diff --git a/mk.sh b/mk.sh index 6ee2814..4cfbeb7 100755 --- a/mk.sh +++ b/mk.sh @@ -44,13 +44,15 @@ source "$SCRIPTDIR/util/cmake.sh" ############################## build toolchain ############################### echo "--- resolving toolchain dependencies ---" -dependencies "toolchain" "tcpkg" > "$PACKAGELIST" +include_pkg "tcpkg" "toolchain" +dependencies | tsort | tac > "$PACKAGELIST" cat "$PACKAGELIST" echo "--- downloading toolchain files ---" while read pkg; do - fetch_package "tcpkg" "$pkg" + include_pkg "tcpkg" "$pkg" + fetch_package done < "$PACKAGELIST" echo "--- building toolchain ---" @@ -58,8 +60,9 @@ echo "--- building toolchain ---" gen_cmake_toolchain_file while read pkg; do - run_tcpkg_command "$pkg" "build" - run_tcpkg_command "$pkg" "deploy" + include_pkg "tcpkg" "$pkg" + run_tcpkg_command "build" + run_tcpkg_command "deploy" done < "$PACKAGELIST" echo "--- backing up toolchain sysroot ---" @@ -69,22 +72,26 @@ save_toolchain ############################### build packages ############################### echo "--- resolving package dependencies ---" -dependencies "release-${CFG}" "pkg" > "$PACKAGELIST" +include_pkg "pkg" "release-${CFG}" +dependencies | tsort | tac > "$PACKAGELIST" cat "$PACKAGELIST" echo "--- downloading package files ---" while read pkg; do - fetch_package "pkg" "$pkg" + include_pkg "pkg" "$pkg" + fetch_package done < "$PACKAGELIST" echo "--- building package ---" while read pkg; do - install_build_deps "$pkg" + include_pkg "pkg" "$pkg" - run_pkg_command "$pkg" "build" - run_pkg_command "$pkg" "deploy" + install_build_deps + + run_pkg_command "build" + run_pkg_command "deploy" restore_toolchain done < "$PACKAGELIST" diff --git a/pkg/rootfs/build b/pkg/rootfs/build index ec2f102..2979419 100755 --- a/pkg/rootfs/build +++ b/pkg/rootfs/build @@ -17,7 +17,7 @@ build() { fi # install packages to rootfs - dependencies "rootfs" "pkg" | grep -v "rootfs" > "$BUILD/etc/packages" + dependencies | tsort | tac | grep -v "$PKGNAME" > "$BUILD/etc/packages" echo "toolchain" >> "$BUILD/etc/packages" while read pkgname; do diff --git a/util/depends.sh b/util/depends.sh index f6bd13c..caf1160 100755 --- a/util/depends.sh +++ b/util/depends.sh @@ -1,27 +1,23 @@ -dependencies_recursive() { - local NAME="$1" - local PKGDIR="$2" +include_pkg() { + PKGDIR="$1" # globally visible package directory + PKGNAME="$2" # globally visible package name unset -f build deploy prepare unset -v VERSION TARBALL URL SRCDIR SHA256SUM DEPENDS - source "$SCRIPTDIR/$PKGDIR/$NAME/build" + source "$SCRIPTDIR/$PKGDIR/$PKGNAME/build" +} +dependencies() { local depends="$DEPENDS" if [ ! -z "$depends" ]; then for DEP in $depends; do - echo "$NAME $DEP" + echo "$PKGNAME $DEP" done for DEP in $depends; do - dependencies_recursive "$DEP" "$PKGDIR" + include_pkg "$PKGDIR" "$DEP" + dependencies done fi } - -dependencies() { - local NAME="$1" - local PKGDIR="$2" - - dependencies_recursive "$NAME" "$PKGDIR" | tsort | tac -} diff --git a/util/download.sh b/util/download.sh index 408e26c..22efd52 100755 --- a/util/download.sh +++ b/util/download.sh @@ -1,11 +1,5 @@ fetch_package() { - local PKGDIR="$1" - local NAME="$2" - echo "$NAME" - - unset -f build deploy prepare - unset -v VERSION TARBALL URL SRCDIR SHA256SUM DEPENDS - source "$SCRIPTDIR/$PKGDIR/$NAME/build" + echo "$PKGNAME - download" if [ -z "$TARBALL" ]; then return @@ -23,14 +17,14 @@ fetch_package() { popd > /dev/null if [ ! -e "$PKGSRCDIR/$SRCDIR" ]; then - local LOGFILE="$PKGLOGDIR/${NAME}-prepare.log" + local LOGFILE="$PKGLOGDIR/${PKGNAME}-prepare.log" - echo "unpacking..." + echo "$PKGNAME - unpack" tar -C "$PKGSRCDIR" -xf "$PKGDOWNLOADDIR/$TARBALL" pushd "$PKGSRCDIR/$SRCDIR" > /dev/null - echo "preparing..." - prepare "$SCRIPTDIR/$PKGDIR/$NAME" &>> "$LOGFILE" < /dev/null + echo "$PKGNAME - prepare" + prepare "$SCRIPTDIR/$PKGDIR/$PKGNAME" &>> "$LOGFILE" < /dev/null popd > /dev/null fi } diff --git a/util/pkgcmd.sh b/util/pkgcmd.sh index 6ea3ecf..abf051b 100644 --- a/util/pkgcmd.sh +++ b/util/pkgcmd.sh @@ -1,22 +1,16 @@ run_pkg_command_common() { - local NAME="$1" - local FUNCTION="$2" - local PKGDIR="$3" - local DEPLOYDIR="$PKGDEPLOYDIR/$4" - local OUT="$PKGBUILDDIR/$5" - local CHECKFILE="$PKGLOGDIR/.${6}-${FUNCTION}" + local FUNCTION="$1" + local DEPLOYDIR="$PKGDEPLOYDIR/$2" + local OUT="$PKGBUILDDIR/$3" + local CHECKFILE="$PKGLOGDIR/.${4}-${FUNCTION}" - echo "$NAME - $FUNCTION" + echo "$PKGNAME - $FUNCTION" if [ -e "$CHECKFILE" ]; then return fi - unset -f build deploy prepare - unset -v VERSION TARBALL URL SRCDIR SHA256SUM DEPENDS - source "$SCRIPTDIR/$PKGDIR/$NAME/build" - - local LOGFILE="$PKGLOGDIR/${7}-${FUNCTION}.log" + local LOGFILE="$PKGLOGDIR/${5}-${FUNCTION}.log" local SRC="$PKGSRCDIR/$SRCDIR" mkdir -p "$DEPLOYDIR" "$OUT" "${DEPLOYDIR}-dev" @@ -33,9 +27,9 @@ run_pkg_command_common() { } run_pkg_command() { - run_pkg_command_common "$1" "$2" "pkg" "$1" "$1" "$1" "$1" + run_pkg_command_common "$1" "$PKGNAME" "$PKGNAME" "$PKGNAME" "$PKGNAME" } run_tcpkg_command() { - run_pkg_command_common "$1" "$2" "tcpkg" "toolchain" "tc-$1" "tc-$1" "tc-$1" + run_pkg_command_common "$1" "toolchain" "tc-$PKGNAME" "tc-$PKGNAME" "tc-$PKGNAME" } diff --git a/util/toolchain.sh b/util/toolchain.sh index 5e63f64..dee0d32 100644 --- a/util/toolchain.sh +++ b/util/toolchain.sh @@ -14,12 +14,6 @@ restore_toolchain() { } install_build_deps() { - local NAME="$1" - - unset -f build deploy prepare - unset -v VERSION TARBALL URL SRCDIR SHA256SUM DEPENDS - source "$SCRIPTDIR/pkg/$NAME/build" - if [ -z "$DEPENDS" ]; then return fi