summaryrefslogtreecommitdiff
path: root/cron-jobs
diff options
context:
space:
mode:
Diffstat (limited to 'cron-jobs')
-rwxr-xr-xcron-jobs/create-filelists50
-rwxr-xr-xcron-jobs/sourceballs33
2 files changed, 25 insertions, 58 deletions
diff --git a/cron-jobs/create-filelists b/cron-jobs/create-filelists
index a25fd1a..8c354fc 100755
--- a/cron-jobs/create-filelists
+++ b/cron-jobs/create-filelists
@@ -1,44 +1,38 @@
#!/bin/bash
-reposdir="/srv/ftp"
-targetdir="/srv/ftp"
-repos="core extra testing community community-testing"
-lock="/tmp/create-filelists.lock"
-
. "$(dirname $0)/../db-functions"
. "$(dirname $0)/../config"
-if [ -f "$lock" ]; then
- echo "Error: create-filelists already in progress."
- exit 1
-fi
+reposdir=${FTP_BASE}
+targetdir=${FTP_BASE}
+repos=(core extra testing community community-testing)
+
+script_lock
-touch "$lock" || exit 1
# location where the package DB is extracted so we know what to include
-DBDIR="$(mktemp -d /tmp/create-filelists.dbdir.XXXXXX)" || exit 1
+DBDIR="$(mktemp -d ${WORKDIR}/create-filelists.dbdir.XXXXXX)" || exit 1
# location where the old files DB is extracted to save us some work
-CACHEDIR="$(mktemp -d /tmp/create-filelists.cachedir.XXXXXX)" || exit 1
+CACHEDIR="$(mktemp -d ${WORKDIR}/create-filelists.cachedir.XXXXXX)" || exit 1
# location where the new files DB is built up and eventually zipped
-TMPDIR="$(mktemp -d /tmp/create-filelists.tmpdir.XXXXXX)" || exit 1
+MYTMPDIR="$(mktemp -d ${WORKDIR}/create-filelists.tmpdir.XXXXXX)" || exit 1
#adjust the nice level to run at a lower priority
/usr/bin/renice +10 -p $$ > /dev/null
case "${DBEXT}" in
- *.gz) TAR_OPT="z" ;;
- *.bz2) TAR_OPT="j" ;;
- *.xz) TAR_OPT="J" ;;
- *) echo "Unknown compression type for DBEXT=${DBEXT}" && exit 1 ;;
+ *.gz) TAR_OPT="z" ;;
+ *.bz2) TAR_OPT="j" ;;
+ *.xz) TAR_OPT="J" ;;
+ *) echo "Unknown compression type for DBEXT=${DBEXT}" && exit 1 ;;
esac
FILESEXT="${DBEXT//db/files}"
-for repo in $repos; do
+for repo in ${repos[@]}; do
REPO_DB_FILE="${repo}$DBEXT"
FILES_DB_FILE="${repo}$FILESEXT"
for arch in ${ARCHES[@]}; do
-# echo "Running for architecture $arch, repo $repo"
- cd "$reposdir"
+ pushd "$reposdir" >/dev/null
repodir="${repo}/os/${arch}"
cached="no"
@@ -46,7 +40,6 @@ for repo in $repos; do
# extract package db archive
if [ -f "${targetdir}/${repodir}/${REPO_DB_FILE}" ]; then
mkdir -p "${DBDIR}/${repodir}"
-# echo "extracting $REPO_DB_FILE"
bsdtar -xf "${targetdir}/${repodir}/${REPO_DB_FILE}" -C "${DBDIR}/${repodir}"
else
echo "Fail! Does the repo $repo with arch $arch even exist?"
@@ -56,7 +49,6 @@ for repo in $repos; do
# extract old file archive
if [ -f "${targetdir}/${repodir}/${FILES_DB_FILE}" ]; then
mkdir -p "${CACHEDIR}/${repodir}"
-# echo "extracting $FILES_DB_FILE"
bsdtar -xf "${targetdir}/${repodir}/${FILES_DB_FILE}" -C "${CACHEDIR}/${repodir}"
cached="yes"
fi
@@ -65,15 +57,13 @@ for repo in $repos; do
for pkg in $(ls ${DBDIR}/${repodir}); do
dbpkgdir="${DBDIR}/${repodir}/${pkg}"
cachepkgdir="${CACHEDIR}/${repodir}/${pkg}"
- tmppkgdir="${TMPDIR}/${repodir}/${pkg}"
+ tmppkgdir="${MYTMPDIR}/${repodir}/${pkg}"
mkdir -p "$tmppkgdir"
ln "${dbpkgdir}/desc" "${tmppkgdir}/desc"
ln "${dbpkgdir}/depends" "${tmppkgdir}/depends"
if [ -f "${cachepkgdir}/files" ]; then
-# echo "cache: $pkg"
ln "${cachepkgdir}/files" "${tmppkgdir}/files"
else
-# echo "not cache: $repo/$arch: $pkg"
filename=$(grep -A1 '^%FILENAME%$' "${dbpkgdir}/desc" | tail -n1)
echo '%FILES%' > "${tmppkgdir}/files"
bsdtar --exclude=.* -tf "$repodir/$filename" >> "${tmppkgdir}/files"
@@ -84,19 +74,17 @@ for repo in $repos; do
# create new file archive
if [ "$cached" == "no" ]; then
# at least one package has changed, so let's rebuild the archive
-# echo "creating ${FILES_DB_FILE}/${arch}"
pkgdir="${targetdir}/${repodir}"
mkdir -p "$pkgdir"
- cd "${TMPDIR}/${repodir}"
+ pushd "${MYTMPDIR}/${repodir}" >/dev/null
[ -f "${pkgdir}/${FILES_DB_FILE}" ] && rm "${pkgdir}/${FILES_DB_FILE}"
bsdtar --exclude=*${DBEXT//\.db/} -c${TAR_OPT}f "${pkgdir}/${FILES_DB_FILE}" *
+ popd >/dev/null
fi
+ popd >/dev/null
done
done
-cd - >/dev/null
-rm -rf "$TMPDIR" "$CACHEDIR" "$DBDIR"
-rm -f "$lock" || exit 1
-# echo 'done'
+script_unlock
# vim: set ts=4 sw=4 et ft=sh:
diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs
index 93cb842..78c3959 100755
--- a/cron-jobs/sourceballs
+++ b/cron-jobs/sourceballs
@@ -1,37 +1,16 @@
#!/bin/bash
-ftpbase="/srv/ftp"
-srcbase="/srv/ftp/sources"
-repos="core extra testing community community-testing"
-
. "$(dirname $0)/../db-functions"
. "$(dirname $0)/../config"
-LOCKFILE="/tmp/.sourceball.lock"
-
-cleanup () {
- rm -f "$LOCKFILE"
- restore_umask
- exit 0
-}
-
-ctrl_c() {
- cleanup
-}
+ftpbase="${FTP_BASE}"
+srcbase="${FTP_BASE}/sources"
+repos=(core extra testing community community-testing)
-if [ -f "$LOCKFILE" ]; then
- owner="$(/usr/bin/stat -c %U $LOCKFILE)"
- echo "error: source tarball generation is already in progress (started by $owner)"
- exit 1
-fi
-
-trap cleanup 0
-trap ctrl_c 2
+script_lock
set_umask
-/bin/touch "$LOCKFILE"
-
dirname="$(/bin/readlink -f $(/usr/bin/dirname $0))"
FAILED_PKGS=""
@@ -39,7 +18,7 @@ FAILED_PKGS=""
[ -e "$srcbase/errors.txt" ] && /bin/mv "$srcbase/errors.txt" "$srcbase/errors.txt.old"
echo "Errors occured during run:" > "$srcbase/errors.txt"
-for repo in $repos; do
+for repo in ${repos[@]}; do
for arch in ${ARCHES[@]} any; do
ftppath="$ftpbase/$repo/os/$arch"
if [ ! -d "$ftppath" ]; then
@@ -91,4 +70,4 @@ fi
$dirname/../misc-scripts/sourceballs-cleanup
-cleanup
+script_unlock