From 316ea6c9de276512969379810f3ba495a3f96939 Mon Sep 17 00:00:00 2001 From: Ivan Davidov Date: Mon, 25 Dec 2017 19:56:06 +0200 Subject: [PATCH] Much better 'Makefile'. Added new 'release' target which generates the sources and then builds MLL from these sources instead of using the development sources. --- src/Makefile | 150 +++++++++++++----- .../bundles/mll_source/bundle.sh | 22 +++ 2 files changed, 130 insertions(+), 42 deletions(-) diff --git a/src/Makefile b/src/Makefile index a57498e46..844e06ebe 100644 --- a/src/Makefile +++ b/src/Makefile @@ -7,55 +7,121 @@ .DEFAULT_GOAL := help all: clean - @echo "Launching the main build script." - @/usr/bin/time -f 'Elapsed time: %E' ./build_minimal_linux_live.sh 2>&1 | tee minimal_linux_live.log + @{ \ + echo "Launching the main build script." ; \ + /usr/bin/time -f "\n Elapsed time: %E" ./build_minimal_linux_live.sh 2>&1 | tee minimal_linux_live.log ; \ + echo "" ; \ + } clean: - @echo "Removing generated work artifacts." - @rm -rf work - @echo "Removing generated build artifacts." - @rm -f minimal_linux_live.iso - @rm -f mll_image.tgz - @echo "Removing predefined configuration files." - @rm -rf minimal_overlay/*.config - @echo "Removing source level overlay software." - @mv -f minimal_overlay/rootfs/README /tmp/mll_overlay_readme - @cd minimal_overlay/rootfs && rm -rf * && cd ../.. - @mv -f /tmp/mll_overlay_readme minimal_overlay/rootfs/README - @echo "Removing build log file." - @rm -f minimal_linux_live.log - @$(eval USE_LOCAL_SOURCE := $(shell grep -i ^USE_LOCAL_SOURCE .config | cut -f2 -d'=')) - @if [ ! "$(USE_LOCAL_SOURCE)" = "true" ]; then echo "Removing source files."; rm -rf source; fi + @{ \ + echo "Removing generated work artifacts." ; \ + rm -rf work ; \ + echo "Removing generated build artifacts." ; \ + rm -f minimal_linux_live.iso ; \ + rm -f mll_image.tgz ; \ + USE_PREDEFINED_KERNEL_CONFIG=`grep -i ^USE_PREDEFINED_KERNEL_CONFIG= .config | cut -f2- -d'=' | xargs` ; \ + if [ ! "$$USE_PREDEFINED_KERNEL_CONFIG" = "true" ] ; then \ + echo "Removing predefined Linux kernel config file." ; \ + rm -rf minimal_overlay/kernel.config ; \ + else \ + echo "Local Linux kernel config file is preserved." ; \ + fi ; \ + USE_PREDEFINED_BUSYBOX_CONFIG=`grep -i ^USE_PREDEFINED_BUSYBOX_CONFIG= .config | cut -f2- -d'=' | xargs` ; \ + if [ ! "$$USE_PREDEFINED_BUSYBOX_CONFIG" = "true" ] ; then \ + echo "Removing predefined BusyBox config file." ; \ + rm -rf minimal_overlay/busybox.config ; \ + else \ + echo "Local BusyBox config file is preserved." ; \ + fi ; \ + echo "Removing source level overlay software." ; \ + mv -f minimal_overlay/rootfs/README /tmp/mll_overlay_readme ; \ + cd minimal_overlay/rootfs ; \ + rm -rf * ; \ + cd ../.. ; \ + mv -f /tmp/mll_overlay_readme minimal_overlay/rootfs/README ; \ + echo "Removing build log file." ; \ + rm -f minimal_linux_live.log ; \ + USE_LOCAL_SOURCE=`grep -i ^USE_LOCAL_SOURCE= .config | cut -f2- -d'=' | xargs` ; \ + if [ ! "$$USE_LOCAL_SOURCE" = "true" ] ; then \ + echo "Removing local source files." ; \ + rm -rf source ; \ + else \ + echo "Local sources are preserved." ; \ + fi ; \ + } qemu-bios: - @if [ ! -f ./minimal_linux_live.iso ]; then echo "ISO image 'minimal_linux_live.iso' not found."; exit 1; fi - @echo "Launching QEMU in legacy BIOS mode." - @./qemu-bios.sh + @{ \ + if [ ! -f ./minimal_linux_live.iso ] ; then \ + echo "" ; \ + echo " ERROR: ISO image 'minimal_linux_live.iso' not found." ; \ + echo "" ; \ + exit 1 ; \ + fi ; \ + echo "Launching QEMU in BIOS mode." ; \ + ./qemu-bios.sh ; \ + } qemu-uefi: - @if [ ! -f ./minimal_linux_live.iso ]; then echo "ISO image 'minimal_linux_live.iso' not found."; exit 1; fi - @echo "Launching QEMU in UEFI mode." - @./qemu-uefi.sh + @{ \ + if [ ! -f ./minimal_linux_live.iso ] ; then \ + echo "" ; \ + echo " ERROR: ISO image 'minimal_linux_live.iso' not found." ; \ + echo "" ; \ + exit 1 ; \ + fi ; \ + echo "Launching QEMU in UEFI mode." ; \ + ./qemu-uefi.sh ; \ + } src: - @echo "Generating source archive." - @rm -f minimal_linux_live_*_src.tar.xz - @cd minimal_overlay && ./overlay_build.sh mll_source 1>/dev/null && cd .. - @$(eval DATE_PARSED := $(shell LANG=en_US ; date +"%d-%b-%Y")) - @cd work/overlay_rootfs/usr/src && tar -cpf - `ls -A` | xz - > ../../../../minimal_linux_live_$(DATE_PARSED)_src.tar.xz && cd ../../../.. - @echo "Source archive is 'minimal_linux_live_$(DATE_PARSED)_src.tar.xz'." + @{ \ + echo "Generating source archive." ; \ + rm -f minimal_linux_live_*_src.tar.xz ; \ + cd minimal_overlay ; \ + ./overlay_build.sh mll_source 1>/dev/null ; \ + cd .. ; \ + cp work/overlay/mll_source/*.tar.xz . ; \ + echo "Source archive is '`ls minimal_linux_live_*_src.tar.xz`'." ; \ + } + +release: src + @{ \ + rm -rf /tmp/mll_release ; \ + mkdir -p /tmp/mll_release ; \ + cp minimal_linux_live_*_src.tar.xz /tmp/mll_release ; \ + cd /tmp/mll_release && tar -xf minimal_linux_live_*_src.tar.xz ; \ + cd /tmp/mll_release/minimal_linux_live_*/ ; \ + echo "Launching the main build script." ; \ + /usr/bin/time -f "\n Elapsed time: %E" ./build_minimal_linux_live.sh 2>&1 | tee minimal_linux_live.log ; \ + echo "" ; \ + echo " Check the directory '/tmp/mll_release'." ; \ + echo "" ; \ + } + +test: + @{ \ + echo "" ; \ + echo " This target is reserved for local tests." ; \ + echo "" ; \ + } help: - @echo "" - @echo " make all - clean the workspace and then generate 'minimal_linux_live.iso'." - @echo "" - @echo " make clean - remove all generated files." - @echo "" - @echo " make src - generate 'tar.xz' source archive." - @echo "" - @echo " make qemu-bios - run 'Minimal Linux Live' in QEMU with legacy BIOS compatibility." - @echo "" - @echo " make qemu-uefi - run 'Minimal Linux Live' in QEMU with UEFI compatibility." - @echo "" - @echo " make help - this is the default target." - @echo "" + @{ \ + echo "" ; \ + echo " make all - clean the workspace and then generate 'minimal_linux_live.iso'." ; \ + echo "" ; \ + echo " make clean - remove all generated files." ; \ + echo "" ; \ + echo " make help - this is the default target." ; \ + echo "" ; \ + echo " make release - generate clean source tree in '/tmp/mll_release' and build MLL there." ; \ + echo "" ; \ + echo " make src - generate 'tar.xz' source archive." ; \ + echo "" ; \ + echo " make qemu-bios - run 'Minimal Linux Live' in QEMU with legacy BIOS compatibility." ; \ + echo "" ; \ + echo " make qemu-uefi - run 'Minimal Linux Live' in QEMU with UEFI compatibility." ; \ + echo "" ; \ + } diff --git a/src/minimal_overlay/bundles/mll_source/bundle.sh b/src/minimal_overlay/bundles/mll_source/bundle.sh index 99636ba04..0d28ef834 100755 --- a/src/minimal_overlay/bundles/mll_source/bundle.sh +++ b/src/minimal_overlay/bundles/mll_source/bundle.sh @@ -42,6 +42,28 @@ cp -r --remove-destination $DEST_DIR/* \ cp -r --remove-destination $DEST_DIR/* \ $OVERLAY_ROOTFS +# Prepare the 'tar.xz' source archive - BEGIN. + +# Generate helper variables. +DATE_PARSED=`LANG=en_US ; date +"%d-%b-%Y"` +ARCHIVE_PREFIX=minimal_linux_live_ +ARCHIVE_DIR=${ARCHIVE_PREFIX}${DATE_PARSED} +ARCHIVE_FILE=${ARCHIVE_DIR}_src.tar.xz + +# Remove old source artifacts. +rm -rf $WORK_DIR/overlay/$BUNDLE_NAME/${ARCHIVE_PREFIX}* + +# Copy all sources to the new temporary directory. +cp -r $DEST_DIR/usr/src \ + $WORK_DIR/overlay/$BUNDLE_NAME/$ARCHIVE_DIR + +cd $WORK_DIR/overlay/$BUNDLE_NAME + +# Generate the 'tar.xz' source archive. +tar -cpf - $ARCHIVE_DIR | xz -9 - \ + > $WORK_DIR/overlay/$BUNDLE_NAME/$ARCHIVE_FILE + +# Prepare the 'tar.xz' source archive - END. echo "Bundle '$BUNDLE_NAME' has been installed."