summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-05-28 19:28:06 +0100
committerdavidovski <david@davidovski.xyz>2022-05-28 19:28:06 +0100
commitbc16b2767d8ec9e8c84828df48e7eab793713003 (patch)
tree9079f7d48b136f49a10e94ea54b0851ec03df22c
parent038a56d555833d2db3af772b890a8fc8c283120e (diff)
added build command
-rw-r--r--Makefile2
-rw-r--r--default.conf2
-rw-r--r--src/build.sh93
-rwxr-xr-xsrc/get.sh4
-rw-r--r--src/install.sh2
-rwxr-xr-xsrc/profile.sh7
-rwxr-xr-xsrc/xi.sh9
-rw-r--r--xipkg.conf2
8 files changed, 115 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index c9da1b2..251d39b 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ install: install-config
mkdir -p ${DESTDIR}${PREFIX}/lib/xipkg
install -m755 ${SOURCE}/*.sh ${DESTDIR}${PREFIX}/lib/xipkg/
install -m755 ${SOURCE}/xi.sh ${DESTDIR}${PREFIX}/bin/xipkg
- ln -s xipkg ${DESTDIR}${PREFIX}/bin/xi
+ ln -sf xipkg ${DESTDIR}${PREFIX}/bin/xi
git describe --always > ${DESTDIR}${PREFIX}/lib/xipkg/VERSION
install-config:
diff --git a/default.conf b/default.conf
index aac8c60..ccfefc5 100644
--- a/default.conf
+++ b/default.conf
@@ -6,5 +6,7 @@ dir {
installed /var/lib/xipkg/installed
postinstall /var/lib/xipkg/postinstall
cache /var/cache/xipkg
+ buildfiles /var/lib/xib/buildfiles
}
+buildfiles_git https://xi.davidovski.xyz/git/buildfiles.git
diff --git a/src/build.sh b/src/build.sh
new file mode 100644
index 0000000..ed9b0ca
--- /dev/null
+++ b/src/build.sh
@@ -0,0 +1,93 @@
+#!/bin/sh
+
+get_buildfiles () {
+ ${QUIET} || printf "${BLUE}Syncing sources..."
+
+ [ -d "$BUILDFILES_DIR" ] ||
+ mkdir -p $BUILDFILES_DIR
+
+ cd $BUILDFILES_DIR
+
+ {
+ git rev-parse --git-dir &&
+ git pull ||
+ git clone $BUILDFILES_GIT .
+ } > $(${VERBOSE}&&echo "/dev/stdout" || echo "/dev/null") 2>&1 && {
+ ${QUIET} || printf "${GREEN}${CHECKMARK}\n"
+ }
+}
+
+get_deps () {
+ for f in $BUILDFILES_DIR/repo/*/$1/*.xibuild; do
+ sed -rn "s/^.*DEPS=\"(.*)\"/\1/p" $f
+ done
+}
+
+build_order () {
+ while [ "$#" != "0" ]; do
+ name=$1
+ shift
+ for dep in $(get_deps $name); do
+ set -- $@ $dep
+ echo $name $dep
+ done
+ done | tsort | reverse_lines
+}
+
+# get the revision hash of a given builddir
+#
+get_revision () {
+ cat $1/*.xibuild | sha512sum | cut -d' ' -f1
+}
+
+# return the installed revision of the given package
+#
+get_installed_revision () {
+ local infofile=${INSTALLED_DIR}/$1/info
+ [ -f $infofile ] && {
+ sed -rn "s/^REVISION=(.*)$/\1/p" $infofile
+ }
+}
+
+# test if the given package by name needs to be rebuilt
+#
+needs_build () {
+ name=$1
+ builddir=$(get_package_build $name)
+
+ [ "$(get_revision $builddir)" = "$(get_installed_revision $name)" ]
+}
+
+
+get_package_build () {
+ local buildfile=$(find $BUILDFILES_DIR/repo -name "$1.xibuild" | head -1)
+ echo ${buildfile%/*}
+}
+
+build_package () {
+ local name=$(basename $1)
+ local builddir=$(get_package_build $1)
+
+ [ -d "$builddir" ] && {
+ xibuild -ci -r ${SYSROOT} $builddir
+ } || {
+ ${QUIET} || printf "${RED}Package $1 does not exist!\n"
+ }
+}
+
+build () {
+ $DO_SYNC && get_buildfiles
+ set -- $(build_order $@)
+
+ for p in $@; do
+ needs_build $p && set -- $@ $p
+ done
+
+ printf "${LIGHT_BLUE}The following packages will be built: \n"
+ echo "\t${BLUE}$@\n"
+
+ prompt_question "${WHITE} Continue?" &&
+ for package in $@; do
+ build_package $package || return 1
+ done
+}
diff --git a/src/get.sh b/src/get.sh
index 0107897..75571ba 100755
--- a/src/get.sh
+++ b/src/get.sh
@@ -14,7 +14,7 @@ list_deps() {
# list all dependencies and sub dependencies of a package
#
resolve_deps () {
- local out="${CACHE_DIR}/deps"
+ local out="$1"; shift
local deps=""
local i=0
@@ -157,7 +157,7 @@ get () {
$DO_SYNC && sync
touch $out
- resolve_deps $@
+ resolve_deps $out $@
for package in $(cat $out); do
package_exists $package || {
diff --git a/src/install.sh b/src/install.sh
index f2f1a8c..20d582d 100644
--- a/src/install.sh
+++ b/src/install.sh
@@ -73,7 +73,7 @@ run_postinstall () {
rm $file &&
printf "${GREEN}${CHECKMARK} postinstall $f!\n"
} || {
- printf "${RED}${CROSSMARK} failed postinstall $f!\n"
+ ${QUIET} || printf "${RED}${CROSSMARK} failed postinstall $f!\n"
}
done
diff --git a/src/profile.sh b/src/profile.sh
index 0ddcc0a..683738e 100755
--- a/src/profile.sh
+++ b/src/profile.sh
@@ -1,10 +1,11 @@
#!/bin/sh
. /usr/lib/colors.sh
+. /usr/lib/glyphs.sh
+
export HBAR_COMPLETE="-c ${GREEN}${BG_DEFAULT}"
export HBAR_RED="-c ${BLACK}${BG_RED}"
-. /usr/lib/glyphs.sh
export CONF_FILE="/etc/xipkg.conf"
@@ -23,4 +24,8 @@ export PACKAGE_CACHE="${CACHE_DIR}/packages"
export SYNC_CACHE="${CACHE_DIR}/sync"
export LOG_FILE="/var/log/xipkg.log"
+
+export BUILDFILES_DIR=$(parseconf -v dir.buildfiles)
+export BUILDFILES_GIT=$(parseconf -v buildfiles_git)
+
[ ! -f ${LOG_FILE} ] && mkdir -p /var/log && touch ${LOG_FILE}
diff --git a/src/xi.sh b/src/xi.sh
index b16a36e..c241585 100755
--- a/src/xi.sh
+++ b/src/xi.sh
@@ -125,6 +125,7 @@ done
. ${LIBDIR}/query.sh
. ${LIBDIR}/sync.sh
. ${LIBDIR}/install.sh
+. ${LIBDIR}/build.sh
. ${LIBDIR}/get.sh
. ${LIBDIR}/remove.sh
@@ -156,6 +157,14 @@ else
get $tofetch
install $(cat $toinstall)
;;
+ "build")
+ shift
+ checkroot
+
+ [ "$#" = "0" ] && set -- $(list_installed)
+
+ build $@
+ ;;
"search")
shift
search $@
diff --git a/xipkg.conf b/xipkg.conf
index a6f6171..b0de8f5 100644
--- a/xipkg.conf
+++ b/xipkg.conf
@@ -7,7 +7,7 @@ include /etc/xipkg.d/default.conf
# Keep this list short, with a few local mirrors
# ensure that you have a bit of redunancy in case of back up
sources {
-# local file:///var/lib/xib/export/repo/
+# local file:///var/lib/xib/repo/
ftp https://xilinux.ftp.sh/repo/
davidovski https://xi.davidovski.xyz/repo/
}