Skip to content

Commit

Permalink
Makefile,makerootfs.sh: implement LIVE_FAST=1 option for make live
Browse files Browse the repository at this point in the history
The LIVE_FAST=1 uses the recent '--input-tar' parameter for the linuxkit
tool, which helps to generate the tarball faster by copying content which
was not changed since the previous invocation.

Time measurements for the separate makerootfs.sh call:

  ./tools/makerootfs.sh tar -u -y rootfs-kvm-generic.yml -t rootfs.tar -d installer -a amd64

before
------
real    0m48.262s
user    0m50.457s
sys     0m2.226s

with the LIVE_FAST=1
--------------------
real    0m8.240s
user    0m7.287s
sys     0m2.529s

For now this feature considered as experimental, so no documentation
or usage is included in makefile. Hopefully we can make this mode as
default.

Signed-off-by: Roman Penyaev <[email protected]>
  • Loading branch information
rouming committed May 7, 2024
1 parent e25d870 commit 7832e62
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,19 @@ DOCKER_GO = _() { $(SET_X); mkdir -p $(CURDIR)/.go/src/$${3:-dummy} ; mkdir -p $

PARSE_PKGS=$(if $(strip $(EVE_HASH)),EVE_HASH=)$(EVE_HASH) DOCKER_ARCH_TAG=$(DOCKER_ARCH_TAG) KERNEL_TAG=$(KERNEL_TAG) ./tools/parse-pkgs.sh
LINUXKIT=$(BUILDTOOLS_BIN)/linuxkit
LINUXKIT_VERSION=3a0405298aab1632524a6ccd074969b417e1ee92
LINUXKIT_VERSION=e6b0ae05eb3a2b99e84d9ffc03a3a5c9c3e7e371
LINUXKIT_SOURCE=https://github.com/linuxkit/linuxkit.git
LINUXKIT_OPTS=$(if $(strip $(EVE_HASH)),--hash) $(EVE_HASH) $(if $(strip $(EVE_REL)),--release) $(EVE_REL)
LINUXKIT_PKG_TARGET=build
LINUXKIT_PATCHES_DIR=tools/linuxkit/patches

ifdef LIVE_FAST
# Check the makerootfs.sh and the linuxkit tool invocation, the --input-tar
# parameter specifically. This will create a new tar based on the old one
# (already generated), which speeds tar generation up a bit.
UPDATE_TAR=-u
endif

RESCAN_DEPS=FORCE
# set FORCE_BUILD to --force to enforce rebuild
FORCE_BUILD=
Expand Down Expand Up @@ -643,7 +651,7 @@ $(ROOTFS)-%.img: $(ROOTFS_IMG)

$(ROOTFS_TAR): images/out/rootfs-$(HV)-$(PLATFORM).yml | $(INSTALLER)
$(QUIET): $@: Begin
./tools/makerootfs.sh tar -y $< -t $@ -d $(INSTALLER) -a $(ZARCH)
./tools/makerootfs.sh tar $(UPDATE_TAR) -y $< -t $@ -d $(INSTALLER) -a $(ZARCH)
$(QUIET): $@: Succeeded
ifdef KERNEL_IMAGE
# Consider this as a cry from the heart: enormous amount of time is
Expand Down
27 changes: 22 additions & 5 deletions tools/makerootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,23 @@ do_tar() {
if [ -n "$arch" ]; then
ARCHARG="--arch ${arch}"
fi
# sbom disabled for now; will be re-enabled later
# shellcheck disable=SC2086
linuxkit build --no-sbom --docker ${ARCHARG} --o "${tarfile}" "$ymlfile"
if [ -z "$updatetar" ] || [ ! -e "${tarfile}" ]; then
# sbom disabled for now; will be re-enabled later
# shellcheck disable=SC2086
linuxkit build --no-sbom --docker ${ARCHARG} --o "${tarfile}" "$ymlfile"
else
# sbom disabled for now; will be re-enabled later
# shellcheck disable=SC2086
linuxkit build --no-sbom --docker ${ARCHARG} --o "${tarfile}.new" --input-tar "${tarfile}" "$ymlfile"
newmd5=$(md5sum "${tarfile}.new" | awk '{print $1}')
oldmd5=$(md5sum "${tarfile}" | awk '{print $1}')
# Don't touch the modification time if files are equal. Crucial for Makefile.
if [ "$newmd5" != "$oldmd5" ]; then
mv "${tarfile}.new" "${tarfile}"
else
rm "${tarfile}.new"
fi
fi
}

# mode 2 - generate image from tarfile
Expand Down Expand Up @@ -113,8 +127,8 @@ help() {
mode="$1"
shift

unset tarfile imgfile arch format ymlfile execidr
while getopts "t:i:a:f:y:d:h" o
unset tarfile imgfile arch format ymlfile execidr updatetar
while getopts "t:i:a:f:y:d:uh" o
do
case $o in
t)
Expand All @@ -135,6 +149,9 @@ do
d)
execdir=$(abspath "$OPTARG")
;;
u)
updatetar=1
;;
h)
help
;;
Expand Down

0 comments on commit 7832e62

Please sign in to comment.