[Lunar-commits] <lunar-iso> Added stage2 make rules

Peter de Ridder peter at lunar-linux.org
Thu Apr 11 00:32:15 CEST 2013


commit 1e1fbe6d24f6db421ac1347f0cb18fc735989e97
Author: Peter de Ridder <peter at lunar-linux.org>
Date: Tue, 28 Aug 2012 15:13:57 -0700
URL: https://github.com/lunar-linux/lunar-iso/commit/1e1fbe6d24f6db421ac1347f0cb18fc735989e97

Added stage2 make rules
---
  Makefile             | +5/-2     
  mkfiles/bootstrap.mk | +7/-8     
  mkfiles/build.mk     | +0/-32    
  mkfiles/download.mk  | +10/-22   
  mkfiles/stage1.mk    | +56/-0    
  mkfiles/stage2.mk    | +88/-0    
  6 files changed, 166 insertions(+), 64 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -27,11 +27,14 @@ ISO_TARGET = $(ISO_SOURCE)/BUILD
 
 export ISO_SOURCE ISO_TARGET ISO_BUILD
 
-all: build
+all: stage2
+
+.SUFFIXES:
 
 include mkfiles/bootstrap.mk
 include mkfiles/download.mk
-include mkfiles/build.mk
+include mkfiles/stage1.mk
+include mkfiles/stage2.mk
 
 clean:
 	rm -rf $(ISO_TARGET) $(ISO_SOURCE)/{spool,cache}
--- a/mkfiles/bootstrap.mk
+++ b/mkfiles/bootstrap.mk
@@ -1,8 +1,12 @@
+.INTERMEDIATE: boostrap bootstrap-base bootstrap-lunar
+
+.SECONDARY: $(ISO_TARGET)/.base $(ISO_TARGET)/.modules $(ISO_SOURCE)/cache/.copied
+
 bootstrap: bootstrap-base bootstrap-lunar
 
 
 # fill the target with the base file required
-$(ISO_TARGET)/.base: $(ISO_TARGET)/.stamp
+$(ISO_TARGET)/.base:
 	@echo bootstrap-base
 	@mkdir -p $(ISO_TARGET)/{bin,dev,etc,lib,mnt,proc,root,run,sbin,sys,tmp,usr,var} $(ISO_TARGET)/run/lock $(ISO_TARGET)/usr/{bin,include,lib,libexec,sbin,src,share} $(ISO_TARGET)/var/{cache,empty,lib,log,spool,state,tmp}
 	@ln -sf lib $(ISO_TARGET)/lib32
@@ -25,8 +29,9 @@ $(ISO_SOURCE)/cache/.copied:
 	@touch $@
 
 # note: use cat after grep to ignore the exit code of grep
-$(ISO_TARGET)/.modules: $(ISO_SOURCE)/cache/.copied $(ISO_TARGET)/.stamp
+$(ISO_TARGET)/.modules: $(ISO_SOURCE)/cache/.copied
 	@echo bootstrap-lunar
