summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--xi_buildscript.sh77
-rw-r--r--xi_profile.sh93
-rw-r--r--xibuild.sh13
4 files changed, 100 insertions, 86 deletions
diff --git a/Makefile b/Makefile
index 9f9058c..af75e7a 100644
--- a/Makefile
+++ b/Makefile
@@ -2,4 +2,5 @@ PREFIX=/usr
install:
install -Dm755 xibuild.sh ${DESTDIR}${PREFIX}/bin/xibuild
- install -Dm755 xi_profile.sh ${DESTDIR}${PREFIX}/lib/xibuild/xi_profile.sh
+ install -Dm755 xi_profile.sh ${DESTDIR}/etc/xibuild_profile.conf
+ install -Dm755 xi_buildscript.sh ${DESTDIR}${PREFIX}/lib/xibuild/xi_buildscript.sh
diff --git a/xi_buildscript.sh b/xi_buildscript.sh
new file mode 100644
index 0000000..d9e19f7
--- /dev/null
+++ b/xi_buildscript.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+PKG_NAME=$1
+cd $2
+
+. ./xi_profile.sh
+
+apply_patches () {
+ for p in *.patch; do
+ echo "Applying $p"
+ patch -Np1 -i $p
+ done
+}
+
+add_from_main () {
+ for pattern in $@; do
+ printf "moving $pattern..."
+ for file in $(find ./xipkg/ -path "./xipkg/*/$pattern" ); do
+ printf "$file "
+ filename=${file#./xipkg/$PKG_NAME}
+ mkdir -p $PKG_DEST/${pattern%/*}
+ mv $file $PKG_DEST/${filename}
+ done
+ printf "\n"
+ done
+}
+
+stages="prepare build check package"
+case "$@" in
+ *"-n"*)
+ stages="prepare build package"
+esac
+
+export BUILD_ROOT=$(realpath $2)
+
+echo "Build file for $1, to build at root $2"
+
+builds="$(ls *.xibuild | grep -v "$PKG_NAME.xibuild")"
+
+for xibuild in $PKG_NAME.xibuild $(ls *.xibuild | grep -v "^$PKG_NAME.xibuild$"); do
+ cd $2
+ SUBPKG_NAME=$(basename $xibuild .xibuild)
+ mkdir -p ./xipkg/$SUBPKG_NAME
+ export PKG_DEST=$(realpath ./xipkg/$SUBPKG_NAME)
+ echo "to install to $PKG_DEST"
+
+ echo "============$SUBPKG_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 $stages; 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 ./$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
diff --git a/xi_profile.sh b/xi_profile.sh
index d85d65e..93453cd 100644
--- a/xi_profile.sh
+++ b/xi_profile.sh
@@ -1,91 +1,24 @@
-#!/bin/sh
-
-export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin:/tools/sbin
-export LIBRARY_PATH=/lib:/usr/lib/:/tools/lib:/tools/lib64
-
export CC="clang"
export CXX="clang++"
export LD="clang"
export JOBS=$(grep "processor" /proc/cpuinfo | wc -l)
+export MAKEFLAGS=-j$JOBS
+export SAMUFLAGS=-j$JOBS
+export CARGO_BUILD_JOBS=$JOBS
+
+export CFLAGS="-Os -fomit-frame-pointer"
+export CXXFLAGS="$CFLAGS"
+export CPPFLAGS="$CFLAGS"
+export LDFLAGS="-Wl,--as-needed,-O1,--sort-common"
+export GOFLAGS="-buildmode=pie"
+export DFLAGS="-Os"
export HOME=/root
-export MAKEFLAGS="-j$JOBS"
export XORG_PREFIX="/usr"
-
export XORG_CONFIG="--prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-static"
-export RUST_TARGET="x86_64-unknown-linux-musl"
-
-apply_patches () {
- for p in *.patch; do
- echo "Applying $p"
- patch -Np1 -i $p
- done
-}
-
-add_from_main () {
- for pattern in $@; do
- printf "moving $pattern..."
- for file in $(find ./xipkg/ -path "./xipkg/*/$pattern" ); do
- printf "$file "
- filename=${file#./xipkg/$PKG_NAME}
- mkdir -p $PKG_DEST/${pattern%/*}
- mv $file $PKG_DEST/${filename}
- done
- printf "\n"
- done
-}
-
-PKG_NAME=$1
-cd $2
-
-stages="prepare build check package"
-case "$@" in
- *"-n"*)
- stages="prepare build package"
-esac
-export BUILD_ROOT=$(realpath $2)
-
-echo "Build file for $1, to build at root $2"
-
-builds="$(ls *.xibuild | grep -v "$PKG_NAME.xibuild")"
-
-for xibuild in $PKG_NAME.xibuild $(ls *.xibuild | grep -v "$PKG_NAME.xibuild"); do
- cd $2
- SUBPKG_NAME=$(basename $xibuild .xibuild)
- mkdir -p ./xipkg/$SUBPKG_NAME
- export PKG_DEST=$(realpath ./xipkg/$SUBPKG_NAME)
- echo "to install to $PKG_DEST"
-
- echo "============$SUBPKG_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 $stages; do
- type $t >/dev/null && {
- echo "==========================$t stage=========================="
- $t || exit 1
- }
- done
+export RUST_TARGET="x86_64-unknown-linux-musl"
- 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 ./$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
+export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin:/tools/sbin
+export LIBRARY_PATH=/lib:/usr/lib/:/tools/lib:/tools/lib64
diff --git a/xibuild.sh b/xibuild.sh
index 15f0aa3..e26fad5 100644
--- a/xibuild.sh
+++ b/xibuild.sh
@@ -19,7 +19,8 @@ checkopt=""
root="/"
-xibuild_profile="/usr/lib/xibuild/xi_profile.sh"
+xibuild_profile="/etc/xibuild_profile.conf"
+xibuild_script="/usr/lib/xibuild/xi_buildscript.sh"
usage () {
cat << EOF
@@ -34,9 +35,9 @@ ${BLUE}Avaiable Options:
${BLUE}-b ${LIGHT_BLUE}[path]
${LIGHT_CYAN}specify the directory to build things in ${LIGHT_WHITE}[default: /var/lib/xibuild]
${BLUE}-p ${LIGHT_BLUE}[file]
- ${LIGHT_CYAN}specify a non-default xi_profile script, to run inside the chroot ${LIGHT_WHITE}[default: /usr/lib/xibuild/xi_profile.sh]
+ ${LIGHT_CYAN}specify a non-default xi_profile script, to run inside the chroot ${LIGHT_WHITE}[default: /etc/xibuild_profile.conf]
${BLUE}-k ${LIGHT_BLUE}[file]
- ${LIGHT_CYAN}specify an openssl private key to sign packages with${LIGHT_WHITE}[default: /usr/lib/xibuild/xi_profile.sh]
+ ${LIGHT_CYAN}specify an openssl private key to sign packages with${LIGHT_WHITE}
${BLUE}-v
${LIGHT_CYAN}verbose: print logs to stdout
@@ -114,13 +115,15 @@ xibuild_fetch () {
}
xibuild_build () {
+ install -d $root/$build_dir/
install -Dm755 $xibuild_profile $root/$build_dir/xi_profile.sh
+ install -Dm755 $xibuild_script $root/$build_dir/xi_buildscript.sh
mkdir -p $root/$export_dir
[ "$root" = "/" ] && {
- sh $build_dir/xi_profile.sh $NAME $build_dir $checkopt || return 1
+ sh $build_dir/xi_buildscript.sh $NAME $build_dir $checkopt || return 1
} || {
- xichroot "$root" "$build_dir/xi_profile.sh $NAME $build_dir $checkopt" || return 1
+ xichroot "$root" "$build_dir/xi_buildscript.sh $NAME $build_dir $checkopt" || return 1
} 2>&1
}