#!/bin/bash # Special thank to Shiroko, he give me the insight of coding in proper way # Usage: $0 [arch] ################################# Here we set the configs REALPATH=`realpath $0` HERE_PATH=`dirname $REALPATH` STORE_APP_PATH="$HERE_PATH" WORKDIR=`mktemp -d` ARCH="" # Define it later ARCH_ANOTHERWAY="" # Define it later PKG_NAME="net.hmcl.huangyuhui" APP_NAME="HMCL我的世界启动器" GITHUB_REPO="HMCL-dev/HMCL" #格式像这样。只在从github获取信息才使用,如果不是,则注释掉。后续下载也整合进入helper VERSION="" # 定义版本号。或者,在后续prepare或build中定义。可使用其他两个bashimport文件中的功能 TAGS="ubuntu;deepin;uos;debian" # 星火的tag信息 CATAGORY="games" #https://gitee.com/deepin-community-store/spark-store/blob/dev/DOCS/spk-doc.md DETAIL="2023/12/23:在原有包基础上重新打包,版本号由原来的开发版3.5.4.232改为3.5.5正式版\n使用星火商店的用户不需要进行任何改动就可以正常使用,如果想不安装星火商店而正常安装此包,请在安装游戏前安装\nhttps://shenmo.lanzoul.com/iqj2vyrkhgj" # This should be written as json format HOMEPAGE="https://github.com/HMCL-dev/HMCL" MAINTAINER="shenmo" ################################# Fill the variables below only if you use write_control function SECTION="games" PRIORITY="optional" DEPENDS="deepin-elf-verify (>= 1.1.10-1), fonts-wqy-zenhei, fonts-wqy-microhei, net.hmcl.huangyuhui.jre21" DESCRIPTION_SHORT="HMCL启动器正式版 3.5.8.249 by huanghongxun" DESCRIPTION_LONG="" PROVIDES="" REPLACES="" RECOMMENDS="" ################################# Here we import our tools if [ ! -e "/opt/bashimport/sbs-utils.bashimport" ];then echo "Need to install spark-building-service deb first! exit" exit 1 fi source /opt/bashimport/sbs-utils.bashimport source /opt/bashimport/sbs-build-helper.bashimport ##这两个里面有详尽的解释 if [ "$1" = "amd64" ] || [ "$1" = "x64" ];then ARCH="amd64" ARCH_ANOTHERWAY="-amd64" elif [ "$1" = "arm64" ] || [ "$1" = "arm" ];then ARCH="arm64" ARCH_ANOTHERWAY="-aarch64" elif [ "$1" = "loong64" ];then ARCH="loong64" ARCH_ANOTHERWAY="-loong64" ARCH_STORE_PATH="loong64-store" else log.error "Err:Invalid Architecture" exit 1 fi # ===== Log 用法 ===== # log.info xxx # log.warn xxx # log.info xxx # log.debug xxx # 带颜色的echo function prepare(){ # Below is the usable funcions # aptss_get_update():更新apt源并检查是否成功,如果成功则记录日志为“aptss update ok”,否则记录日志为“aptss is locked.Give up”并退出。 # get_version_from_aptss():从aptss(全部)源中获取指定软件包的版本号。实战中建议使用下方的函数替代以避免无法预知的情况 # get_version_from_source_list_file ${PKG_NAME} ${PATH_TO_SOURCE_LIST} # compare_version ${VER_Apt} ${VER_Upstream} (Will give the upstream version as variable $VERSION if it is higher or exit if they are the same or Ver_Apt is higher) # get_version_from_github():从github上获取指定仓库的最新发布版本号。需要定义GITHUB_REPO变量。会给返回值 # get_size():获取软件包目录的大小并返回值 VER_APTSS=$(get_version_from_source_list_file ${PKG_NAME} /opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore${ARCH_ANOTHERWAY}.list) VER_GITHUB=$(get_version_from_github $GITHUB_REPO) VER_GITHUB_NO_v=$(echo $VER_GITHUB | sed 's/^[^0-9]*//') compare_version ${VER_APTSS} ${VER_GITHUB_NO_v} } function build(){ pushd $STORE_APP_PATH # init_package_directory():初始化软件包目录,创建DEBIAN、opt/apps//entries/applications、opt/apps//entries/icons和opt/apps//files等目录,并将模板应用到软件包目录中。 # write_control():在软件包目录中生成control文件,并设置软件包的基本信息,如名称、版本、维护者、主页、架构、依赖关系、描述等。 # write_info():在软件包目录/opt/apps//下生成info文件,记录软件包的基本信息,如appid、名称、版本、架构、权限等。 # write_json():在软件包目录中生成app.json.update文件,记录软件包的详细信息,如名称、版本、文件名、种子地址、作者、贡献者、主页、更新时间、大小、更多信息、标签、截图地址和图标地址等。应当在商店目录使用而不是workdir init_package_directory write_control write_info url1="https://github.com/${GITHUB_REPO}/releases/download/${VER_GITHUB}/HMCL-${VERSION}.jar" echo $url1 aria2c $url1 --check-certificate=false -o opt/apps/net.hmcl.huangyuhui/files/lib/hmcl/HMCL-${VERSION}.jar dpkg-deb -Z xz -b . ${STORE_APP_PATH}/${PKG_NAME}_${VERSION}_${ARCH}.deb popd } prepare build write_json $STORE_APP_PATH rm -rf $WORKDIR