summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2023-01-21 13:48:04 +0000
committerdavidovski <david@davidovski.xyz>2023-01-21 13:48:04 +0000
commit0d1cc409caa9f94ebd6334a920a992e8a8ae233e (patch)
treee7b23ddad25f3c45451bc4363ea6fe56e5c84f77
parentee1692eaf63404cadafabb407c709a2d2f5c071b (diff)
Add mirror feature
-rw-r--r--default.conf1
-rw-r--r--src/mirror.sh29
-rwxr-xr-xsrc/profile.sh2
-rwxr-xr-xsrc/sync.sh2
-rwxr-xr-xsrc/xi.sh9
5 files changed, 42 insertions, 1 deletions
diff --git a/default.conf b/default.conf
index ed5bfed..95f3bcc 100644
--- a/default.conf
+++ b/default.conf
@@ -7,6 +7,7 @@ dir {
postinstall /var/lib/xipkg/postinstall
cache /var/cache/xipkg
buildfiles /var/lib/xib/buildfiles
+ mirror /var/lib/xipkg/mirror
}
buildfiles_git https://xi.davidovski.xyz/git/buildfiles.git
diff --git a/src/mirror.sh b/src/mirror.sh
new file mode 100644
index 0000000..ea23968
--- /dev/null
+++ b/src/mirror.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+create_deps_graph () {
+ for f in $DEP_DIR/*; do
+ printf "${f#$DEP_DIR/}:"
+ local deps=""
+ [ -f "$f" ] && while read line; do
+ for dep in $line; do
+ case "$deps" in
+ *"$dep"*);;
+ *) deps="$deps $dep";;
+ esac
+ done
+ done < $f
+ printf "%s\n" "$deps"
+ done
+}
+
+mirror () {
+ local MIRROR_DIR=${1:-$MIRROR_DIR}
+ mkdir -p $MIRROR_DIR
+ create_deps_graph > $MIRROR_DIR/deps.graph
+
+ local packages=$(list)
+
+ cd $MIRROR_DIR
+ fetch $packages
+ cd -
+}
diff --git a/src/profile.sh b/src/profile.sh
index 6eb3bbf..3f402fe 100755
--- a/src/profile.sh
+++ b/src/profile.sh
@@ -31,4 +31,6 @@ export LOG_FILE="/var/log/xipkg.log"
export BUILDFILES_DIR=$(parseconf -v dir.buildfiles)
export BUILDFILES_GIT=$(parseconf -v buildfiles_git)
+export MIRROR_DIR=$(parseconf -v dir.mirror)
+
[ ! -f ${LOG_FILE} ] && mkdir -p /var/log && touch ${LOG_FILE}
diff --git a/src/sync.sh b/src/sync.sh
index 2df7b64..0be6c83 100755
--- a/src/sync.sh
+++ b/src/sync.sh
@@ -114,7 +114,7 @@ index_repo () {
list_source $src
completed=$((completed+1))
done
- ${QUIET} || hbar -l $1 ${HBAR_COMPLETE} -T "${CHECKMARK} synced sources" $completed $total
+ ${QUIET} || hbar -l $l ${HBAR_COMPLETE} -T "${CHECKMARK} synced sources" $completed $total
}
sync () {
diff --git a/src/xi.sh b/src/xi.sh
index adf7c1c..03c049e 100755
--- a/src/xi.sh
+++ b/src/xi.sh
@@ -13,6 +13,8 @@
#include remove.sh
#include stats.sh
#include bootstrap.sh
+#include mirror.sh
+
#>echo "VERSION=$(git describe --always)"
usage () {
@@ -82,6 +84,9 @@ ${BLUE}Available Commands:
${LIGHT_GREEN}bootstrap ${LIGHT_BLUE}[additional packages...]
${LIGHT_CYAN}installs base packages and system files to an empty system
+ ${LIGHT_GREEN}mirror [path]
+ ${LIGHT_CYAN}create a repository mirror [default_path: /var/lib/xipkg/mirror]
+
${LIGHT_GREEN}help
${LIGHT_CYAN}shows this message${RESET}
@@ -223,6 +228,10 @@ else
shift
info $@
;;
+ "mirror")
+ shift
+ mirror $@
+ ;;
"verify")
shift
[ -z "$*" ] && set -- $(ls ${SYSROOT}${INSTALLED_DIR})