summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/build.sh42
-rwxr-xr-xsrc/build_package.sh71
-rwxr-xr-xsrc/prepare_environment.sh5
3 files changed, 82 insertions, 36 deletions
diff --git a/src/build.sh b/src/build.sh
new file mode 100755
index 0000000..b39e392
--- /dev/null
+++ b/src/build.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+ERROR="\033[0;31m"
+INFO="\033[0;34m"
+PASS="\033[0;32m"
+NEUTRAL="\033[0;33m"
+RESET="\033[0m"
+
+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
+ fi
+ fi
+ done;
+
+}
+
+if build_all; then
+ printf "$PASSBuilt all packages!"
+else
+ printf "$ERROR Something went wrong!$NEUTRAL Press enter to view recent log"
+ read;
+
+ f=$(ls -1 --sort time $XIB_EXPORT/repo/*/*.log | head -1 | xargs realpath)
+ less $f
+fi
diff --git a/src/build_package.sh b/src/build_package.sh
index 0c37069..29f4d78 100755
--- a/src/build_package.sh
+++ b/src/build_package.sh
@@ -44,28 +44,28 @@ package_exists () {
fetch_source () {
local src_dir="$XIB_CHROOT/build/source"
- mkdir -pv $src_dir
-
- pushd $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;
- fi
+ 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;
fi
- popd
+ fi
}
clean_chroot () {
@@ -75,16 +75,19 @@ clean_chroot () {
rm -rf $export_dir
rm -rf $build_dir
- mkdir -pv $export_dir
- mkdir -pv $build_dir
+ mkdir -p $export_dir
+ mkdir -p $build_dir
- mkdir -pv "$XIB_EXPORT/repo/$REPO/"
+ mkdir -p "$XIB_EXPORT/repo/$REPO/"
}
make_buildscript () {
+
+ echo MAKEFLAGS="$MAKEFLAGS" >> "$XIB_CHROOT/build/profile"
+
cat > "$XIB_CHROOT/build/build.sh" << "EOF"
#!/bin/bash
-
+source /build/profile
export PKG_NAME=$(cat /build/name)
export PKG_DEST=/export
@@ -132,13 +135,12 @@ package () {
local export_pkg="$XIB_EXPORT/repo/$REPO/$NAME.xipkg"
local pkg_dest="$XIB_CHROOT/export"
- pushd "$pkg_dest"
- if [ "$(ls -1 | wc -l)" = "0" ]; then
- echo "package is empty"
- exit 1;
- fi
- tar -C $pkg_dest -cvzf $export_pkg ./
- popd
+ cd "$pkg_dest"
+ if [ "$(ls -1 | wc -l)" = "0" ]; then
+ echo "package is empty"
+ exit 1;
+ fi
+ tar -C $pkg_dest -czf $export_pkg ./
}
create_info () {
@@ -173,7 +175,7 @@ build () {
printf $NAME > "$XIB_CHROOT/build/name"
local log_file="$XIB_EXPORT/repo/$REPO/$NAME.log"
- xichroot $XIB_CHROOT /build/build.sh > $log_file
+ xichroot $XIB_CHROOT /build/build.sh > $log_file 2>&1
package
create_info
@@ -187,4 +189,5 @@ build () {
[ -z "${XIB_CHROOT}" ] && echo "CRITICAL! No chroot env variable set!" && exit 1;
-package_exists || build
+package_exists && printf "exists!" || build
+
diff --git a/src/prepare_environment.sh b/src/prepare_environment.sh
index 73fca98..c45c895 100755
--- a/src/prepare_environment.sh
+++ b/src/prepare_environment.sh
@@ -5,15 +5,16 @@ export XIB_BUILDFILES="$XIB_DIR/buildfiles"
export XIB_CHROOT="$XIB_DIR/chroot"
export XIB_EXPORT="$XIB_DIR/export"
-export PRIV_KEY="$HOME/.ssh/xi.pem"
+export PRIV_KEY="/home/david/.ssh/xi.pem"
export BUILDFILES_GIT_REPO="https://xi.davidovski.xyz/git/buildfiles.git"
-mkdir -pv $XIB_DIR $XIB_BUILDFILES $XIB_CHROOT $XIB_EXPORT
+mkdir -p $XIB_DIR $XIB_BUILDFILES $XIB_CHROOT $XIB_EXPORT
if [ -d $XIB_BUILDFILES/.git ]; then
cd $XIB_BUILDFILES
git pull
+ cd $OLDPWD
else
git clone $BUILDFILES_GIT_REPO $XIB_BUILDFILES
fi