summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-01-30 22:30:25 +0000
committerdavidovski <david@davidovski.xyz>2022-01-30 22:30:25 +0000
commitd1cdb90006b966f41b84ef7cf17ea2e87a4c7378 (patch)
tree2c1b1186ce81c6e120c0701ea66e3a61f54bffde /src
parenta5ab5c46c5b031fc46c05fbe5f7bb5f2a3945dad (diff)
tidied output of the build system
Diffstat (limited to 'src')
-rwxr-xr-xsrc/build.sh37
-rwxr-xr-xsrc/build_package.sh84
-rwxr-xr-xsrc/prepare_environment.sh2
3 files changed, 81 insertions, 42 deletions
diff --git a/src/build.sh b/src/build.sh
index b39e392..3073c3c 100755
--- a/src/build.sh
+++ b/src/build.sh
@@ -11,23 +11,30 @@ source prepare_environment.sh
build_all () {
for line in $(perl build_order.pm); do
name=$(echo $line | cut -d"+" -f1)
- buildfile=$(find $XIB_BUILDFILES -wholename "*/$name.xibuild" | head -1 | xargs realpath)
-
- printf $INFO
- printf "Building %s...$RESET" $name
- ./build_package.sh $buildfile && printf "$PASS passed\n" || return 1
-
- # Install the package if it is needed for other builds
- if echo $line | grep -q '+'; then
- exported_pkg=$(find $XIB_EXPORT -wholename "*/$name.xipkg" | head -1 | xargs realpath)
- if [ -f $exported_pkg ]; then
- cd $XIB_CHROOT
- tar -xf $exported_pkg
- cd $OLDPWD
- printf "$INFO\tInstalled %s$RESET\n" $name
+ buildfile=$(find $XIB_BUILDFILES -wholename "*/$name.xibuild" | head -1)
+
+ if [ -f "$buildfile" ]; then
+ printf $INFO
+ printf "Building$NEUTRAL %s$INFO:\n$RESET" $name
+ ./build_package.sh $buildfile || return 1
+
+ # Install the package if it is needed for other builds
+ if echo $line | grep -q '+'; then
+ printf "$INFO\tInstalling..."
+ exported_pkg=$(find $XIB_EXPORT -wholename "*/$name.xipkg" | head -1 | xargs realpath)
+ if [ -f $exported_pkg ]; then
+ tar -h --no-overwrite-dir -xf $exported_pkg -C $XIB_CHROOT
+ fi
+
+ printf "$PASS installed to chroot!\n"
fi
+
+ printf $RESET
+ printf "Finished building %s!\n" $name
+ else
+ printf "$ERROR$name does not exist\n"
fi
- done;
+ done
}
diff --git a/src/build_package.sh b/src/build_package.sh
index 29f4d78..7ad5919 100755
--- a/src/build_package.sh
+++ b/src/build_package.sh
@@ -1,5 +1,8 @@
#!/bin/bash
+GREEN="\033[0;32m"
+BLUE="\033[0;34m"
+
BUILDFILE=$1
REPO=$(echo $BUILDFILE | rev | cut -d/ -f2 | rev)
NAME=$(basename $BUILDFILE .xibuild)
@@ -43,31 +46,44 @@ package_exists () {
}
fetch_source () {
+ # download additional files
local src_dir="$XIB_CHROOT/build/source"
mkdir -p $src_dir
cd $src_dir
- if git ls-remote -q $SOURCE $BRANCH &> /dev/null; then
- # The source is a git repo
- git clone $SOURCE .
- git checkout $BRANCH
- else
- # The source is a file
-
- local downloaded_file=$(basename $SOURCE)
- curl -SsL $SOURCE > $downloaded_file
- extract $downloaded_file
-
- # if the extracted file only had one directory
- if [ "$(ls -l | wc -l)" = "3" ]; then
- for file in */*; do
- mv $file .
- done;
+ if [ ! -z ${SOURCE} ]; then
+
+ if git ls-remote -q $SOURCE $BRANCH &> /dev/null; then
+ # The source is a git repo
+ git clone $SOURCE .
+ git checkout $BRANCH
+ else
+ # The source is a file
+
+ local downloaded_file=$(basename $SOURCE)
+ curl -SsL $SOURCE > $downloaded_file
+ extract $downloaded_file
+
+ # if the extracted file only had one directory
+ if [ "$(ls -l | wc -l)" = "3" ]; then
+ for file in */* */.*; do
+ echo $file | grep -q '\.$' || mv $file .
+ done;
+ fi
fi
fi
+
+ # download additional files
+ if [ ! -z ${ADDITIONAL} ]; then
+ for url in ${ADDITIONAL[*]}; do
+ local name=$(basename $url)
+ curl -Ssl $url > $src_dir/$name
+ done
+ fi
}
+
clean_chroot () {
local export_dir="$XIB_CHROOT/export"
local build_dir="$XIB_CHROOT/build"
@@ -112,9 +128,13 @@ ls
source $PKG_NAME.xibuild
cd /build/source
+echo "==========================PREPARE STAGE=========================="
prepare || exit 1
+echo "==========================BUILD STAGE=========================="
build || exit 1
+echo "==========================CHECK STAGE=========================="
check
+echo "==========================PACKAGE STAGE=========================="
package || exit 1
if command -v postinstall > /dev/null; then
@@ -137,8 +157,8 @@ package () {
cd "$pkg_dest"
if [ "$(ls -1 | wc -l)" = "0" ]; then
- echo "package is empty"
- exit 1;
+ printf " package is empty;"
+ [ -z "${SOURCE}"] || exit 1;
fi
tar -C $pkg_dest -czf $export_pkg ./
}
@@ -167,27 +187,37 @@ sign () {
}
build () {
- clean_chroot
- fetch_source
- make_buildscript
+ printf "$BLUE\tCleaning chroot..."
+ clean_chroot && printf "$GREEN prepared\n" || return 1
+
+ printf "$BLUE\tfetching source..."
+ fetch_source && printf "$GREEN fetched $(du -sh "$XIB_CHROOT/build/source" | awk '{ print $1 }')\n" || return 1
+
+ printf "$BLUE\tgenerating buildscript..."
+ make_buildscript && printf "$GREEN generated\n" || return 1
cp "$BUILDFILE" "$XIB_CHROOT/build/"
printf $NAME > "$XIB_CHROOT/build/name"
local log_file="$XIB_EXPORT/repo/$REPO/$NAME.log"
- xichroot $XIB_CHROOT /build/build.sh > $log_file 2>&1
- package
- create_info
+ printf "$BLUE\tBuilding package..."
+ xichroot $XIB_CHROOT /build/build.sh &> $log_file && printf "$GREEN built!\n" || return 1
+
+ printf "$BLUE\tPackaging package..."
+ package && printf "$GREEN packaged!\n" || return 1
+
+ printf "$BLUE\tCreating package info..."
+ create_info && printf "$GREEN created info!\n" || return 1
# TODO check if the key exists, if not, skip signing
- sign
+ printf "$BLUE\tSigning package..."
+ sign && printf "$GREEN signed!\n" || return 1
cp "$BUILDFILE" "$XIB_EXPORT/repo/$REPO/"
-
}
[ -z "${XIB_CHROOT}" ] && echo "CRITICAL! No chroot env variable set!" && exit 1;
-package_exists && printf "exists!" || build
+package_exists && printf "\tPackage exists!\n" || build
diff --git a/src/prepare_environment.sh b/src/prepare_environment.sh
index c45c895..c4cfe54 100755
--- a/src/prepare_environment.sh
+++ b/src/prepare_environment.sh
@@ -1,5 +1,7 @@
#!/bin/sh
+export MAKEFLAGS="-j12"
+
export XIB_DIR="/var/lib/xib"
export XIB_BUILDFILES="$XIB_DIR/buildfiles"
export XIB_CHROOT="$XIB_DIR/chroot"