openwrt / gh-action-sdk

GitHub CI action to build packages via SDK
29 stars 47 forks source link

"PKG_MIRROR_HASH:=skip" in Makefile, but build fails with "Package HASH check failed". #35

Open qwerttvv opened 5 months ago

qwerttvv commented 5 months ago

"PKG_MIRROR_HASH:=skip" in Makefile, but build fails with "Package HASH check failed".

I saw this https://github.com/openwrt/gh-action-sdk/issues/18 but it didn't help

Makefile like

PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://www.github.com/xx/xx.git PKG_MIRROR_HASH:=skip PKG_SOURCE_VERSION:=b482340c35d47f63fecfb324f4d513c5f2255190

build log step: make package/openwrt-pkg/check

make[1]: Entering directory '/builder' make[2]: Entering directory '/feed/openwrt-pkg' WARNING: PKG_MIRROR_HASH uses deprecated hash, set to 5cb6d1cf30437d42a1b172a7d3477eea178f26330dd26e32fff2c7741559cae1 make[2]: Leaving directory '/feed/openwrt-pkg' time: package/feeds/packages_ci/openwrt-pkg/check#0.01#0.00#0.02 make[1]: Leaving directory '/builder' Package HASH check failed Error: Process completed with exit code 1.

I removed "PKG_MIRROR_HASH:=skip" from the Makefile, the problem is still there, the error is WARNING: PKG_MIRROR_HASH is missing, set to

Any help?

qwerttvv commented 5 months ago

May I ask how this PKG_MIRROR_HASH is derived?

I read the documentation, it is source code to generate tar.xz sha265, but I tried for a long time, the hash is never correct, I think it is the step of generating the tar.xz is wrong, please tell me how to correctly package the source code to generate the tar.xz so as to calculate this value

THX

qwerttvv commented 5 months ago

Many methods have been tried, such as the following

After $SHA_smartdns has been obtained, the process is as follows, what's wrong...or what's the correct method?

      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

after that

      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

After that change the Makefile ready to go to openwrt/gh-action-sdk@main to run

      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

or one of and so on...

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

It's all wrong.