summaryrefslogtreecommitdiff
path: root/xib.sh
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-05-05 22:54:29 +0100
committerdavidovski <david@davidovski.xyz>2022-05-05 22:54:29 +0100
commitb273972f3fcbc84c9114d32646c2ae3e46dd1590 (patch)
treefc66d2c13528d9e2e5a86895c6291c30679b5723 /xib.sh
parent00ad91b7aa7266ae2ddd9b5e5264bb4cb3380b70 (diff)
removed old xibuild files with new xib.sh
Diffstat (limited to 'xib.sh')
-rw-r--r--xib.sh138
1 files changed, 114 insertions, 24 deletions
diff --git a/xib.sh b/xib.sh
index b380a75..e52d9dc 100644
--- a/xib.sh
+++ b/xib.sh
@@ -10,7 +10,9 @@ XIPKG_INSTALL=/usr/lib/xipkg/install.sh
xib_dir="/var/lib/xib"
priv_key="xi.pem"
-buildfiles="$xib_dir/buildfiles"
+#buildfiles="$xib_dir/buildfiles"
+buildfiles="/home/david/docs/proj/xilinux/buildfiles"
+seen="$xib_dir/seen"
chroot="$xib_dir/chroot"
stage="$xib_dir/stage"
local_repo="$xib_dir/repo"
@@ -19,13 +21,16 @@ keychain="$xib_dir/keychain"
# add a package to the repo's packages.list
#
publish_package () {
- local repo=$1
+ local repo=$1 name=$2
xipkgs=$(ls $stage/*.xipkg)
mv $stage/build.log $stage/$name.log
packageslist="$local_repo/$repo/packages.list"
depsgraph="$local_repo/deps.graph"
+ [ ! -d "$local_repo/$repo" ] && mkdir -p "$local_repo/$repo"
+ [ ! -f "$packageslist" ] && touch $packageslist
+ [ ! -f "$depsgraph" ] && touch $depsgraph
for xipkg in $xipkgs; do
local name=$(basename $xipkg ".xipkg")
@@ -40,43 +45,55 @@ publish_package () {
sed -i "s/^$name: //" $depsgraph
echo "$name: $deps" >> $depsgraph
- mv $stage/$xipkg $local_repo/$repo/$name.xipkg
- mv $stage/$xipkg.info $local_repo/$repo/$name.xipkg.info
- mv $stage/$name.xibuild $local_repo/$repo/$name.xibuild
- cp $stage/build.log $local_repo/$repo/$name.log
+ [ -f $stage/$name.xipkg ] && mv $stage/$name.xipkg $local_repo/$repo/$name.xipkg
+ [ -f $stage/$name.xipkg.info ] && mv $stage/$name.xipkg.info $local_repo/$repo/$name.xipkg.info
+ [ -f $stage/$name.xibuild ] && mv $stage/$name.xibuild $local_repo/$repo/$name.xibuild
+ [ -f $stage/build.log ] && cp $stage/build.log $local_repo/$repo/$name.log
+ done
+
+ [ ! -d "$seen" ] && mkdir -p $seen
+ for s in $stage/*.xibsum; do
+ s=$(basename $s)
+ mv $stage/$s $seen/$s
done
}
# get root package from package name
#
get_package_build () {
- local name=$1
- local buildfile=$(find $buildfiles/repo -name "$name.xibuild" | head -1)
- local name="$(realpath $buildfile | rev | cut -d'/' -f2 | rev)"
- local repo="$(realpath $buildfile | rev | cut -d'/' -f3 | rev)"
+ local buildfile=$(find $buildfiles/repo -name "$1.xibuild" | head -1)
+ echo ${buildfile%/*}
+}
- echo $buildfiles/repo/$repo/$name
+list_all () {
+ for repo in $(ls -1 $buildfiles/repo); do
+ for name in $(ls -1 $buildfiles/repo/$repo); do
+ echo "$repo/$name"
+ done
+ done
}
# get package file from package name
#
get_package_file () {
- local name=$1
- local pkgfile=$(find $local_repo/ -name "$name.xipkg" | head -1)
- echo $pkgfile
+ find $local_repo/ -name "$1.xipkg" | head -1
}
-# Use xibuild to build a singular package
+# Use xibuild to build a singular package, input is packagebuild dir
#
build_package () {
- local package=$(get_package_build $1)
+ local name=$(basename $1)
+
rm -rf $stage
mkdir -p $stage
- xibuild -k $keychain/$priv_key -c $package -d $stage -r $chroot
+ xibuild -v -k $keychain/$priv_key -c $1 -d $stage -r $chroot || return 1
+ get_buildfiles_hash $1 > $stage/$name.xibsum
}
+
package_install () {
local name=$1
local xipkg=$(get_package_file $1)
+
INSTALLED_DIR="$chroot/var/lib/xipkg/installed/"
SYSROOT=$chroot
VERBOSE=false
@@ -88,12 +105,12 @@ package_install () {
# get the direct dependencies of a single package
#
get_deps () {
- package=$(get_package_build $1)
- [ -d $package ] && {
+ local package=$(get_package_build $1)
+ [ -d $package ] &&
for buildfile in $package/*.xibuild; do
sed -rn "s/^.*DEPS=\"(.*)\"/\1/p" $buildfile
- done
- }
+ done | tr '\n' ' '
+
}
list_deps () {
@@ -114,13 +131,86 @@ list_deps () {
echo "$deps"
}
+get_buildfiles_hash () {
+ cat $1/*.xibuild | sha512sum | cut -d' ' -f1
+}
+
xib_single () {
local name=$1
- local deps=$(list_deps $name)
+ local deps=$(get_deps $name)
+ missing=""
for dep in $deps; do
- [ -e "$chroot/var/lib/xipkg/installed/$name" ] || {
- install_package $(get_package_file $name) $name
+ [ -e "$chroot/var/lib/xipkg/installed/$dep" ] || {
+ pkgfile=$(get_package_file $dep)
+ [ "${#pkgfile}" = "0" ] && missing="$missing $dep"
+ printf "${LIGHT_GREEN}+${LIGHT_CYAN}install $dep"
+ install_package $(get_package_file $dep) $dep
+ }
+ done
+
+ [ "${#missing}" != "0" ] && {
+ printf "${RED}This package requires the following to be installed in order to build: ${LIGHT_RED}$missing\n"
+ return 1
+ }
+
+ package=$(get_package_build $name)
+ repo=$(echo "$package" | rev | cut -f2 -d'/' | rev)
+ build_package $package || return 1
+ publish_package $repo $name
+}
+
+xib_all () {
+ for name in $(build_order); do
+ # TODO CHECK IF the package is already built
+
+ package=$(get_package_build $name)
+ [ "${#package}" != 0 ] && [ -d "$package" ] && {
+ xibsum=$(get_buildfiles_hash $package)
+ [ -f "$seen/$name.xibsum" ] && [ "$(cat "$seen/$name.xibsum")" = "$xibsum" ] && {
+ printf "${BLUE}$name${LIGHT_BLUE}...already built!\n"
+ } || {
+ xib_single $name || return 1
+ }
+ } || {
+ printf "${RED} could not find package for $name in $package $RESET\n"
+ return 1
}
done
}
+reverse_lines () {
+ local result=
+ while IFS= read -r line; do
+ result="$line
+ $result"
+ done
+ echo "$result"
+}
+
+build_order () {
+ for pkg in $(list_all); do
+ set -- $(echo $pkg | tr '/' ' ')
+ repo=$1
+ name=$2
+ [ "$repo" != "meta" ] &&
+ for dep in $(get_deps $name); do
+ echo $name $dep
+ done
+ done | tsort | reverse_lines
+}
+
+xibd () {
+ cd $buildfiles
+ git pull
+ cd $xib_dir
+ xib_all
+}
+
+[ "$#" = 0 ] && {
+ xib_all
+} || {
+ for x in $@; do
+ xib_single $x
+ done
+}
+