summaryrefslogtreecommitdiffstats
path: root/scripts/bootstrap
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2019-09-02 21:55:32 +0200
committerSuren A. Chilingaryan <csa@suren.me>2019-09-02 21:55:32 +0200
commit3bcab636b4addc4ca6e083334caf68b09e097690 (patch)
tree8d7b4ff95db443bd1194c187e8d655bf05089f99 /scripts/bootstrap
parent18789b5f0b1eb648ea8e8498bc7d0350f9f946c7 (diff)
downloadgentoo-3bcab636b4addc4ca6e083334caf68b09e097690.tar.gz
gentoo-3bcab636b4addc4ca6e083334caf68b09e097690.tar.bz2
gentoo-3bcab636b4addc4ca6e083334caf68b09e097690.tar.xz
gentoo-3bcab636b4addc4ca6e083334caf68b09e097690.zip
Switch to persistent container
Diffstat (limited to 'scripts/bootstrap')
-rw-r--r--scripts/bootstrap/builder.sh24
-rw-r--r--scripts/bootstrap/builder_sleep.sh22
-rw-r--r--scripts/bootstrap/builder_sync.sh6
3 files changed, 46 insertions, 6 deletions
diff --git a/scripts/bootstrap/builder.sh b/scripts/bootstrap/builder.sh
index 89ff9d0..c16fce1 100644
--- a/scripts/bootstrap/builder.sh
+++ b/scripts/bootstrap/builder.sh
@@ -1,11 +1,23 @@
#! /bin/bash
-emerge --usepkg --buildpkg --keep-going --update --deep --with-bdeps=y --newuse @world
-status=$?
+# ENVIRONMENTAL PARAMETERS
+# REBUILD_INTERVAL (days), manual if not specified
+# REBUILD_FAILED (days), manual if not specified
-if [ $status -ne 0 ]; then
- while [ 1 ]; do
+# This is intended as permanent container
+while [ 1 ]; do
+ emerge --usepkg --buildpkg --keep-going --update --deep --with-bdeps=y --newuse @world
+ status=$?
+
+ if [ $status -eq 0 ]; then
+ echo "Emerge successful"
+ [ -n "$REBUILD_INTERVAL" ] && echo "Rebuild is scheduled in $REBUILD_INTERVAL days"
+ bash /etc/portage/scripts/bootstrap/builder_sleep.sh "$REBUILD_INTERVAL"
+ bash /etc/portage/scripts/bootstrap/builder_sync.sh
+ else
echo "Emerge crashed with error code: $status"
- sleep 21600
- done
+ [ -n "$REBUILD_FAILED" ] && echo "Automatic rebuild is scheduled in $REBUILD_FAILED days"
+ bash /etc/portage/scripts/bootstrap/builder_sleep.sh "$REBUILD_FAILED"
+ [ -n "$REBUILD_FAILED" ] && bash /etc/portage/scripts/bootstrap/builder_sync.sh
+ fi
fi
diff --git a/scripts/bootstrap/builder_sleep.sh b/scripts/bootstrap/builder_sleep.sh
new file mode 100644
index 0000000..a8f8a90
--- /dev/null
+++ b/scripts/bootstrap/builder_sleep.sh
@@ -0,0 +1,22 @@
+#! /bin/bash
+
+SLEEP_DURATION=0
+[ -n "$1" ] && SLEEP_DURATION=$(($1 * 86400))
+SLEEP_INTERVAL=${REACTION_TIME:-600}
+
+WAKE_FILE="/tmp/wake"
+SYNC_FILE="/tmp/sync"
+
+rm -f "$WAKE_FILE"
+rm -f "$SYNC_FILE"
+
+sum=0
+while [ 1 ]; do
+ sleep "$SLEEP_INTERVAL"
+
+ sum=$(($sum + $SLEEP_INTERVAL))
+ [ $SLEEP_DURATION -gt 0 -a $sum > $SLEEP_DURATION ] && break
+ [ -f "$WAKE_FILE" ] && break
+done
+
+[ -f "$SYNC_FILE" ] && bash /etc/portage/scripts/bootstrap/builder_sync.sh
diff --git a/scripts/bootstrap/builder_sync.sh b/scripts/bootstrap/builder_sync.sh
new file mode 100644
index 0000000..e7f1f66
--- /dev/null
+++ b/scripts/bootstrap/builder_sync.sh
@@ -0,0 +1,6 @@
+#! /bin/bash
+
+cd /darklin/gentoo && git pull
+cd /darklin/darklin4 && git pull
+emerge --sync && eix-sync
+emerge -1 portage