summaryrefslogtreecommitdiff
path: root/db-sync
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-12-31 15:31:33 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-12-31 15:31:33 -0500
commit9b69d5863bdf398b78ce46661dabb9abec09385e (patch)
tree8d1e504f529749f0941ced0fe44718a00972d9c0 /db-sync
parent7a49d26565b1bdbd73d946e3dca3dae7b1073572 (diff)
db-sync: use mktemp/trap
Diffstat (limited to 'db-sync')
-rwxr-xr-xdb-sync12
1 files changed, 6 insertions, 6 deletions
diff --git a/db-sync b/db-sync
index 39e72b9..0acfbc1 100755
--- a/db-sync
+++ b/db-sync
@@ -19,9 +19,11 @@
VERBOSE=${V}
${VERBOSE} && extra="-v"
+WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX")
+trap "rm -rf -- $(printf '%q' "${WORKDIR}")" EXIT
+
# Returns contents of a repo
get_repos() {
- mkdir -p ${TMPDIR}/$0.$$.cache
# Exclude everything but db files
rsync ${extra} -mrtlH --no-p --include="*/" \
--include="*.db" \
@@ -30,7 +32,7 @@ get_repos() {
--include="*${FILESEXT}" \
--exclude="*" \
--delete-after \
- rsync://${mirror}/${mirrorpath}/ ${TMPDIR}/$0.$$.cache
+ rsync://${mirror}/${mirrorpath}/ "$WORKDIR"
}
get_repo_content() {
@@ -48,7 +50,7 @@ get_blacklist() {
# repo
# arch
get_repo_file() {
- echo "${TMPDIR}/$0.$$.cache/${1}/os/${2}/${1}"
+ echo "${WORKDIR}/${1}/os/${2}/${1}"
}
# Process the databases and get the libre packages
@@ -118,7 +120,7 @@ init() {
rsync ${extra} -rtlH \
--delay-updates \
--safe-links \
- ${TMPDIR}/$0.$$.cache/${_repo}/os/${_arch}/ \
+ "${WORKDIR}/${_repo}/os/${_arch}/" \
${FTP_BASE}/${_repo}/os/${_arch}/
# Cleanup
@@ -188,5 +190,3 @@ trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR
init
-
-rm -r ${TMPDIR}/$0.$$.cache