kenzok8 / openwrt-packages

openwrt常用软件包
https://op.dllkids.xyz
6.26k stars 2.59k forks source link

请教一下Makefile中PKG_MIRROR_HASH具体是如何计算出来的?也就是PKG_HASH #459

Open qwerttvv opened 3 months ago

qwerttvv commented 3 months ago

我想从git弄nightly,不从release这里弄

比如说 PKG_NAME:=smartdns PKG_VERSION:=1.2024.10 PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://www.github.com/pymumu/smartdns.git PKG_SOURCE_VERSION:=40dc9eceb78ac558b235a128241b1a4d2819f15f PKG_MIRROR_HASH:= 如果其它已知,PKG_MIRROR_HASH未知,那这个值是如何计算的呢?

这里的PKG_MIRROR_HASH,我看文档是从 https://www.github.com/pymumu/smartdns.git 打包一个tar.xz后计算sha256,但是这个tar.xz请问下是如何打包的,我试了很久,最终的hash都对不上,没办法去openwrt/gh-action-sdk编译

或者说这个PKG_MIRROR_HASH是依靠什么脚本或者其它工具生成的?我想学习下这个值的生成过程

不要skip,openwrt/gh-action-sdk不能用skip,我想要这个值的生成过程

尝试过很多方法,例如下面的

$SHA_smartdns已经获取后,相关流程如下,哪里不对…或者说正确方法是啥

  git clone https://www.github.com/pymumu/smartdns.git smartdns-$(date +1.%Y.%m.%d-%H)
  cd smartdns-$(date +1.%Y.%m.%d-%H)
  git checkout $SHA_smartdns
  git submodule update --init --recursive
  echo "TAR_TIMESTAMP=$(git log -1 --format='@%ct')" >> $GITHUB_ENV
  rm -rf .git

然后

  tar --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name $$$${TAR_TIMESTAMP:+--mtime="$$$$TAR_TIMESTAMP"} -c smartdns-$(date +1.%Y.%m.%d-%H) | xz -zc -7e > ../smartdns-$(date +1.%Y.%m.%d-%H).tar.xz
  echo "PKG_MIRROR_HASH=$(sha256sum ../smartdns-$(date +1.%Y.%m.%d-%H).tar.xz | cut -d ' ' -f1)" >> $GITHUB_ENV

之后改Makefile准备去openwrt/gh-action-sdk@main运行

  sed -i "s/PKG_VERSION:=.*/PKG_VERSION:=$(date +1.%Y.%m.%d-%H)/" Makefile
  sed -i "s/PKG_SOURCE_VERSION:=.*/PKG_SOURCE_VERSION:=$SHA_smartdns/" Makefile
  sed -i "s/PKG_MIRROR_HASH:=.*/PKG_MIRROR_HASH:=$PKG_MIRROR_HASH/" Makefile

或者tar的步骤改为

tar --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name ${TAR_TIMESTAMP:+--mtime="$TAR_TIMESTAMP"} -c smartdns-$(date +1.%Y.%m.%d-%H) | xz -zc -7e > ../smartdns-$(date +1.%Y.%m.%d-%H).tar.xz

以上都不对……

tar的步骤我是在openwrt/gh-action-sdk运行的日志里和官网一个mk文件里看到,mk文件里是$$$${TAR_TIMESTAMP:+--mtime="$$$$TAR_TIMESTAMP"},日志里是${TAR_TIMESTAMP:+--mtime="$TAR_TIMESTAMP"},全不对,在openwrt/gh-action-sdk没办法运行

kenzok8 commented 3 months ago

第一次没审题,回答没仔细! 这个蛮简单的 比如ssh 或者终端下运行 wget https://codeload.github.com/pymumu/smartdns/tar.gz/Release45 然后 sha256sum 文件名 就可以出来

qwerttvv commented 3 months ago

呃,,我也编辑下,我想从git弄nightly,不从release这里弄

多谢回复,但是不太对呀

https://openwrt.org/docs/guide-developer/packages#use_source_repository 这里提示要打包源码到tar.xz之后对文件生成hash,具体怎么打包没说,后来看运行openwrt/gh-action-sdk的日志,自己照抄不太对,又搜了搜,搜到了以下

https://github.com/openwrt/openwrt/blob/master/include/download.mk#L29 这里29到66行

搜到这个我看和日志只有一点点不一样,两种我都试了,也都不对……

qwerttvv commented 3 months ago

从从git弄nightly builds现在其实解决方法也有,也不麻烦,但是我有点儿就是想知道这个值怎么算出来的…一不忙了就想知道知道,较劲了有点儿……