From a15bd6db33d0432040a1075569d70c59c9402530 Mon Sep 17 00:00:00 2001 From: rhatto Date: Fri, 28 Nov 2008 14:27:36 +0000 Subject: cleanup git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@599 04377dda-e619-0410-9926-eae83683ac58 --- trunk/lib/common.sh | 139 +++++++++++++++++++++++++++------------------------- 1 file changed, 71 insertions(+), 68 deletions(-) (limited to 'trunk/lib') diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh index e34ce8e..8f78468 100644 --- a/trunk/lib/common.sh +++ b/trunk/lib/common.sh @@ -510,31 +510,25 @@ function svn_check { # check if a file is under svn # usage: svn_check - local cwd folder retval - - cwd="`pwd`" folder="`dirname $1`" file="`basename $1`" if [ -d "$folder/.svn" ]; then - cd $folder + ( + cd $folder - if [ "`svn status $file | awk '{ print $1 }'`" == "?" ]; then - retval="1" - else - retval="0" - fi + if [ "`svn status $file | awk '{ print $1 }'`" == "?" ]; then + return 1 + else + return 0 + fi + ) else - - retval="1" - + return 1 fi - cd $cwd - return $retval - } function build_repo { @@ -613,10 +607,7 @@ function svn_copy { cp $orig/$file $dest if [ -d "`dirname $dest`/.svn" ]; then chown_svn $dest && chgrp_svn $dest - cwd="`pwd`" - cd `dirname $dest` - svn_add `basename $dest` - cd $cwd + ( cd `dirname $dest` && svn_add `basename $dest` ) fi } @@ -799,15 +790,18 @@ function gen_patches_filelist { if [ ! -z "$1" ] && [ -d "$1" ]; then - cwd="`pwd`" - cd $1 + folder="$1" + + ( - find . -type f -name '*.tgz' -follow -print | sort | tr '\n' '\0' | \ - xargs -0r ls -ldL --time-style=long-iso > FILE_LIST + cd $folder - svn_add FILE_LIST + find . -type f -name '*.tgz' -follow -print | sort | tr '\n' '\0' | \ + xargs -0r ls -ldL --time-style=long-iso > FILE_LIST - cd $cwd + svn_add FILE_LIST + + ) if [ "$1" == "." ]; then echo "Created new FILE_LIST" @@ -826,17 +820,20 @@ function gen_packages_txt { if [ ! -z "$1" ] && [ -d "$1" ]; then - cwd="`pwd`" - cd $1 + folder="$1" + + ( + + cd $folder - echo '' > PACKAGES.TXT - find . -type f -name '*.meta' -exec cat {} \; >> PACKAGES.TXT - cat PACKAGES.TXT | gzip -9 -c - > PACKAGES.TXT.gz + echo '' > PACKAGES.TXT + find . -type f -name '*.meta' -exec cat {} \; >> PACKAGES.TXT + cat PACKAGES.TXT | gzip -9 -c - > PACKAGES.TXT.gz - svn_add PACKAGES.TXT - svn_add PACKAGES.TXT.gz + svn_add PACKAGES.TXT + svn_add PACKAGES.TXT.gz - cd $cwd + ) if [ "$1" == "." ]; then echo "Created new PACKAGES.TXT and PACKAGES.TXT.gz" @@ -855,18 +852,21 @@ function gen_md5_checksums { if [ -d "$1" ]; then - cwd="`pwd`" - cd $1 + folder="$1" - echo 'MD5 digest for files in this directory.' > CHECKSUMS.md5 - echo '' >> CHECKSUMS.md5 - find . -type f -name '*.tgz' -exec md5sum {} \; >> CHECKSUMS.md5 - cat CHECKSUMS.md5 | gzip -9 -c - > CHECKSUMS.md5.gz + ( - svn_add CHECKSUMS.md5 - svn_add CHECKSUMS.md5.gz + cd $folder - cd $cwd + echo 'MD5 digest for files in this directory.' > CHECKSUMS.md5 + echo '' >> CHECKSUMS.md5 + find . -type f -name '*.tgz' -exec md5sum {} \; >> CHECKSUMS.md5 + cat CHECKSUMS.md5 | gzip -9 -c - > CHECKSUMS.md5.gz + + svn_add CHECKSUMS.md5 + svn_add CHECKSUMS.md5.gz + + ) if [ "$1" == "." ]; then echo "Created new CHECKSUMS.md5 and CHECKSUMS.md5.gz" @@ -890,26 +890,27 @@ function update_md5_checksum { folder="$1" fi - cwd="`pwd`" - cd $folder + ( - if [ ! -f CHECKSUMS.md5 ]; then - gen_md5_checksums . - else - # remove the old entry and add a new one - sed -i "/ \.*\/*$(regexp_slash $file)$/d" CHECKSUMS.md5 - file="`echo $file | sed -e 's/\.*\/*//'`" # remove additional ./ - md5sum ./$file >> CHECKSUMS.md5 - fi + cd $folder + + if [ ! -f CHECKSUMS.md5 ]; then + gen_md5_checksums . + else + # remove the old entry and add a new one + sed -i "/ \.*\/*$(regexp_slash $file)$/d" CHECKSUMS.md5 + file="`echo $file | sed -e 's/\.*\/*//'`" # remove additional ./ + md5sum ./$file >> CHECKSUMS.md5 + fi - cat CHECKSUMS.md5 | gzip -9 -c - > CHECKSUMS.md5.gz + cat CHECKSUMS.md5 | gzip -9 -c - > CHECKSUMS.md5.gz - echo "Updated CHECKSUMS.md5" + echo "Updated CHECKSUMS.md5" - svn_add CHECKSUMS.md5 - svn_add CHECKSUMS.md5.gz + svn_add CHECKSUMS.md5 + svn_add CHECKSUMS.md5.gz - cd $cwd + ) } @@ -920,19 +921,21 @@ function gen_meta { if [ ! -f $1 ]; then return 1 + else + file="$1" fi - if [ "`echo $1|grep -E '(.*{1,})\-(.*[\.\-].*[\.\-].*).tgz[ ]{0,}$'`" == "" ]; then + if [ "`echo $file | grep -E '(.*{1,})\-(.*[\.\-].*[\.\-].*).tgz[ ]{0,}$'`" == "" ]; then return fi - NAME=$(echo $1 | sed -re "s/(.*\/)(.*.tgz)$/\2/") - LOCATION=$(echo $1 | sed -re "s/(.*)\/(.*.tgz)$/\1/") - SIZE=$( expr `gunzip -l $1 | tail -n 1 | awk '{print $1}'` / 1024 ) - USIZE=$( expr `gunzip -l $1 | tail -n 1 | awk '{print $2}'` / 1024 ) - REQUIRED=$(tar xzfO $1 install/slack-required 2>/dev/null | grep -v -e "^#" | xargs -r -iZ echo -n "Z," | sed -e "s/,$//") - CONFLICTS=$(tar xzfO $1 install/slack-conflicts 2>/dev/null | grep -v -e "^#" | xargs -r -iZ echo -n "Z," | sed -e "s/,$//") - SUGGESTS=$(tar xzfO $1 install/slack-suggests 2>/dev/null | grep -v -e "^#" | xargs -r ) + NAME=$(echo $file | sed -re "s/(.*\/)(.*.tgz)$/\2/") + LOCATION=$(echo $file | sed -re "s/(.*)\/(.*.tgz)$/\1/") + SIZE=$( expr `gunzip -l $file | tail -n 1 | awk '{ print $1 }'` / 1024 ) + USIZE=$( expr `gunzip -l $file | tail -n 1 | awk '{ print $2 }'` / 1024 ) + REQUIRED=$(tar xzfO $file install/slack-required 2>/dev/null | grep -v -e "^#" | xargs -r -iZ echo -n "Z," | sed -e "s/,$//") + CONFLICTS=$(tar xzfO $file install/slack-conflicts 2>/dev/null | grep -v -e "^#" | xargs -r -iZ echo -n "Z," | sed -e "s/,$//") + SUGGESTS=$(tar xzfO $file install/slack-suggests 2>/dev/null | grep -v -e "^#" | xargs -r ) METAFILE=${NAME%tgz}meta echo "PACKAGE NAME: $NAME" > $LOCATION/$METAFILE @@ -949,12 +952,12 @@ function gen_meta { echo "PACKAGE SUGGESTS: $SUGGESTS" >> $LOCATION/$METAFILE echo "PACKAGE DESCRIPTION:" >> $LOCATION/$METAFILE - tar xzfO $1 install/slack-desc | grep -E '\w+\:' | grep -v '^#' >> $LOCATION/$METAFILE + tar xzfO $file install/slack-desc | grep -E '\w+\:' | grep -v '^#' >> $LOCATION/$METAFILE echo "" >> $LOCATION/$METAFILE - echo "Created metafile for `basename $1`" + echo "Created metafile for `basename $file`" - ( cd `dirname $1` && svn_add `basename $1 .tgz`.meta ) + ( cd `dirname $file` && svn_add `basename $file .tgz`.meta ) } -- cgit v1.2.3