function get_version_from_source_list_file(){ # Usage $1 for pkgname $2 for path echo $(apt -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf show ${1} -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" -o Dir::Etc::sourcelist="${2}" | grep -oP 'Version: \K\S+') } function aptss_get_update(){ sudo aptss update if [ "$?" = "0" ];then log.info "aptss update ok" else log.error "aptss is locked.Give up" exit 1 fi } function get_version_from_aptss(){ echo $(aptss show ${1} | grep -oP 'Version: \K\S+') } function get_version_from_github(){ local GITHUB_REPO=${1} local github_api_url="https://api.github.com/repos/$GITHUB_REPO/releases/latest" local resp="$(curl -s $github_api_url)" local VERSION_GITHUB="$(jq -r '.tag_name' <<<$resp | sed "s/.*V\([^_]*\).*/\1/g")" echo "$VERSION_GITHUB" } function compare_version(){ VERSION_IN_REPO=${1} VERSION_GITHUB=${2} if dpkg --compare-versions "$VERSION_IN_REPO" "<<" "$VERSION_GITHUB";then ## Here we give the value to version VERSION=$VERSION_GITHUB else log.info "No need to upgrade, exit" exit fi } function init_package_directory(){ if [ "$1" = "" ];then local package_dir=`pwd` else local package_dir="$1" fi mkdir -p $package_dir/DEBIAN mkdir -p $package_dir/opt/apps/$PKG_NAME/entries/applications mkdir -p $package_dir/opt/apps/$PKG_NAME/entries/icons mkdir -p $package_dir/opt/apps/$PKG_NAME/files ######## Apply template if [ -e "$HERE_PATH/template" ];then cp -r "$HERE_PATH/template/"* $package_dir fi } function get_size(){ if [ "$1" = "" ];then local package_dir=`pwd` else local package_dir="$1" fi local SIZE=`du -sh $package_dir` echo ${SIZE%%/*} } function write_control(){ if [ "$1" = "" ];then local package_dir=`pwd` else local package_dir="$1" fi get_size cat << EOFFFFFF > $package_dir/DEBIAN/control Package: ${PKG_NAME} Version: ${VERSION} Maintainer: ${MAINTAINER} Homepage: ${HOMEPAGE} Architecture: ${ARCH} Section: ${SECTION} Priority: ${PRIORITY} Depends: ${DEPENDS} Recommends: ${RECOMMENDS} Provides: ${PROVIDES} Replaces: ${REPLACES} Installed-Size: $(get_size $WORKDIR) Description: ${DESCRIPTION_SHORT} ${DESCRIPTION_LONG} EOFFFFFF chmod 755 DEBIAN/control } function write_info(){ if [ "$1" = "" ];then local package_dir=`pwd` else local package_dir="$1" fi cat << EOFFFFFF > $package_dir/opt/apps/${PKG_NAME}/info { "appid": "${PKG_NAME}", "name": "${PKG_NAME}", "version": "${VERSION}", "arch": ["${ARCH}"], "permissions": { "autostart": true, "notification": true, "trayicon": true, "clipboard": true, "account": true, "bluetooth": true, "camera": true, "audio_record": true, "installed_apps": true } } EOFFFFFF } function write_json(){ if [ "$1" = "" ];then local package_dir=`pwd` else local package_dir="$1" fi cat << EOFFFFFF > $package_dir/app.json.update { "Name": "${APP_NAME}", "Version": "${VERSION}", "Filename": "${PKG_NAME}_${VERSION}_${ARCH}.deb", "Torrent_address": "${PKG_NAME}_${VERSION}_${ARCH}.deb.torrent", "Pkgname": "${PKG_NAME}", "Author": "${MAINTAINER}", "Contributor": "${MAINTAINER}", "Website": "${HOMEPAGE}", "Update": "$(date +'%Y-%m-%d %H:%M:%S')", "Size": "$(get_size "$STORE_APP_PATH"/${PKG_NAME}_${VERSION}_${ARCH}.deb)", "More": "${DETAIL}", "Tags": "${TAGS}", "img_urls": "[\"https://cdn.d.store.deepinos.org.cn/store/${CAGATORY}/${PKG_NAME}/screen_1.png\",\"https://cdn.d.store.deepinos.org.cn/store/${CAGATORY}/${PKG_NAME}/screen_2.png\",\"https://cdn.d.store.deepinos.org.cn/store/${CAGATORY}/${PKG_NAME}/screen_3.png\",\"https://cdn.d.store.deepinos.org.cn/store/${CAGATORY}/${PKG_NAME}/screen_4.png\",\"https://cdn.d.store.deepinos.org.cn/store/${CAGATORY}/${PKG_NAME}/screen_5.png\"]", "icons": "https://cdn.d.store.deepinos.org.cn/store/${CAGATORY}/${PKG_NAME}/icon.png" } EOFFFFFF }