summaryrefslogtreecommitdiff
path: root/extra/coadde/xbslibre
diff options
context:
space:
mode:
authorcoadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu>2015-08-26 03:33:26 -0300
committercoadde [Márcio Alexandre Silva Delgado] <coadde@parabola.nu>2015-08-26 03:33:26 -0300
commit8eafe04ec5eaf917d9e2d58993604c454f1a26d1 (patch)
treec0e9bb91659c3a1f5814ba94ee251639b52c5873 /extra/coadde/xbslibre
parentf17c9169de91036cd4b9bb725d2cc6713ad06ce5 (diff)
re-estructure dbscrips
Diffstat (limited to 'extra/coadde/xbslibre')
-rwxr-xr-xextra/coadde/xbslibre93
1 files changed, 93 insertions, 0 deletions
diff --git a/extra/coadde/xbslibre b/extra/coadde/xbslibre
new file mode 100755
index 0000000..e40865a
--- /dev/null
+++ b/extra/coadde/xbslibre
@@ -0,0 +1,93 @@
+#!/bin/bash
+
+set -e
+
+# Steps
+# * Sync bs derivation (abs)
+# * Download blacklist.txt
+# * Sync bs (abslibre) from bs derivation (abs) excluding from blacklist
+# * Create repo.abs.tar.gz tarballs
+
+source "$(dirname "$(readlink -e "$0")")/config_platforms"
+
+for 'platform' in "${DERIVATIVE_PLATFORMS[@]}"; do
+
+ source "$(dirname "$(readlink -e "$0")")/config_${platform}"
+
+ function sync_bs_derivation() {
+ for 'ARCH' in 'any' "${ARCHES[@]}"; do
+ rsync "${SYNC_ARGS}" "${SYNC_DERIVATION_SERVER}::${BS_DERIVATION_NAME}/${ARCH}" "${BS_DERIVATION_DIR}/${ARCH}" || return $?
+ done
+
+ # fix some permissions
+ find "${BS_DERIVATION_DIR}" -type d -print0 | xargs -0 chmod 755
+ find "${BS_DERIVATION_DIR}" -type f -print0 | xargs -0 chmod 644
+ }
+
+ function get_blacklist() {
+ printf ":: Updating blacklist...\t"
+ cat "${BLACKLIST_FILE}" | cut -d':' -f1 | sort -u | \
+ sed "s/^/**\//" > "${BLACKLIST_TMP}" || {
+ printf "[FAILED]\n"
+ return 1
+ }
+
+ # Prevent using an empty blacklist
+ [ $(wc -l "${BLACKLIST_TMP}" | cut -d " " -f1) -eq 0 ] && return 1
+
+ printf "[OK]\n"
+ }
+
+ function sync_bs() {
+
+ # Clone BS git repo
+ if [ -d "${BS_GIT_TMP}"/.git ]; then
+ pushd "${BS_GIT_TMP}" >/dev/null 2>&1
+ git pull
+ popd >/dev/null 2>&1
+ else
+ git clone "${BS_GIT}" "${BS_GIT_TMP}"
+ fi
+
+ # Sync from BS_DERIVATION and then sync from BS
+ printf ":: Syncing ${BS_MAIN_NAME}...\t"
+ (rsync "${SYNC_ARGS}" --delete-excluded \
+ --exclude-from="${BLACKLIST_TMP}" \
+ "${BS_DERIVATION_DIR}" \
+ "${BS_MAIN_DIR}" \
+ &&
+ for 'ARCH' in "${ARCHES[@]}"; do rsync -v -mrtq --no-motd --no-p --no-o --no-g --quiet --exclude=.git/ "${BS_GIT_TMP}" "${BS_MAIN_DIR}/${ARCH}/"; done) || {
+ printf "[FAILED]\n"
+ return 1
+ }
+
+ # fix some permissions
+ find "${BS_MAIN_DIR}" -type d -print0 | xargs -0 chmod 755
+ find "${BS_MAIN_DIR}" -type f -print0 | xargs -0 chmod 644
+
+ printf "[OK]\n"
+ }
+
+ # Create .abs.tar.gz tarballs
+ create_tarballs() {
+ for 'repo' in "${BS_MAIN_DIR}/${ARCHES[@]}/"*; do
+ baserepo="${repo##*/}"
+ arch="$(basename $(dirname ${repo}))"
+
+ # Remove the old one
+ mkdir -p "${REPO_DIR}/${baserepo}/os/${arch}"
+ rm -fv "${REPO_DIR}/${baserepo}/os/${arch}/${baserepo}.abs.tar.gz"
+ # Create a new one joining arch and any
+ # Remove the first part of the path (it could be $repo but any isn't hit)
+ bsdtar -czf "${REPO_DIR}/${baserepo}/os/${arch}/${baserepo}.abs.tar.gz" \
+ -s ":${BS_MAIN_DIR}/[a-z0-9_]\+/[a-z]\+::" \
+ "${repo}"/* "${BS_MAIN_DIR}/any/${baserepo}"/*
+
+ done
+ }
+
+ sync_bs_derivation
+ get_blacklist
+ sync_bs
+ create_tarballs
+done