From 3c1eb5b59792fbaafde12a7408201fb1e0a77df6 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Thu, 29 Oct 2009 19:10:26 -0700 Subject: Rename createFileLists to be more like the others Signed-off-by: Aaron Griffin --- cron-jobs/create-filelists | 82 ++++++++++++++++++++++++++++++++++++++++++++++ cron-jobs/createFileLists | 82 ---------------------------------------------- 2 files changed, 82 insertions(+), 82 deletions(-) create mode 100755 cron-jobs/create-filelists delete mode 100755 cron-jobs/createFileLists (limited to 'cron-jobs') diff --git a/cron-jobs/create-filelists b/cron-jobs/create-filelists new file mode 100755 index 0000000..d936853 --- /dev/null +++ b/cron-jobs/create-filelists @@ -0,0 +1,82 @@ +#!/bin/bash + +reposdir=/srv/ftp/ +targetdir=$reposdir +repos="core extra testing community" + +. "$(dirname $0)/../db-functions" +. "$(dirname $0)/../config" + +if [ -f "/tmp/createFileList.lock" ]; then + echo "Error: createFileList allready in progress." + exit 1 +fi + +touch "/tmp/createFileList.lock" || 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 + +case "${DBEXT}" in + *.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}" + +cd $reposdir +for repo in $repos; do + REPO_DB_FILE=${repo}$FILESEXT + for arch in ${ARCHES[@]}; do + 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} + 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 +# echo "cache: $pkgname" + mv ${CACHEDIR}/${repodir}${pkgname}/files ${tmppkgdir}files + else +# echo "$repo/$arch: $pkgname" + echo '%FILES%' > ${tmppkgdir}files + bsdtar --exclude=.* -tf $pkg >> ${tmppkgdir}files + cached="no" + fi + done + + # create new file archive + 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} * + fi + + cd $reposdir + done +done + +cd - >/dev/null +rm -rf $TMPDIR || exit 1 +rm -rf $CACHEDIR || exit 1 +rm -f "/tmp/createFileList.lock" || exit 1 +# echo 'done' diff --git a/cron-jobs/createFileLists b/cron-jobs/createFileLists deleted file mode 100755 index d936853..0000000 --- a/cron-jobs/createFileLists +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash - -reposdir=/srv/ftp/ -targetdir=$reposdir -repos="core extra testing community" - -. "$(dirname $0)/../db-functions" -. "$(dirname $0)/../config" - -if [ -f "/tmp/createFileList.lock" ]; then - echo "Error: createFileList allready in progress." - exit 1 -fi - -touch "/tmp/createFileList.lock" || 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 - -case "${DBEXT}" in - *.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}" - -cd $reposdir -for repo in $repos; do - REPO_DB_FILE=${repo}$FILESEXT - for arch in ${ARCHES[@]}; do - 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} - 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 -# echo "cache: $pkgname" - mv ${CACHEDIR}/${repodir}${pkgname}/files ${tmppkgdir}files - else -# echo "$repo/$arch: $pkgname" - echo '%FILES%' > ${tmppkgdir}files - bsdtar --exclude=.* -tf $pkg >> ${tmppkgdir}files - cached="no" - fi - done - - # create new file archive - 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} * - fi - - cd $reposdir - done -done - -cd - >/dev/null -rm -rf $TMPDIR || exit 1 -rm -rf $CACHEDIR || exit 1 -rm -f "/tmp/createFileList.lock" || exit 1 -# echo 'done' -- cgit v1.2.3-24-g4f1b