Skip to content

Can you tell me exactly how PKG_MIRROR_HASH is calculated in the Makefile? #23656

Description

@qwerttvv

For example

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:=

If everything else is known and PKG_MIRROR_HASH is unknown, how is this value calculated?

PKG_MIRROR_HASH, I see the document, its from https://www.github.com/pymumu/smartdns.git packaged a tar.xz after the calculation of sha256, but this tar.xz please ask how to pack, I tried for a long time, the final hash can not be matched, no way to go to the openwrt/gh-action-sdk compile

Or what script or other tool is used to generate this PKG_MIRROR_HASH? I would like to learn the process of generating this value

No skip, openwrt/gh-action-sdk doesn't work with skip, I want to learn the process of generating this value.

I've tried a lot of things, such as the following

After $SHA_smartdns has been obtained, the process is as follows, what is wrong... or what is 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 the steps for tar are changed to

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

None of the above is correct ......

The tar steps I saw in the log of openwrt/gh-action-sdk run and in a mk file on the official website, the mk file is $$$${TAR_TIMESTAMP:+-- mtime="$$$$TAR_TIMESTAMP"} and the log is ${TAR_TIMESTAMP:+-- mtime="$TAR_TIMESTAMP"}, all wrong, no way to run in openwrt/gh-action-sdk!

https://openwrt.org/docs/guide-developer/packages#use_source_repository
here tips to pack the source code to tar.xz after the file to generate hash, the specific how to pack did not say, and then look at running openwrt/gh-action -sdk logs, I copied it myself is not quite right, and searched, searched the following

https://github.com/openwrt/openwrt/blob/master/include/download.mk#L29
here 29 to 66 lines
I found this I see and log only a little different, I tried both, but also not right ......

Please help...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions