From 511759504993c858d977b649cd02cf7969811b57 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Wed, 7 May 2008 02:06:21 -0400 Subject: Moving some files around, organizational Signed-off-by: Aaron Griffin --- cleanup-scripts/cleanup2.sh | 46 -------- cron-jobs/cleanup2.sh | 46 ++++++++ cron-jobs/ftpdir-cleanup | 60 ++++++++++ cron-jobs/genpkglist | 74 ++++++++++++ ftpdir-cleanup | 60 ---------- genpkglist | 74 ------------ updatesync-many | 268 -------------------------------------------- 7 files changed, 180 insertions(+), 448 deletions(-) delete mode 100755 cleanup-scripts/cleanup2.sh create mode 100755 cron-jobs/cleanup2.sh create mode 100755 cron-jobs/ftpdir-cleanup create mode 100755 cron-jobs/genpkglist delete mode 100755 ftpdir-cleanup delete mode 100755 genpkglist delete mode 100755 updatesync-many diff --git a/cleanup-scripts/cleanup2.sh b/cleanup-scripts/cleanup2.sh deleted file mode 100755 index 4a79654..0000000 --- a/cleanup-scripts/cleanup2.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -usage() { - echo "Usage: $0 repo architecture" -} - -getpkgname() { - local tmp - - tmp=${1##*/} - tmp=${tmp%.pkg.tar.gz} - tmp=${tmp%-i686} - tmp=${tmp%-x86_64} - echo ${tmp%-*-*} -} - -FTPBASEDIR="/home/ftp" -FTPDIR=${FTPBASEDIR}/${1}/os/${2} -DBFILE=${FTPDIR}/${1}.db.tar.gz -OBSOLETEFILES="" - -if [ $# -lt 2 -o ! -f ${DBFILE} ]; then - usage - exit 1 -fi - -TMPDIR=$(mktemp -d /tmp/cleanup.XXXXXX) || exit 1 -cd ${TMPDIR} -tar xzf ${DBFILE} - -cd ${FTPDIR} -for pkgfile in *.pkg.tar.gz; do - pkgname="$(getpkgname ${pkgfile})" - for p in ${FTPDIR}/${pkgname}-*; do - if [ "$(getpkgname $(basename ${p}))" = "${pkgname}" ]; then - continue 2 - fi - done - OBSOLETEFILES="${OBSOLETEFILES} ${pkgfile}" -done - -cd - >/dev/null -rm -rf ${TMPDIR} - -echo -ne "DIRECTORY:\n${FTPDIR}\n\n" -echo -ne "OBSOLETEFILES:\n${OBSOLETEFILES}\n\n" diff --git a/cron-jobs/cleanup2.sh b/cron-jobs/cleanup2.sh new file mode 100755 index 0000000..4a79654 --- /dev/null +++ b/cron-jobs/cleanup2.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +usage() { + echo "Usage: $0 repo architecture" +} + +getpkgname() { + local tmp + + tmp=${1##*/} + tmp=${tmp%.pkg.tar.gz} + tmp=${tmp%-i686} + tmp=${tmp%-x86_64} + echo ${tmp%-*-*} +} + +FTPBASEDIR="/home/ftp" +FTPDIR=${FTPBASEDIR}/${1}/os/${2} +DBFILE=${FTPDIR}/${1}.db.tar.gz +OBSOLETEFILES="" + +if [ $# -lt 2 -o ! -f ${DBFILE} ]; then + usage + exit 1 +fi + +TMPDIR=$(mktemp -d /tmp/cleanup.XXXXXX) || exit 1 +cd ${TMPDIR} +tar xzf ${DBFILE} + +cd ${FTPDIR} +for pkgfile in *.pkg.tar.gz; do + pkgname="$(getpkgname ${pkgfile})" + for p in ${FTPDIR}/${pkgname}-*; do + if [ "$(getpkgname $(basename ${p}))" = "${pkgname}" ]; then + continue 2 + fi + done + OBSOLETEFILES="${OBSOLETEFILES} ${pkgfile}" +done + +cd - >/dev/null +rm -rf ${TMPDIR} + +echo -ne "DIRECTORY:\n${FTPDIR}\n\n" +echo -ne "OBSOLETEFILES:\n${OBSOLETEFILES}\n\n" diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup new file mode 100755 index 0000000..18e26f2 --- /dev/null +++ b/cron-jobs/ftpdir-cleanup @@ -0,0 +1,60 @@ +#!/bin/bash + +usage() { + echo "Usage: $0 repo architecture" +} + +getpkgname() { + local tmp + + tmp=${1##*/} + tmp=${tmp%.pkg.tar.gz} + tmp=${tmp%-i686} + tmp=${tmp%-x86_64} + echo ${tmp%-*-*} +} + +reponame=$1 +arch=$2 + +FTPBASEDIR="/home/ftp" +FTPDIR=${FTPBASEDIR}/$reponame/os/$arch +DBFILE=${FTPDIR}/$reponame.db.tar.gz +MISSINGFILES="" +DELETEFILES="" + +if [ $# -lt 2 -o ! -f ${DBFILE} ]; then + usage + exit 1 +fi + +TMPDIR=$(mktemp -d /tmp/cleanup.XXXXXX) || exit 1 + +cd ${TMPDIR} +tar xzf ${DBFILE} +for pkg in *; do + filename=$(grep -A1 '^%FILENAME%$' ${pkg}/desc | tail -n1) + [ -z "${filename}" ] && filename="${pkg}.pkg.tar.gz" + if [ ! -f ${FTPDIR}/${filename} ]; then + MISSINGFILES="${MISSINGFILES} ${filename}" + else + pkgname="$(getpkgname ${filename})" + for otherfile in ${FTPDIR}/${pkgname}-*; do + otherfile="$(basename ${otherfile})" + if [ "${otherfile}" != "${filename}" -a "${pkgname}" = "$(getpkgname ${otherfile})" ]; then + DELETEFILES="${DELETEFILES} ${otherfile}" + fi + done + fi +done + +cd - >/dev/null +rm -rf ${TMPDIR} + +echo -ne "DIRECTORY:\n${FTPDIR}\n\n" +echo -ne "DELETEFILES:\n${DELETEFILES}\n\n" +echo -ne "MISSINGFILES:\n${MISSINGFILES}\n\n" + +cd ${FTPDIR} +[ -n "${DELETEFILES}" ] && mv ${DELETEFILES} /home/package-cleanup/ +cd - >/dev/null diff --git a/cron-jobs/genpkglist b/cron-jobs/genpkglist new file mode 100755 index 0000000..31b7c78 --- /dev/null +++ b/cron-jobs/genpkglist @@ -0,0 +1,74 @@ +#!/bin/bash +# +# genpkglist +# +# Generates a text package database for use with the setup script +# (also used to check for missing packages in the download directory) +# + +# Get the package name from the filename +# hackish, but should work for now +getpkgname() { + local tmp + + tmp=${1##*/} + tmp=${tmp%.pkg.tar.gz} + tmp=${tmp%-i686} + tmp=${tmp%-x86_64} + echo ${tmp%-*-*} +} + +pkgfile="$(pwd)/packages.txt" +ftppath=$1 +repotag=$2 + +rm -f $pkgfile +for package in *; do + if [ -d "$package/$repotag/" ]; then + cd "$package/$repotag/" + if [ -f PKGBUILD ]; then + . PKGBUILD + if [ -f $ftppath/$pkgname-$pkgver-$pkgrel.pkg.tar.gz ]; then + echo "$pkgname-$pkgver-$pkgrel.pkg.tar.gz" >>$pkgfile + elif [ -f $ftppath/$pkgname-$pkgver-$pkgrel-$dbarch.pkg.tar.gz ]; then + echo "$pkgname-$pkgver-$pkgrel-$dbarch.pkg.tar.gz" >>$pkgfile + else + echo "notice: Missing $pkgname-$pkgver-$pkgrel-$dbarch.pkg.tar.gz in ftp site" >&2 + fi + fi + cd .. + fi +done + +cd $ftppath +unset DUPES DUPEFILES last +for pkg in *.pkg.tar.gz; do + pkgname=$(getpkgname $pkg) + if [ "$last" = "$pkgname" ]; then + DUPES="$DUPES $pkgname" + DUPEFILES="$DUPEFILES $pkg" + fi + last=$pkgname +done + +showdupes() { + done= + for i in *.pkg.tar.gz; do + pkgname=$(getpkgname $i) + if [ "$pkgname" = "$1" ]; then + ls -l $i | awk '{print $6" "$7" "$8" "$9}' + done=1 + else + [ "$done" = "1" ] && return + fi + done +} + +if [ "$DUPES" ]; then + DUPES=$((for d in $DUPES; do echo $d; done) | sort -u) + echo "Possible Dupes for $ftppath (remove old versions)" + echo "Date Filename" + for dupe in $DUPES; do + showdupes $dupe + done +fi diff --git a/ftpdir-cleanup b/ftpdir-cleanup deleted file mode 100755 index 18e26f2..0000000 --- a/ftpdir-cleanup +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash - -usage() { - echo "Usage: $0 repo architecture" -} - -getpkgname() { - local tmp - - tmp=${1##*/} - tmp=${tmp%.pkg.tar.gz} - tmp=${tmp%-i686} - tmp=${tmp%-x86_64} - echo ${tmp%-*-*} -} - -reponame=$1 -arch=$2 - -FTPBASEDIR="/home/ftp" -FTPDIR=${FTPBASEDIR}/$reponame/os/$arch -DBFILE=${FTPDIR}/$reponame.db.tar.gz -MISSINGFILES="" -DELETEFILES="" - -if [ $# -lt 2 -o ! -f ${DBFILE} ]; then - usage - exit 1 -fi - -TMPDIR=$(mktemp -d /tmp/cleanup.XXXXXX) || exit 1 - -cd ${TMPDIR} -tar xzf ${DBFILE} -for pkg in *; do - filename=$(grep -A1 '^%FILENAME%$' ${pkg}/desc | tail -n1) - [ -z "${filename}" ] && filename="${pkg}.pkg.tar.gz" - if [ ! -f ${FTPDIR}/${filename} ]; then - MISSINGFILES="${MISSINGFILES} ${filename}" - else - pkgname="$(getpkgname ${filename})" - for otherfile in ${FTPDIR}/${pkgname}-*; do - otherfile="$(basename ${otherfile})" - if [ "${otherfile}" != "${filename}" -a "${pkgname}" = "$(getpkgname ${otherfile})" ]; then - DELETEFILES="${DELETEFILES} ${otherfile}" - fi - done - fi -done - -cd - >/dev/null -rm -rf ${TMPDIR} - -echo -ne "DIRECTORY:\n${FTPDIR}\n\n" -echo -ne "DELETEFILES:\n${DELETEFILES}\n\n" -echo -ne "MISSINGFILES:\n${MISSINGFILES}\n\n" - -cd ${FTPDIR} -[ -n "${DELETEFILES}" ] && mv ${DELETEFILES} /home/package-cleanup/ -cd - >/dev/null diff --git a/genpkglist b/genpkglist deleted file mode 100755 index 31b7c78..0000000 --- a/genpkglist +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -# -# genpkglist -# -# Generates a text package database for use with the setup script -# (also used to check for missing packages in the download directory) -# - -# Get the package name from the filename -# hackish, but should work for now -getpkgname() { - local tmp - - tmp=${1##*/} - tmp=${tmp%.pkg.tar.gz} - tmp=${tmp%-i686} - tmp=${tmp%-x86_64} - echo ${tmp%-*-*} -} - -pkgfile="$(pwd)/packages.txt" -ftppath=$1 -repotag=$2 - -rm -f $pkgfile -for package in *; do - if [ -d "$package/$repotag/" ]; then - cd "$package/$repotag/" - if [ -f PKGBUILD ]; then - . PKGBUILD - if [ -f $ftppath/$pkgname-$pkgver-$pkgrel.pkg.tar.gz ]; then - echo "$pkgname-$pkgver-$pkgrel.pkg.tar.gz" >>$pkgfile - elif [ -f $ftppath/$pkgname-$pkgver-$pkgrel-$dbarch.pkg.tar.gz ]; then - echo "$pkgname-$pkgver-$pkgrel-$dbarch.pkg.tar.gz" >>$pkgfile - else - echo "notice: Missing $pkgname-$pkgver-$pkgrel-$dbarch.pkg.tar.gz in ftp site" >&2 - fi - fi - cd .. - fi -done - -cd $ftppath -unset DUPES DUPEFILES last -for pkg in *.pkg.tar.gz; do - pkgname=$(getpkgname $pkg) - if [ "$last" = "$pkgname" ]; then - DUPES="$DUPES $pkgname" - DUPEFILES="$DUPEFILES $pkg" - fi - last=$pkgname -done - -showdupes() { - done= - for i in *.pkg.tar.gz; do - pkgname=$(getpkgname $i) - if [ "$pkgname" = "$1" ]; then - ls -l $i | awk '{print $6" "$7" "$8" "$9}' - done=1 - else - [ "$done" = "1" ] && return - fi - done -} - -if [ "$DUPES" ]; then - DUPES=$((for d in $DUPES; do echo $d; done) | sort -u) - echo "Possible Dupes for $ftppath (remove old versions)" - echo "Date Filename" - for dupe in $DUPES; do - showdupes $dupe - done -fi diff --git a/updatesync-many b/updatesync-many deleted file mode 100755 index 8060585..0000000 --- a/updatesync-many +++ /dev/null @@ -1,268 +0,0 @@ -#!/bin/bash -# -# updatesync-many -# -# Copyright (c) 2004-2006 by Jason Chu and Judd Vinet -# Contact: and -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -# USA. -# - -usage() { - echo "updatesync-many" - echo "usage: $0 " - echo - echo "This should probably only be run from the Arch db-generation scripts" - echo - echo "Caveats:" - echo " - Make sure you run it from the staging directory" - echo " - Use absolute pathnames for dbfile and svn_checkout" - echo - exit 0 -} - -die() -{ - echo "updatesync-many: $*" >&2 - rm -rf $TMPDIR - exit 1 -} - -msg() -{ - echo "updatesync-many: $*" >&2 -} - -# Get the package name from the filename -# hackish, but should work for now -getpkgname() { - local tmp - - tmp=${1##*/} - tmp=${tmp%.pkg.tar.gz} - tmp=${tmp%-i686} - tmp=${tmp%-x86_64} - echo ${tmp%-*-*} -} - -check_option() { - local i - for i in ${options[@]}; do - local uc=`echo $i | tr [:lower:] [:upper:]` - local lc=`echo $i | tr [:upper:] [:lower:]` - if [ "$uc" = "$1" -o "$lc" = "$1" ]; then - echo $1 - return - fi - done -} - -get_md5checksum() -{ - md5line=`md5sum $1` - [ ! -z "$md5line" ] && pkgmd5sum=${md5line% *} - echo $pkgmd5sum -} - -db_write_entry() -{ - unset pkgname pkgver pkgrel pkgdesc license groups provides md5sums force - unset replaces depends conflicts backup source install build makedepends - unset options - source $1 || return 1 - cd $TMPDIR - mkdir $pkgname-$pkgver-$pkgrel || return 1 - cd $pkgname-$pkgver-$pkgrel - # desc - : >desc - echo "%FILENAME%" >>desc - echo "$2" >>desc - echo "" >>desc - echo "%NAME%" >>desc - echo "$pkgname" >>desc - echo "" >>desc - echo "%VERSION%" >>desc - echo "$pkgver-$pkgrel" >>desc - echo "" >>desc - echo "%DESC%" >>desc - echo "$pkgdesc" >>desc - echo "" >>desc - echo "%CSIZE%" >>desc - echo "$csize" >>desc - echo "" >>desc - if [ ! -z $pkgmd5sum ]; then - echo "%MD5SUM%" >>desc - echo "$pkgmd5sum" >>desc - echo "" >>desc - fi - if [ ${#groups[*]} -gt 0 ]; then - echo "%GROUPS%" >>desc - for it in "${groups[@]}"; do - echo "$it" >>desc - done - echo "" >>desc - fi - if [ ${#replaces[*]} -gt 0 ]; then - echo "%REPLACES%" >>desc - for it in "${replaces[@]}"; do - echo "$it" >>desc - done - echo "" >>desc - fi - if [ "$force" = "y" -o "$force" = "Y" -o "`check_option FORCE`" ]; then - echo "%FORCE%" >>desc - echo "" >>desc - fi - # depends - : >depends - if [ ${#depends[*]} -gt 0 ]; then - echo "%DEPENDS%" >>depends - for it in "${depends[@]}"; do - echo "$it" >>depends - done - echo "" >>depends - fi - if [ ${#conflicts[*]} -gt 0 ]; then - echo "%CONFLICTS%" >>depends - for it in "${conflicts[@]}"; do - echo "$it" >>depends - done - echo "" >>depends - fi - if [ ${#provides[*]} -gt 0 ]; then - echo "%PROVIDES%" >>depends - for it in "${provides[@]}"; do - echo "$it" >>depends - done - echo "" >>depends - fi -} - -delete_entry() -{ - # grab the pkgname - pkgname=$(getpkgname $1) - for i in *; do - if [ "${i%-*-*}" = "$pkgname" ]; then - rm -rf $i - fi - done -} - -update_entry() -{ - pkgfile=$1 - pkgname=$(getpkgname ${pkgfile}) - fullname=$(basename ${pkgfile}) - pkgpath="$SVNCO/$pkgname/repos/$REPOTAG" - - # find the matching PKGBUILD - if [ ! -d "$pkgpath" ]; then - msg "WARNING: could not find PKGBUILD for $pkgname, cannot update this entry" - return - fi - pkgbuild="${pkgpath}/PKGBUILD" - if [ ! -f $pkgbuild ]; then - msg "WARNING: could not find PKGBUILD for $fullname, cannot update this entry" - return - fi - - source $pkgbuild - if [ $? -ne 0 ]; then - msg "WARNING: PKGBUILD for $fullname has errors, cannot update this entry" - return - fi - - # all good so far - delete the old entry - cd $TMPDIR - delete_entry $pkgfile - - csize=`du -b $pkgfile | cut -f1` - pkgmd5sum=`get_md5checksum $pkgfile` - [ -z $pkgmd5sum ] && die "error generating checksum for $pkgfile" - - db_write_entry ${pkgbuild} ${fullname} || die "error writing entry for $pkgname" - cd - >/dev/null -} - -if [ ! "`type -p lsof`" ]; then - echo "ERROR: lsof is needed to run updatesync-many!" - exit 1 -fi - -if [ $# -lt 3 ]; then - usage - exit 1 -fi - -if [ "$1" = "-h" -o "$1" = "--help" ]; then - usage - exit 0 -fi - -ACTION=$1 -PKGDB=$2 -SVNCO=$3 -REPOTAG=$4 -STAGEDIR="`pwd`" -PKGDIR="`dirname $PKGDB`" -if [ "$PKGDIR" = "." ]; then - PKGDIR=$STAGEDIR -fi - -if [ "$ACTION" != "add" -a "$ACTION" != "del" ]; then - usage - exit 1 -fi - -# Prepare the sync db for modifications -TMPDIR=$(mktemp -d /tmp/updatesync-many.XXXXXXXXXX) || exit 1 -cd $TMPDIR -if [ ! -f $PKGDB ]; then - die "$PKGDB not found" -fi -msg "Unpacking db: $PKGDB" -tar zxf $PKGDB || die "error unpacking $PKGDB" - -# Process packages in the staging directory -for pkgfile in $STAGEDIR/*.pkg.tar.gz; do - # Make sure this file isn't currently in use by any processes... - # This is our cheap way of (mostly) making sure the file isn't being - # uploaded at this very time (and thus incomplete). - # Of course, if an upload failed and the scp connection terminated, then - # this check will fail us. - lsof $pkgfile &>/dev/null - [ $? -ne 1 ] && continue - - pkgname=$(getpkgname ${pkgfile}) - if [ "$ACTION" = "del" ]; then - msg "Deleting entry: $pkgname" - delete_entry $pkgfile - else - msg "Updating entry: $pkgname" - update_entry $pkgfile - fi -done - -# Repackage the DB -msg "Repacking db: $PKGDB" -cd $TMPDIR -tar c * | gzip -9 >$PKGDB || die "error writing to $PKGDB" - -cd / -rm -rf $TMPDIR - -exit 0 -- cgit v1.2.3-24-g4f1b