summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2017-01-20 17:33:52 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2017-01-20 17:33:52 -0500
commitd04091d80cc0c30423ce9a792533be682833e07c (patch)
tree17f312a59896781de5b894a9b9cea27a61917f5f
parent45633afa194774b40bcc3dc6b1219d3d84e2acbf (diff)
db-import-archlinux-src: Better tmp file management.
-rwxr-xr-xdb-import-archlinux-src23
1 files changed, 15 insertions, 8 deletions
diff --git a/db-import-archlinux-src b/db-import-archlinux-src
index b529f77..6571e87 100755
--- a/db-import-archlinux-src
+++ b/db-import-archlinux-src
@@ -8,7 +8,6 @@ ABSGIT=/srv/git/abslibre/abslibre.git
# Remote
# ABSGIT=http://projects.parabolagnulinux.org/abslibre.git
SYNCARGS='-mrtv --no-motd --delete-after --no-p --no-o --no-g --quiet'
-BLFILE=/tmp/blacklist.txt
# Variables from abs.conf
ABSROOT="/srv/abs/"
@@ -51,8 +50,8 @@ function get_blacklist() {
function sync_abs_libre() {
# Clone ABSLibre git repo
- rm -rf /tmp/abslibre
- git clone "$ABSGIT" /tmp/abslibre
+ rm -rf -- "$tmpdir/abslibre"
+ git clone "$ABSGIT" "$tmpdir/abslibre"
# Sync from ABS and then sync from ABSLibre
printf ":: Syncing ABSLibre...\t"
@@ -61,7 +60,7 @@ function sync_abs_libre() {
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/ /tmp/abslibre/ ${ABSLIBRE}/${ARCH}/; then
+ if ! rsync -v -mrtq --no-motd --no-p --no-o --no-g --quiet --exclude=.git/ "$tmpdir/abslibre/" ${ABSLIBRE}/${ARCH}/; then
printf "[FAILED]\n"
return 1
fi
@@ -92,7 +91,15 @@ create_tarballs() {
done
}
-sync_abs
-get_blacklist
-sync_abs_libre
-create_tarballs
+main() {
+ trap 'rm -rf -- "$tmpdir"' EXIT
+ tmpdir=$(mktemp --tmpdir -d "${0##*/}.XXXXXXXXXX")
+
+ BLFILE=${tmpdir}/blacklist.txt
+ sync_abs
+ get_blacklist
+ sync_abs_libre
+ create_tarballs
+}
+
+main "$@"