My buildroot environment is downloaded from a git server named gitserver1:
$ git remote -v
origin git@gitserver1:/platforms/buildroot.git (fetch)
This is an example of a buildroot package included in package/company/mypackage/mypackage.mk
GITHOST = git@gitserver2
GIT_PATH = /packages/mypackage.git
GIT_BRANCH = branch
MYPACKAGE_SITE = $(GITHOST):$(GIT_PATH)
MYPACKAGE_SITE_METHOD = git
MYPACKAGE_VERSION = $(GIT_BRANCH)
MYPACKAGE_PKG_NAME = mypackage
MYPACKAGE_PKG_DIR = $(TOPDIR)/package/company/$(MYPACKAGE_PKG_NAME)
MYPACKAGE_BUILD_DIR = $(BUILD_DIR)/$(MYPACKAGE_PKG_NAME)-$(GIT_BRANCH)
define MYPACKAGE_BUILD_CMDS
$(MAKE) CC="$(TARGET_CC)" CFLAGS="$(TARGET_CFLAGS)" -C $(@D)
endef
define MYPACKAGE_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 755 $(@D)/binary $(TARGET_DIR)/usr/bin/
endef
$(MYPACKAGE_PKG_NAME)-clean:
if test -d $(MYPACKAGE_BUILD_DIR); then make clean -C $(MYPACKAGE_BUILD_DIR); fi
$(MYPACKAGE_PKG_NAME)-dirclean: $(MYPACKAGE_PKG_NAME)-clean
rm -Rf $(DL_DIR)/$(MYPACKAGE_PKG_NAME)-$(GIT_BRANCH).tar.gz
$(MYPACKAGE_PKG_NAME)-rebuild: $(MYPACKAGE_PKG_NAME)-clean
ifeq ($(BR2_PACKAGE_MYPACKAGE),y)
$(eval $(generic-package))
endif
The source code of this buildroot package is fetched from a different git server named gitserver2. This remote will be used for the example:
$ git remote -v
origin git@gitserver2:/packages/mypackage.git (fetch)
To build this buildroot package I type:
$ make mypackage
The internal buildroot process:
- downloads a mypackage-branch.tar.gz tarball inside the BR2_DL_DIR.
- creates a local directory output/build/mypackage-branch where the tarball is uncompressed.
My purpose is getting the checksum ID of the commit used for the build of mypackage (for internal reporting). Using a branch, the only way of getting that checksum ID is having the .git directory available.
But when I check the remote repository inside the output/build directory, I get the remote pointing to gitserver1 (the buildroot .git repo), and not the expected (gitserver2):
$ git remote -v
origin git@gitserver1:/platforms/buildroot.git (fetch)
After some responses to this post, I understand the downloaded tarball is uncompressed inside output/build/mypackage-branch, and it doens't contain the .git control information. So when I type git remote -v I get the main repository (gitserver1) and not the repository used to fetch the source code (gitserver2).
As a workaround, I defined this inside the mypackage.mk:
define MYPACKAGE_EXTRACT_CMDS
@$(call MESSAGE, "Extracting $(MYPACKAGE_PKG_NAME) branch $(GIT_BRANCH) from $(GITHOST)")
rm -f $(MYPACKAGE_BUILD_DIR)/.stamp_downloaded
git clone -b $(GIT_BRANCH) $(GITHOST):$(GIT_PATH) $(MYPACKAGE_BUILD_DIR)
touch $(MYPACKAGE_BUILD_DIR)/.stamp_downloaded
endef
Now, once the package is built, I can see the expected remote server (gitserver2) inside the output/build/mypackage-branch directory:
$ git remote -v
origin git@gitserver2:/packages/mypackage.git (fetch)
Here, all the repo history is available, even the last commit ID for the branch used to fetch source code. And I use that information to get the checksum_ID for the compiled branch.
However, this is an awful fix. The package is fetched twice. And I understand this is not the way to go.
Can you suggest a better way to get the expected result? Thanks!