M Sylvester B has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/29778
Change subject: [WIP]LinuxBoot: refactor u-root.mk ......................................................................
[WIP]LinuxBoot: refactor u-root.mk
Clean the u-root initramfs integration.
TODO: - handle all u-root flags
Change-Id: Id978ed2ebeff96c5be4f74ae07df9be76e106a1b Signed-off-by: Marcello Sylvester Bauer info@marcellobauer.com --- M payloads/external/LinuxBoot/Makefile M payloads/external/LinuxBoot/targets/u-root.mk 2 files changed, 18 insertions(+), 41 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/78/29778/1
diff --git a/payloads/external/LinuxBoot/Makefile b/payloads/external/LinuxBoot/Makefile index a9b35fc..456d846 100644 --- a/payloads/external/LinuxBoot/Makefile +++ b/payloads/external/LinuxBoot/Makefile @@ -58,7 +58,8 @@
clean: if [ -d "$(kernel_dir)" ]; then rm -rf $(kernel_dir); fi - rm -f $(project_dir)/initramfs.cpio.xz + rm -f $(project_dir)/u-root + rm -f $(project_dir)/initramfs_u-root.cpio.xz
distclean: rm -rf $(project_dir) diff --git a/payloads/external/LinuxBoot/targets/u-root.mk b/payloads/external/LinuxBoot/targets/u-root.mk index 5cb19bb..dc570b5 100644 --- a/payloads/external/LinuxBoot/targets/u-root.mk +++ b/payloads/external/LinuxBoot/targets/u-root.mk @@ -13,19 +13,18 @@ ## GNU General Public License for more details. ##
-uroot_git_repo=https://github.com/u-root/u-root.git -uroot_dir=$(project_dir)/go/src/github.com/u-root/u-root go_version=$(shell go version | sed -nr 's/.*go([0-9]+.[0-9]+.?[0-9]?).*/\1/p' ) go_version_major=$(shell echo $(go_version) | sed -nr 's/^([0-9]+).([0-9]+).?([0-9]*)$$/\1/p') go_version_minor=$(shell echo $(go_version) | sed -nr 's/^([0-9]+).([0-9]+).?([0-9]*)$$/\2/p')
project_dir=$(shell pwd)/linuxboot -project_name=u-root -go_path_dir=$(shell pwd)/linuxboot/go +go_path_dir=$(project_dir)/go +uroot_bin=$(project_dir)/u-root +uroot_package=github.com/u-root/u-root
all: u-root
-check: +version: ifeq ("$(go_version)","") printf "\n<<Please install Golang >= 1.9 for u-root mode>>\n\n" exit 1 @@ -37,59 +36,36 @@ exit 1 endif endif - mkdir -p $(project_dir)/go/src/github.com/u-root
-$(uroot_dir)/.git: - echo " Git Cloning u-root $(CONFIG_LINUXBOOT_UROOT_VERSION)" - git clone $(uroot_git_repo) $(uroot_dir) +get: version + GOPATH=$(go_path_dir) go get -u $(uroot_package)
-fetch: check $(uroot_dir)/.git - -cd "$(uroot_dir)" && git fetch origin +checkout: get + git -C $(go_path_dir)/src/$(uroot_package) checkout $(CONFIG_LINUXBOOT_UROOT_VERSION)
-checkout: fetch - cd "$(uroot_dir)" && \ - if ! git diff --quiet _cb_checkout "$(CONFIG_LINUXBOOT_UROOT_VERSION)" -- 2>/dev/null; \ - then \ - printf " CHECKOUT $(project_name) [$(CONFIG_LINUXBOOT_UROOT_VERSION)]\n"; \ - git checkout $$(git rev-parse HEAD) >/dev/null 2>&1; \ - git branch -f _cb_checkout "$(CONFIG_LINUXBOOT_UROOT_VERSION)" && \ - git checkout _cb_checkout && \ - $(if $(project_patches), \ - for patch in $(project_patches); do \ - printf " PATCH $$patch\n"; \ - git am --keep-cr "$$patch" || \ - ( printf "Error when applying patches.\n"; \ - git am --abort; exit 1; ); \ - done;,true;) \ - fi +build: checkout + GOPATH=$(go_path_dir) go build -o $(uroot_bin) $(uroot_package)
-$(uroot_dir)/u-root: $(uroot_dir)/u-root.go - echo " GO u-root" - cd $(uroot_dir); GOPATH=$(go_path_dir) go build u-root.go - -$(project_dir)/initramfs_u-root.cpio.xz: checkout $(uroot_dir)/u-root - echo " MAKE u-root $(CONFIG_LINUXBOOT_UROOT_VERSION)" +u-root: build ifneq ($(CONFIG_LINUXBOOT_UROOT_COMMANDS),) ifneq ($(CONFIG_LINUXBOOT_UROOT_FILES),) - cd $(uroot_dir); GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) ./u-root \ + GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) $(uroot_bin) \ -build=bb -files $(CONFIG_LINUXBOOT_UROOT_FILES) -o $(project_dir)/initramfs_u-root.cpio \ $(patsubst %,cmds/%,$(CONFIG_LINUXBOOT_UROOT_COMMANDS)) else - cd $(uroot_dir); GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) ./u-root \ + GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) $(uroot_bin) \ -build=bb -o $(project_dir)/initramfs_u-root.cpio \ $(patsubst %,cmds/%,$(CONFIG_LINUXBOOT_UROOT_COMMANDS)) endif else ifneq ($(CONFIG_LINUXBOOT_UROOT_FILES),) - cd $(uroot_dir); GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) ./u-root \ + GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) $(uroot_bin) \ -build=bb -files $(CONFIG_LINUXBOOT_UROOT_FILES) -o $(project_dir)/initramfs_u-root.cpio coreboot-app else - cd $(uroot_dir); GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) ./u-root \ + GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) $(uroot_bin) \ -build=bb -o $(project_dir)/initramfs_u-root.cpio coreboot-app endif endif xz -f --check=crc32 -9 --lzma2=dict=1MiB --threads=$(CPUS) $(project_dir)/initramfs_u-root.cpio
-u-root: $(project_dir)/initramfs_u-root.cpio.xz - -.PHONY: u-root checkout fetch all check +.PHONY: all u-root build checkout get version