Recording Git hash of downloaded package

I have some local packages that are downloaded from a private Git repo using PKG_SOURCE_URL and PKG_SOURCE_VERSION. While PKG_SOURCE_VERSION usually points to a tag or branch during development, I'd like to keep a more specific record of what version of code ends up in a package or image ie. the git SHA1 or maybe the output from git describe.

I thought maybe I could do this by hooking into the download step and writing the git hash out to a file before .git gets deleted. But I can't figure out what the build target is for downloaded (akin to Build/Configure for overriding the build stage, but for downloading).

  • Is there a better way to record this information?
  • If I were to do it by hooking into the download/archiving process, what target to I need to override in my package's makefile?

At least I figured this out. It's just called Download, so you can do:

define Download/mypackage
	$(call Download,mypackage)
endef

Looking at eg. the GCC packaging, they do this:

define Download/gmp
  URL:=ftp://gcc.gnu.org/pub/gcc/infrastructure/
  FILE:=$(GMPSRC).tar.bz2
  HASH:=936162c0312886c21581002b79932829aa048cfaf9937c6265aeaa14f1cd1775
endef
$(eval $(call Download,gmp))

I don't know why they have the $(eval $(call ...)) sitting outside the define like that, but the other way seems to work fine.

Unfortunately this doesn't help me, because the Download target doesn't have any hooks in the checkout/delete .git/compress into archive operation, and I don't know that I want to re-implement all the downloading logic for this.

1 Like

I'm not entirely sure I understand your use case correctly, but there are a couple of answers to this depending on what your needs are.

PKG_SOURCE_VERSION can specifiy the git commit hash. In which case, you're satisfying your condition of keeping the git SHA since it's specified in the Makefile

Assuming you want some more detailed information which you would save to a log somewhere, you'd probably need to edit include/download.mk and edit the method DownloadMethod/rawgit to add some logic when it does the checkout.

Really it's about being lazy — I want to be able to leave PKG_SOURCE_VERSION set to eg. develop or v0.9_pre in the makefile, but still be able to tell what version of what packages are in use when someone testing such an image tells me about an issue.

I try not to hack on upstream makefiles, but I can always copy out the code I need into a separate makefile that I can include.