diff options
-rw-r--r-- | xi_profile.sh | 94 | ||||
-rw-r--r-- | xibuild.sh | 64 |
2 files changed, 105 insertions, 53 deletions
diff --git a/xi_profile.sh b/xi_profile.sh index d88ed80..97047bd 100644 --- a/xi_profile.sh +++ b/xi_profile.sh @@ -1,48 +1,64 @@ #!/bin/sh -cd $1 -prepare () { - echo "passing prepare" -} +export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin:/tools/sbin +export LIBRARY_PATH=/lib:/usr/lib/:/tools/lib:/tools/lib64 -build () { - echo "passing build" -} +export JOBS=$(grep "processor" /proc/cpuinfo | wc -l) +export HOME=/root -check () { - echo "passing check" -} +export MAKEFLAGS="-j$JOBS" +export XORG_PREFIX="/usr" -package () { - echo "passing package" +export XORG_CONFIG="--prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-static" +export BUILD_ROOT="/build/source" +export RUST_TARGET="x86_64-unknown-linux-musl" + +apply_patches () { + for p in *.patch; do + echo "Applying $p" + patch -Np1 -i $p + done } -for xibuild in *.xibuild; do - PKG_NAME=$(basename $xibuild .xibuild) - export PKG_DEST=./xipkg/$PKG_NAME - mkdir -p $PKG_DEST - - . ./$xibuild - - echo "==========================PREPARE STAGE==========================" - prepare || exit 1 - echo "==========================BUILD STAGE==========================" - build || exit 1 - echo "==========================CHECK STAGE==========================" - check || exit 1 - echo "==========================PACKAGE STAGE==========================" - package || exit 1 - - printf "checking for postinstall... " - if command -v postinstall > /dev/null; then - echo "adding postinstall" - POST_DIR=$PKG_DEST/var/lib/xipkg/postinstall - mkdir -p $POST_DIR - cat /build/$PKG_NAME.xibuild > $POST_DIR/$PKG_NAME.sh - echo "" >> $POST_DIR/$PKG_NAME.sh - echo "postinstall" >> $POST_DIR/$PKG_NAME.sh - else - echo "no postinstall" - fi +PKG_NAME=$1 +cd $2 +export BUILD_ROOT=$(realpath $2) + +builds="$(ls *.xibuild | grep -v "$PKG_NAME.xibuild")" + +for xibuild in $PKG_NAME.xibuild $(ls *.xibuild | grep -v "$PKG_NAME.xibuild"); do + PKG_NAME=$(basename $xibuild .xibuild) + export PKG_DEST=./xipkg/$PKG_NAME + mkdir -p $PKG_DEST + + echo "============$PKG_NAME=============" + + # read only the static variables fromt the primary + . ./$PKG_NAME.xibuild + unset -f prepare + unset -f build + unset -f check + unset -f package + + . ./$xibuild + + + for t in prepare build check package; do + type $t >/dev/null && { + echo "==========================$t stage==========================" + $t || exit 1 + } + done + printf "checking for postinstall... " + if command -v postinstall > /dev/null; then + echo "adding postinstall" + POST_DIR=$PKG_DEST/var/lib/xipkg/postinstall + mkdir -p $POST_DIR + cat /build/$PKG_NAME.xibuild > $POST_DIR/$PKG_NAME.sh + echo "" >> $POST_DIR/$PKG_NAME.sh + echo "postinstall" >> $POST_DIR/$PKG_NAME.sh + else + echo "no postinstall" + fi done @@ -1,5 +1,7 @@ #!/bin/sh +XIPKG_INFO_VERSION='04' + [ -f /usr/lib/colors.sh ] && . /usr/lib/colors.sh [ -f /usr/lib/glyphs.sh ] && . /usr/lib/glyphs.sh @@ -74,6 +76,7 @@ xibuild_prepare () { rm -rf $root/$build_dir rm -rf $root/$export_dir mkdir -p $root/$export_dir + echo > $logfile install -Dm755 $xibuild_profile $root/$build_dir/xi_profile.sh } @@ -111,9 +114,9 @@ xibuild_fetch () { xibuild_build () { [ "$root" = "/" ] && { - $build_dir/xi_profile.sh $build_dir + $build_dir/xi_profile.sh $NAME $build_dir || return 1 } || { - xichroot "$root" $builddir/xi_profile $builddir + xichroot "$root" "$build_dir/xi_profile.sh $NAME $build_dir" || return 1 } } @@ -132,7 +135,7 @@ xibuild_package () { for pkg in $(ls -1 $export_dir); do cd $root/$export_dir/$pkg [ "$(ls -1 $root/$export_dir/$pkg| wc -l)" = "0" ] && { - echo "package $pkg is empty" + printf "${RED}package $pkg is empty\n" [ ! -z ${SOURCE} ] || exit 1 } tar -C $root/$export_dir/$pkg -czf $out_dir/$pkg.xipkg ./ @@ -140,11 +143,36 @@ xibuild_package () { } xibuild_describe () { - + for xipkg in $(ls $out_dir/*.xipkg); do + name=$(basename $xipkg .xipkg) + buildfile="$src_dir/$name.xibuild" + info_file=$xipkg.info + + . $buildfile + + local pkg_ver=$PKG_VER + [ -z "$pkg_ver" ] && pkg_ver=$BRANCH + [ -z "$pkg_ver" ] && pkg_ver="latest" + + { + echo "# XiPKG info file version $XIPKG_INFO_VERSION" + echo "# automatically generated from the built packages" + echo "NAME=$name" + echo "DESCRIPTION=$DESC" + echo "PKG_FILE=$name.xipkg" + echo "CHECKSUM=$(md5sum $xipkg | awk '{ print $1 }')" + echo "VERSION=$pkg_ver" + echo "SOURCE=$SOURCE" + echo "DATE=$(stat -t $xipkg | cut -d' ' -f13 | xargs date -d)" + echo "DEPS=${DEPS}" + echo "MAKE_DEPS=${MAKE_DEPS}" + echo "ORIGIN=$NAME" + } > $info_file + done } -while getopts ":r:c:p:b:d:qh" opt; do +while getopts ":r:c:p:b:d:vh" opt; do case "${opt}" in r) root=$(realpath ${OPTARG});; @@ -165,7 +193,7 @@ done shift $((OPTIND-1)) -tasks="prepare fetch build strip package" +tasks="prepare fetch build strip package describe" [ "$#" = "1" ] && { [ -d "$1" ] && { @@ -176,15 +204,23 @@ tasks="prepare fetch build strip package" } NAME=$(basename $(realpath "$src_dir")) -trap "{printf \"${RED}${CROSS}\n\"}" 1 -. $src_dir/$NAME.xibuild +[ -f "$src_dir/$NAME.xibuild" ] || { + printf "${RED} could not find $NAME.xibuild!\n" + exit 1 +} -printf "${BLUE}${NAME}\n" -for task in $tasks; do - printf "${BLUE}${TABCHAR}$task " +build_package () { + . $src_dir/$NAME.xibuild - xibuild_$task 2>&1 | tee -a $logfile > $textout || exit 1 + printf "${BLUE}${NAME}\n" + for task in $tasks; do + printf "${BLUE}${TABCHAR}$task " + xibuild_$task >> $logfile > $textout && printf "${GREEN}${CHECKMARK}\n" || return 1 + done +} - printf "${GREEN}${CHECKMARK}\n" -done +build_package || { + printf "${RED}${CROSSMARK} Failed\n" + exit 1 +} |