From 4ed4a3244da9acedf0df6894aec8ae4ddaf0ecf3 Mon Sep 17 00:00:00 2001 From: Pierre Labastie Date: Sat, 1 May 2021 09:22:06 +0200 Subject: [PATCH] Allow using any branch/tag in BLFS Makefile Still WIP because of the *_TREE names --- BLFS/Makefile | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/BLFS/Makefile b/BLFS/Makefile index d4d01bd..a95f141 100644 --- a/BLFS/Makefile +++ b/BLFS/Makefile @@ -56,8 +56,11 @@ define INITIAL_TRACK endef +# Git locations and branches LFS-GIT = git://git.linuxfromscratch.org/lfs.git +LFS-BRANCH = trunk GIT = git://git.linuxfromscratch.org/blfs.git +BLFS-BRANCH = trunk ALLXML := $(filter-out $(RENDERTMP)/%, \ $(shell if [ -d $(BLFS_XML) ]; then \ @@ -178,18 +181,34 @@ $(BLFS_FULL): $(BLFS_XML) $(BLFS_XML)/general.ent $(ALLXML) $(ALLXSL) all: update $(BOOK_XML) +# If in detached head state, "git pull" returns an error, so switch back to +# trunk before updating, and switch back to the branch/tag afterwards update: $(BLFS_XML) $(LFS_XML) @echo Updating the book sources - $(Q)cd $(LFS_XML) && git pull - $(Q)cd $(BLFS_XML) && git pull + $(Q)cd $(LFS_XML) && \ + if [ $(LFS-BRANCH) != trunk ]; then git switch -; fi && \ + git pull && \ + git checkout $(LFS-BRANCH) + $(Q)cd $(BLFS_XML) && \ + if [ $(BLFS-BRANCH) != trunk ]; then git switch -; fi && \ + git pull && \ + git checkout $(BLFS-BRANCH) $(LFS_XML): @echo Getting the LFS book sources... $(Q)git clone $(LFS-GIT) $@ + if [ $(LFS-BRANCH) != trunk ]; then \ + cd $@ && \ + git checkout $(LFS-BRANCH); \ + fi $(BLFS_XML): @echo Getting the BLFS book sources... $(Q)git clone $(GIT) $@ + if [ $(BLFS-BRANCH) != trunk ]; then \ + cd $@ && \ + git checkout $(BLFS-BRANCH); \ + fi # Clean up