From 4039cd1c8197b9aff6cc053f0ee9ec619f7ab32a Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 16 Jan 2018 17:44:43 +0100 Subject: [PATCH] Move rootfs generation to dedicated packages Add rootfs- packages that create the skeleton system, copy the files and create the squashfs images. Old "SQUASHFS" package list is depends file of rootfs- package. This removes some of the special case code. Signed-off-by: David Oberhollenzer --- cfg/alix/PACKAGES | 1 + cfg/alix/ld-musl-i386.path | 1 - cfg/rpi3/PACKAGES | 1 + cfg/rpi3/ld-musl-arm.path | 2 - mk.sh | 27 +------------ pkg/rootfs-alix/build | 39 +++++++++++++++++++ cfg/alix/SQUASHFS => pkg/rootfs-alix/depends | 1 - pkg/rootfs-rpi3/build | 40 ++++++++++++++++++++ cfg/rpi3/SQUASHFS => pkg/rootfs-rpi3/depends | 1 - pkg/rootfs/build | 16 -------- tcpkg/musl/build | 2 - 11 files changed, 82 insertions(+), 49 deletions(-) delete mode 100644 cfg/alix/ld-musl-i386.path delete mode 100644 cfg/rpi3/ld-musl-arm.path create mode 100755 pkg/rootfs-alix/build rename cfg/alix/SQUASHFS => pkg/rootfs-alix/depends (94%) create mode 100755 pkg/rootfs-rpi3/build rename cfg/rpi3/SQUASHFS => pkg/rootfs-rpi3/depends (95%) delete mode 100755 pkg/rootfs/build diff --git a/cfg/alix/PACKAGES b/cfg/alix/PACKAGES index baa767f..73a53db 100644 --- a/cfg/alix/PACKAGES +++ b/cfg/alix/PACKAGES @@ -1,3 +1,4 @@ +rootfs-alix bbstatic initrd linux diff --git a/cfg/alix/ld-musl-i386.path b/cfg/alix/ld-musl-i386.path deleted file mode 100644 index 502167f..0000000 --- a/cfg/alix/ld-musl-i386.path +++ /dev/null @@ -1 +0,0 @@ -/lib diff --git a/cfg/rpi3/PACKAGES b/cfg/rpi3/PACKAGES index 13c861c..21d4a5c 100644 --- a/cfg/rpi3/PACKAGES +++ b/cfg/rpi3/PACKAGES @@ -1,2 +1,3 @@ +rootfs-rpi3 linux-rpi3 boot-rpi3 diff --git a/cfg/rpi3/ld-musl-arm.path b/cfg/rpi3/ld-musl-arm.path deleted file mode 100644 index a2afec8..0000000 --- a/cfg/rpi3/ld-musl-arm.path +++ /dev/null @@ -1,2 +0,0 @@ -/lib -/opt/vc/lib diff --git a/mk.sh b/mk.sh index 88da627..3fe371e 100755 --- a/mk.sh +++ b/mk.sh @@ -24,7 +24,6 @@ PKGDOWNLOADDIR="$BUILDROOT/download" PACKAGELIST="$BUILDROOT/$CFG/pkglist" SQFS="$BUILDROOT/$CFG/rootfs.img" -SQFS_DIR="$BUILDROOT/$CFG/squashfs" mkdir -p "$PKGDOWNLOADDIR" "$PKGSRCDIR" "$PKGBUILDDIR" "$PKGLOGDIR" mkdir -p "$PKGDEPLOYDIR" "$TCDIR/bin" @@ -73,8 +72,7 @@ save_toolchain ############################### build packages ############################### echo "--- resolving package dependencies ---" -cat "$SCRIPTDIR/cfg/$CFG/PACKAGES" "$SCRIPTDIR/cfg/$CFG/SQUASHFS" | \ - sort -u > "$BUILDROOT/$CFG/rawpkg" +cat "$SCRIPTDIR/cfg/$CFG/PACKAGES" | sort -u > "$BUILDROOT/$CFG/rawpkg" dependencies "$BUILDROOT/$CFG/rawpkg" "$PACKAGELIST" "pkg" cat "$PACKAGELIST" @@ -96,29 +94,6 @@ while read pkg; do restore_toolchain done < "$PACKAGELIST" -############################### squashfs image ############################### - -echo "--- building squashfs ---" - -cat "$SCRIPTDIR/cfg/$CFG/SQUASHFS" | sort -u > "$BUILDROOT/$CFG/rawpkg" -dependencies "$BUILDROOT/$CFG/rawpkg" "$PACKAGELIST" "pkg" -echo "toolchain" >> "$PACKAGELIST" - -mkdir -p "$SQFS_DIR" - -while read pkg; do - if [ -e "$PKGDEPLOYDIR/$pkg" ]; then - cp -ru --remove-destination ${PKGDEPLOYDIR}/${pkg}/* "$SQFS_DIR" - echo "$pkg" - fi -done < "$PACKAGELIST" - -if [ -f "$SQFS" ]; then - rm "$SQFS" -fi - -mksquashfs "$SQFS_DIR" "$SQFS" -all-root -no-progress -no-xattrs 2>&1 > "$PKGLOGDIR/rootfs.log" - ############################## release package ############################### echo "--- building release package ---" diff --git a/pkg/rootfs-alix/build b/pkg/rootfs-alix/build new file mode 100755 index 0000000..466161d --- /dev/null +++ b/pkg/rootfs-alix/build @@ -0,0 +1,39 @@ +prepare() { + return +} + +build() { + local SOURCE="$1" + local BUILD="$2" + local DEPLOY="$3" + + # setup skeleton + mkdir -pv ${BUILD}/{bin,etc,dev,sys,proc,tmp,var,run} + + echo "/lib" > "$BUILD/etc/ld-musl-i386.path" + + # install packages to rootfs + cat "$SCRIPTDIR/pkg/rootfs-alix/depends" | sort -u > "$BUILD/rawpkg" + + dependencies "$BUILD/rawpkg" "$BUILD/etc/packages" "pkg" + echo "toolchain" >> "$BUILD/etc/packages" + rm -f "$BUILD/rawpkg" + + while read pkgname; do + if [ ! -e "$PKGDEPLOYDIR/$pkgname" ]; then + continue + fi + + cp -ru --remove-destination ${PKGDEPLOYDIR}/${pkgname}/* "$BUILD" + done < "$BUILD/etc/packages" +} + +deploy() { + local SOURCE="$1" + local BUILD="$2" + local DEPLOY="$3" + + rm -f "$SQFS" + + mksquashfs "$BUILD" "$SQFS" -all-root -no-progress -no-xattrs +} diff --git a/cfg/alix/SQUASHFS b/pkg/rootfs-alix/depends similarity index 94% rename from cfg/alix/SQUASHFS rename to pkg/rootfs-alix/depends index 8b02f3b..c95edbb 100644 --- a/cfg/alix/SQUASHFS +++ b/pkg/rootfs-alix/depends @@ -1,6 +1,5 @@ coreutils bash -rootfs nano util-linux grep diff --git a/pkg/rootfs-rpi3/build b/pkg/rootfs-rpi3/build new file mode 100755 index 0000000..f236308 --- /dev/null +++ b/pkg/rootfs-rpi3/build @@ -0,0 +1,40 @@ +prepare() { + return +} + +build() { + local SOURCE="$1" + local BUILD="$2" + local DEPLOY="$3" + + # setup skeleton + mkdir -pv ${BUILD}/{bin,etc,dev,sys,proc,tmp,var,run} + + echo "/lib" > "$BUILD/etc/ld-musl-arm.path" + echo "/opt/vc/lib" >> "$BUILD/etc/ld-musl-arm.path" + + # install packages to rootfs + cat "$SCRIPTDIR/pkg/rootfs-rpi3/depends" | sort -u > "$BUILD/rawpkg" + + dependencies "$BUILD/rawpkg" "$BUILD/etc/packages" "pkg" + echo "toolchain" >> "$BUILD/etc/packages" + rm -f "$BUILD/rawpkg" + + while read pkgname; do + if [ ! -e "$PKGDEPLOYDIR/$pkgname" ]; then + continue + fi + + cp -ru --remove-destination ${PKGDEPLOYDIR}/${pkgname}/* "$BUILD" + done < "$BUILD/etc/packages" +} + +deploy() { + local SOURCE="$1" + local BUILD="$2" + local DEPLOY="$3" + + rm -f "$SQFS" + + mksquashfs "$BUILD" "$SQFS" -all-root -no-progress -no-xattrs +} diff --git a/cfg/rpi3/SQUASHFS b/pkg/rootfs-rpi3/depends similarity index 95% rename from cfg/rpi3/SQUASHFS rename to pkg/rootfs-rpi3/depends index ab1a6e3..85b0218 100644 --- a/cfg/rpi3/SQUASHFS +++ b/pkg/rootfs-rpi3/depends @@ -1,6 +1,5 @@ coreutils bash -rootfs linux_modules firmware-rpi3 nano diff --git a/pkg/rootfs/build b/pkg/rootfs/build deleted file mode 100755 index 83bbb91..0000000 --- a/pkg/rootfs/build +++ /dev/null @@ -1,16 +0,0 @@ -prepare() { - return -} - -build() { - return -} - -deploy() { - local SOURCE="$1" - local BUILD="$2" - local DEPLOY="$3" - - mkdir -p "$DEPLOY/dev" "$DEPLOY/sys" "$DEPLOY/proc" - mkdir -p "$DEPLOY/tmp" "$DEPLOY/var" "$DEPLOY/run" -} diff --git a/tcpkg/musl/build b/tcpkg/musl/build index 8e5346b..622435f 100755 --- a/tcpkg/musl/build +++ b/tcpkg/musl/build @@ -26,6 +26,4 @@ deploy() { rm $DEPLOY/lib/*.a $DEPLOY/lib/*.o mkdir -p "$DEPLOY/etc" - - cp ${SCRIPTDIR}/cfg/${CFG}/ld-musl-* "$DEPLOY/etc/" }