summaryrefslogtreecommitdiffstats
path: root/cron-jobs/create-filelists
diff options
context:
space:
mode:
authorAaron Griffin <aaronmgriffin@gmail.com>2009-10-30 03:18:41 +0100
committerAaron Griffin <aaronmgriffin@gmail.com>2009-10-30 03:18:41 +0100
commit38c7241ad2528b29a65a0b81b980e76d1046e94e (patch)
treed34337848fe96e25998cc68dc95b9a14828d68b8 /cron-jobs/create-filelists
parent3c1eb5b59792fbaafde12a7408201fb1e0a77df6 (diff)
downloaddbscripts-38c7241ad2528b29a65a0b81b980e76d1046e94e.tar.gz
dbscripts-38c7241ad2528b29a65a0b81b980e76d1046e94e.tar.xz
Cleanup create-filelists
* Quote absolutely everything * Move directory slashes around, for readability * Move a cd to the top of the loop Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
Diffstat (limited to 'cron-jobs/create-filelists')
-rwxr-xr-xcron-jobs/create-filelists55
1 files changed, 27 insertions, 28 deletions
diff --git a/cron-jobs/create-filelists b/cron-jobs/create-filelists
index d936853..b49f722 100755
--- a/cron-jobs/create-filelists
+++ b/cron-jobs/create-filelists
@@ -1,7 +1,7 @@
#!/bin/bash
-reposdir=/srv/ftp/
-targetdir=$reposdir
+reposdir="/srv/ftp"
+targetdir="/srv/ftp"
repos="core extra testing community"
. "$(dirname $0)/../db-functions"
@@ -13,8 +13,8 @@ if [ -f "/tmp/createFileList.lock" ]; then
fi
touch "/tmp/createFileList.lock" || exit 1
-TMPDIR=$(mktemp -d /tmp/createFileList.XXXXXX) || exit 1
-CACHEDIR=$(mktemp -d /tmp/createFileList.XXXXXX) || exit 1
+TMPDIR="$(mktemp -d /tmp/createFileList.XXXXXX)" || exit 1
+CACHEDIR="$(mktemp -d /tmp/createFileList.XXXXXX)" || exit 1
#adjust the nice level to run at a lower priority
/usr/bin/renice +10 -p $$ > /dev/null
@@ -28,33 +28,34 @@ esac
FILESEXT="${DBEXT//db/files}"
-cd $reposdir
for repo in $repos; do
- REPO_DB_FILE=${repo}$FILESEXT
+ REPO_DB_FILE="${repo}$FILESEXT"
for arch in ${ARCHES[@]}; do
- repodir=${repo}/os/${arch}/
+ cd "$reposdir"
+
+ repodir="${repo}/os/${arch}"
cached="no"
# extract old file archive
- if [ -f ${targetdir}${repodir}${REPO_DB_FILE} ]; then
- mkdir -p ${CACHEDIR}/${repodir}
- bsdtar -xf ${targetdir}${repodir}${REPO_DB_FILE} -C ${CACHEDIR}/${repodir}
+ if [ -f "${targetdir}/${repodir}/${REPO_DB_FILE}" ]; then
+ mkdir -p "${CACHEDIR}/${repodir}"
+ bsdtar -xf "${targetdir}/${repodir}/${REPO_DB_FILE}" -C "${CACHEDIR}/${repodir}"
cached="yes"
fi
# create file lists
for pkg in $repodir*${PKGEXT}; do
- basename=$(basename $pkg)
- pkgname=$(getpkgname $basename)
- tmppkgdir=${TMPDIR}/${repodir}${pkgname}/
- mkdir -p $tmppkgdir
- if [ -f "${CACHEDIR}/${repodir}${pkgname}/files" ]; then
+ basename="$(basename "$pkg")"
+ pkgname="$(getpkgname "$basename")"
+ tmppkgdir="${TMPDIR}/${repodir}/${pkgname}"
+ mkdir -p "$tmppkgdir"
+ if [ -f "${CACHEDIR}/${repodir}/${pkgname}/files" ]; then
# echo "cache: $pkgname"
- mv ${CACHEDIR}/${repodir}${pkgname}/files ${tmppkgdir}files
+ mv "${CACHEDIR}/${repodir}$/{pkgname}/files" "${tmppkgdir}/files"
else
# echo "$repo/$arch: $pkgname"
- echo '%FILES%' > ${tmppkgdir}files
- bsdtar --exclude=.* -tf $pkg >> ${tmppkgdir}files
+ echo '%FILES%' > "${tmppkgdir}/files"
+ bsdtar --exclude=.* -tf "$pkg" >> "${tmppkgdir}/files"
cached="no"
fi
done
@@ -63,20 +64,18 @@ for repo in $repos; do
if [ "$cached" == "no" ]; then
# at least one package has changed, so let's rebuild the archive
# echo "creating ${REPO_DB_FILE}/${arch}"
- pkgdir=${targetdir}${repodir}
- mkdir -p $pkgdir
- cd ${TMPDIR}/${repodir}
- [ -f "${pkgdir}${REPO_DB_FILE}.old" ] && rm "${pkgdir}${REPO_DB_FILE}.old"
- [ -f "${pkgdir}${REPO_DB_FILE}" ] && mv "${pkgdir}${REPO_DB_FILE}" "${pkgdir}${REPO_DB_FILE}.old"
- bsdtar --exclude=*${DBEXT//\.db/} -c${TAR_OPT}f ${pkgdir}${REPO_DB_FILE} *
+ pkgdir="${targetdir}/${repodir}"
+ mkdir -p "$pkgdir"
+ cd "${TMPDIR}/${repodir}"
+ [ -f "${pkgdir}/${REPO_DB_FILE}.old" ] && rm "${pkgdir}/${REPO_DB_FILE}.old"
+ [ -f "${pkgdir}/${REPO_DB_FILE}" ] && mv "${pkgdir}/${REPO_DB_FILE}" "${pkgdir}/${REPO_DB_FILE}.old"
+ bsdtar --exclude=*${DBEXT//\.db/} -c${TAR_OPT}f "${pkgdir}/${REPO_DB_FILE}" *
fi
-
- cd $reposdir
done
done
cd - >/dev/null
-rm -rf $TMPDIR || exit 1
-rm -rf $CACHEDIR || exit 1
+rm -rf "$TMPDIR" || exit 1
+rm -rf "$CACHEDIR" || exit 1
rm -f "/tmp/createFileList.lock" || exit 1
# echo 'done'