+	@mkdir -p $(ISO_TARGET)
 	@for archive in $(ISO_SOURCE)/cache/*-$(ISO_BUILD).tar.bz2 ; do \
 	  tar -xjf "$$archive" -C $(ISO_TARGET) || exit 1 ; \
 	done
@@ -38,9 +43,3 @@ $(ISO_TARGET)/.modules: $(ISO_SOURCE)/cache/.copied $(ISO_TARGET)/.stamp
 	@touch $@
 
 bootstrap-lunar: $(ISO_TARGET)/.modules
-
-
-# create the target directory
-$(ISO_TARGET)/.stamp:
-	@mkdir -p $(ISO_TARGET)
-	@touch $@
--- a/mkfiles/build.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-build: build-toolchain
-
-
-# generate the required cache files
-$(ISO_TARGET)/.moonbase-build: $(ISO_TARGET)/.base $(ISO_TARGET)/.modules $(ISO_TARGET)/.moonbase-download 
-	@echo build-moonbase
-	@$(ISO_SOURCE)/scripts/chroot-build lsh create_module_index
-	@$(ISO_SOURCE)/scripts/chroot-build lsh create_depends_cache
-	@$(ISO_SOURCE)/scripts/chroot-build lsh update_plugins
-	@touch $@
-
-build-moonbase: $(ISO_TARGET)/.moonbase-build
-
-
-# first build sequence to get the toolchain installed properly
-# note: xz is added. The package list is empty and thereby the xz plugin isn't installed.
-$(ISO_TARGET)/.toolchain: $(ISO_TARGET)/.moonbase-build $(ISO_TARGET)/.spool
-	@echo build-toolchain
-	@yes n | $(ISO_SOURCE)/scripts/chroot-build lin -rc kernel-headers glibc binutils gcc binutils glibc
-	@touch $@
-
-build-toolchain: $(ISO_TARGET)/.toolchain
-
-
-# first time build all the require modules for a minimal system
-STAGE1_MODULES=acl attr bash bzip2 coreutils cracklib dialog diffutils e2fsprogs file findutils gawk gettext glib-2 gmp grep gzip installwatch less libcap libffi libmpc lunar make mpfr ncurses net-tools patch procps readline sed shadow tar util-linux wget xz zlib
-
-$(ISO_TARGET)/.stage1: $(ISO_TARGET)/.toolchain
-	yes n | $(ISO_SOURCE)/scripts/chroot-build lin -rc $(STAGE1_MODULES)
-	@touch $@
-
-build-stage1: $(ISO_TARGET)/.stage1
--- a/mkfiles/download.mk
+++ b/mkfiles/download.mk
@@ -1,17 +1,21 @@
-download-sources: install-moonbase download-lunar
+.INTERMEDIATE: download install-moonbase download-lunar
 
-install-sources: install-spool
+.SECONDARY: $(ISO_TARGET)/.install-moonbase
+
+download: download-lunar
 
 
 # download the moonbase
-$(ISO_SOURCE)/spool/moonbase.tar.bz2: $(ISO_SOURCE)/spool/.stamp
+$(ISO_SOURCE)/spool/moonbase.tar.bz2:
 	@echo download-moonbase
+	@mkdir -p $(ISO_SOURCE)/spool
 	@wget -O $@ "`lsh eval echo '$$MOONBASE_URL'`/moonbase.tar.bz2" \
 	  || { rm $@ ; exit 1 ; }
 	@touch $@
 
+
 # note: this installs an empty installed packages list
-$(ISO_TARGET)/.moonbase-download: $(ISO_TARGET)/.stamp $(ISO_SOURCE)/spool/moonbase.tar.bz2
+$(ISO_TARGET)/.install-moonbase: $(ISO_SOURCE)/spool/moonbase.tar.bz2
 	@echo install-moonbase
 	@mkdir -p $(ISO_TARGET)/var/lib/lunar/moonbase
 	@rm -r $(ISO_TARGET)/var/lib/lunar/moonbase
@@ -21,29 +25,13 @@ $(ISO_TARGET)/.moonbase-download: $(ISO_TARGET)/.stamp $(ISO_SOURCE)/spool/moonb
 	@touch $(ISO_TARGET)/var/state/lunar/{packages,depends}{,.backup}
 	@touch $@
 
-install-moonbase: $(ISO_TARGET)/.moonbase-download
+install-moonbase: $(ISO_TARGET)/.install-moonbase
 
 
 # download on a lunar host
-$(ISO_SOURCE)/spool/.copied: $(ISO_TARGET)/.moonbase-download
+$(ISO_SOURCE)/spool/.copied: install-moonbase
 	@echo download-lunar
 	@$(ISO_SOURCE)/scripts/download-lunar-spool
 	@touch $@
 
 download-lunar: $(ISO_SOURCE)/spool/.copied
-
-
-# install the sources
-$(ISO_TARGET)/.spool: $(ISO_SOURCE)/spool/.copied
-	@echo install-spool
-	@mkdir -p $(ISO_TARGET)/var/spool/lunar
-	@cp $(ISO_SOURCE)/spool/* $(ISO_TARGET)/var/spool/lunar/
-	@touch $@
-
-install-spool: $(ISO_TARGET)/.spool
-
-
-# create the spool directory
-$(ISO_SOURCE)/spool/.stamp:
-	@mkdir -p $(ISO_SOURCE)/spool
-	@touch $@
--- /dev/null
+++ b/mkfiles/stage1.mk
@@ -0,0 +1,56 @@
+.INTERMEDIATE: stage1 stage1-spool stage1-moonbase stage1-toolchain stage1-build stage1-cache
+
+.SECONDARY: $(ISO_TARGET)/.stage1-spool $(ISO_TARGET)/.stage1-moonbase $(ISO_TARGET)/.stage1-toolchain $(ISO_TARGET)/.stage1
+
+stage1: stage1-cache
+
+
+# install the sources
+$(ISO_TARGET)/.stage1-spool: download
+	@echo stage1-spool
+	@mkdir -p $(ISO_TARGET)/var/spool/lunar
+	@cp $(ISO_SOURCE)/spool/* $(ISO_TARGET)/var/spool/lunar/
+	@touch $@
+
+stage1-spool: $(ISO_TARGET)/.stage1-spool
+
+
+# generate the required cache files
+$(ISO_TARGET)/.stage1-moonbase: bootstrap install-moonbase
+	@echo stage1-moonbase
+	@$(ISO_SOURCE)/scripts/chroot-build lsh create_module_index
+	@$(ISO_SOURCE)/scripts/chroot-build lsh create_depends_cache
+	@$(ISO_SOURCE)/scripts/chroot-build lsh update_plugins
+	@touch $@
+
+stage1-moonbase: $(ISO_TARGET)/.stage1-moonbase
+
+
+# first build sequence to get the toolchain installed properly
+$(ISO_TARGET)/.stage1-toolchain: stage1-moonbase stage1-spool
+	@echo stage1-toolchain
+	@yes n | $(ISO_SOURCE)/scripts/chroot-build lin -rc kernel-headers glibc binutils gcc binutils glibc
+	@touch $@
+
+stage1-toolchain: $(ISO_TARGET)/.stage1-toolchain
+
+
+# first time build all the require modules for a minimal system
+STAGE1_MODULES=acl attr bash bzip2 coreutils cracklib dialog diffutils e2fsprogs file findutils gawk gettext glib-2 gmp grep gzip installwatch less libcap libffi libmpc lunar make mpfr ncurses net-tools patch procps readline sed shadow tar util-linux wget xz zlib
+
+$(ISO_TARGET)/.stage1: stage1-toolchain
+	@echo stage1-build
+	@yes n | $(ISO_SOURCE)/scripts/chroot-build lin -rc $(STAGE1_MODULES)
+	@touch $@
+
+stage1-build: $(ISO_TARGET)/.stage1
+
+
+# replace the cache with the new build cache
+$(ISO_SOURCE)/cache/.stage1: stage1-build
+	@echo stage1-cache
+	@rm -rf $(ISO_SOURCE)/cache
+	@cp -r $(ISO_TARGET)/var/cache/lunar $(ISO_SOURCE)/cache
+	@touch $@
+
+stage1-cache: $(ISO_SOURCE)/cache/.stage1
--- /dev/null
+++ b/mkfiles/stage2.mk
@@ -0,0 +1,88 @@
+.INTERMEDIATE: stage2 stage2-target stage2-base stage2-modules stage2-spool stage2-extract-moonbase stage2-moonbase stage2-build
+
+stage2: stage2-build
+
+
+# clean the target directory for stage2
+$(ISO_TARGET)/.stage2-target: stage1
+	@echo stage2-target
+	@rm -rf $(ISO_TARGET)
+	@mkdir $(ISO_TARGET)
+	@touch $@
+
+stage2-target: $(ISO_TARGET)/.stage2-target
+
+
+# create base directory structure
+$(ISO_TARGET)/.stage2-base: stage2-target
+	@echo stage2-base
+	@mkdir -p $(ISO_TARGET)/{bin,dev,etc,lib,mnt,proc,root,run,sbin,sys,tmp,usr,var} $(ISO_TARGET)/run/lock $(ISO_TARGET)/usr/{bin,include,lib,libexec,sbin,src,share} $(ISO_TARGET)/var/{cache,empty,lib,log,spool,state,tmp}
+	@ln -sf lib $(ISO_TARGET)/lib32
+	@ln -sf lib $(ISO_TARGET)/lib64
+	@ln -sf lib $(ISO_TARGET)/usr/lib32
+	@ln -sf lib $(ISO_TARGET)/usr/lib64
+	@ln -sf ../run/lock $(ISO_TARGET)/var/lock
+	@ln -sf ../run $(ISO_TARGET)/var/run
+	@cp -r $(ISO_SOURCE)/template/etc $(ISO_TARGET)
+	@echo MAKES=$(ISO_MAKES) > $(ISO_TARGET)/etc/lunar/local/optimizations.GNU_MAKE
+	@touch $@
+
+stage2-base: $(ISO_TARGET)/.stage2-base
+
+
+# install the module caches
+$(ISO_TARGET)/.stage2-modules: stage2-target
+	@echo stage2-modules
+	@for archive in $(ISO_SOURCE)/cache/*-$(ISO_BUILD).tar.bz2 ; do \
+	  tar -xjf "$$archive" -C $(ISO_TARGET) || exit 1 ; \
+	done
+	@mkdir -p $(ISO_TARGET)/var/state/lunar
+	@touch $(ISO_TARGET)/var/state/lunar/packages{,.backup}
+	@touch $@
+
+stage2-modules: $(ISO_TARGET)/.stage2-modules
+
+
+# copy the source files
+$(ISO_TARGET)/.stage2-spool: stage2-target download
+	@echo stage2-spool
+	@mkdir -p $(ISO_TARGET)/var/spool/lunar
+	@cp $(ISO_SOURCE)/spool/* $(ISO_TARGET)/var/spool/lunar/
+	@touch $@
+
+stage2-spool: $(ISO_TARGET)/.stage2-spool
+
+
+$(ISO_TARGET)/.stage2-extract-moonbase: stage2-target $(ISO_SOURCE)/spool/moonbase.tar.bz2
+	@echo stage2-extract-moonbase
+	@mkdir -p $(ISO_TARGET)/var/lib/lunar/moonbase
+	@rm -r $(ISO_TARGET)/var/lib/lunar/moonbase
+	@tar -xjf $(ISO_SOURCE)/spool/moonbase.tar.bz2 -C $(ISO_TARGET)/var/lib/lunar moonbase/core moonbase/aliases
+	@mkdir -p $(ISO_TARGET)/var/lib/lunar/moonbase/zlocal
+	@mkdir -p $(ISO_TARGET)/var/state/lunar/moonbase
+	@touch $(ISO_TARGET)/var/state/lunar/{packages,depends}{,.backup}
+	@touch $@
+
+stage2-extract-moonbase: $(ISO_TARGET)/.stage2-extract-moonbase
+
+
+# generate the required cache files
+$(ISO_TARGET)/.stage2-moonbase: stage2-base stage2-modules stage2-extract-moonbase
+	@echo stage2-build-moonbase
+	@$(ISO_SOURCE)/scripts/chroot-build lsh create_module_index
+	@$(ISO_SOURCE)/scripts/chroot-build lsh create_depends_cache
+	@$(ISO_SOURCE)/scripts/chroot-build lsh update_plugins
+	@touch $@
+
+stage2-moonbase: $(ISO_TARGET)/.stage2-moonbase
+
+
+# build all the require modules for the iso
+STAGE2_MODULES=acl attr bash binutils bzip2 coreutils cracklib dialog diffutils e2fsprogs file findutils gawk gcc gettext glib-2 glibc gmp grep gzip installwatch less libcap libffi libmpc lunar make mpfr ncurses net-tools patch procps readline sed shadow tar util-linux wget xz zlib
+
+$(ISO_TARGET)/.stage2: stage2-moonbase stage2-spool
+	@echo stage2-build
+	@yes n | $(ISO_SOURCE)/scripts/chroot-build lin -c $(STAGE1_MODULES)
+	@touch $@
+
+stage2-build: $(ISO_TARGET)/.stage2




More information about the Lunar-commits mailing list