blob: c355e7b254fec6db2e1bc3af5c823a586820300f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#!/bin/bash
set -e
source "$(dirname "$(readlink -e "$0")")/config"
source "$(dirname "$(readlink -e "$0")")/db-import-archlinux.conf"
# Steps
# * Sync abs
# * Download blacklist.txt
# * Sync abslibre from abs excluding from blacklist
# * Create repo.abs.tar.gz tarballs
function sync_abs() {
for ARCH in any i686 x86_64; do
rsync ${SYNCARGS} ${ABS_SERVER}::abs/${ARCH}/ ${ABS_ROOT}/${ARCH} || return $?
done
# fix some permissions
find "${ABS_ROOT}" -type d -print0 | xargs -0 chmod 755
find "${ABS_ROOT}" -type f -print0 | xargs -0 chmod 644
}
function get_blacklist() {
libreblacklist update
if ! libreblacklist cat | libreblacklist get-pkg | sort -u | sed "s/^/**\//" > ${BLFILE}; then
printf "[FAILED]\n"
return 1
fi
# Prevent using an empty blacklist
[ $(wc -l ${BLFILE} | cut -d " " -f1) -eq 0 ] && return 1
printf "[OK]\n"
}
function sync_abs_libre() {
# Clone ABSLibre git repo
rm -rf -- "$tmpdir/abslibre"
git clone "$ABSLIBRE_GIT" "$tmpdir/abslibre"
# Sync from ABS and then sync from ABSLibre
printf ":: Syncing ABSLibre...\t"
if ! rsync ${SYNCARGS} --delete-excluded --exclude-from=${BLFILE} ${ABS_ROOT} ${ABSLIBRE_ROOT}; then
printf "[FAILED]\n"
return 1
fi
for ARCH in i686 x86_64; do
if ! rsync -v -mrtq --no-motd --no-p --no-o --no-g --quiet --exclude=.git/ "$tmpdir/abslibre/" ${ABSLIBRE_ROOT}/${ARCH}/; then
printf "[FAILED]\n"
return 1
fi
done
# fix some permissions
find "${ABSLIBRE_ROOT}" -type d -print0 | xargs -0 chmod 755
find "${ABSLIBRE_ROOT}" -type f -print0 | xargs -0 chmod 644
printf "[OK]\n"
}
# Create .abs.tar.gz tarballs
create_tarballs() {
for repo in ${ABSLIBRE_ROOT}/{i686,x86_64}/*; do
baserepo=${repo##*/}
arch=$(basename $(dirname $repo))
# Remove the old one
mkdir -p $FTP_BASE/$baserepo/os/$arch/
rm -fv $FTP_BASE/$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)
include=($repo/*)
if [[ -d ${ABSLIBRE_ROOT}/any/${baserepo}/ ]]; then
include+=(${ABSLIBRE_ROOT}/any/${baserepo}/*)
fi
bsdtar -czf $FTP_BASE/$baserepo/os/$arch/$baserepo.abs.tar.gz \
-s ":${ABSLIBRE_ROOT}/[a-z0-9_]\+/[a-z]\+::" \
"${include[@]}"
done
}
main() {
trap 'rm -rf -- "$tmpdir"' EXIT
tmpdir=$(mktemp --tmpdir -d "${0##*/}.XXXXXXXXXX")
BLFILE=${tmpdir}/blacklist.txt
mkdir -p -- "$ABSLIBRE_ROOT" "$ABS_ROOT"
sync_abs
get_blacklist
sync_abs_libre
create_tarballs
}
main "$@"
|