diff options
author | rhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58> | 2009-08-30 20:53:15 +0000 |
---|---|---|
committer | rhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58> | 2009-08-30 20:53:15 +0000 |
commit | 632ec0d8518f1ee1b2af1eeae6a9d967dd26b16f (patch) | |
tree | e184d352ba2764561155b1ce3ab3cd343f5929e9 /trunk/lib | |
parent | 33da53d2d881d85cfdeb97910c16c71902749c58 (diff) | |
download | simplepkg-632ec0d8518f1ee1b2af1eeae6a9d967dd26b16f.tar.gz simplepkg-632ec0d8518f1ee1b2af1eeae6a9d967dd26b16f.tar.bz2 |
Attempt to fix #94 and #95
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@811 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'trunk/lib')
-rw-r--r-- | trunk/lib/common.sh | 118 |
1 files changed, 105 insertions, 13 deletions
diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh index 0f2edcd..2453099 100644 --- a/trunk/lib/common.sh +++ b/trunk/lib/common.sh @@ -29,13 +29,98 @@ SIMPLARET="simplaret" # pkgtool functions # ----------------------------------------------- +function pkg_ext { + + # list all possible package extensions + echo .tgz .tbz .tlz .txz + +} + +function pkg_ext_grep { + + # list all possible package extensions + # grep extended regexp version + + local period + + if [ "$1" == "." ]; then + $period="." + fi + + for ext in `pkg_ext`; do + exts="$exts|$period$ext" + done + echo $exts + +} + +function pkg_ext_sed { + + # list all possible package extensions + # sed regexp version + + local period + + if [ "$1" == "." ]; then + $period="." + fi + + exts="\(" + for ext in `pkg_ext`; do + exts="$exts\|$period$ext" + done + exts="\)" + echo $exts + +} + +function pkg_ext_find { + + # list all possible package extensions + # find expr version + + local match + + if [ ! -z "$1" ]; then + match="$1" + else + match="*" + fi + + exts="(" + for ext in `pkg_ext`; do + exts="$exts -or -name $match.$ext" + done + exts=")" + echo $exts + +} + +function strip_basename { + + file="$1" + shift + for ext in $*; do + file="`basename $file $ext`" + done + echo $file + +} + +function strip_pkg_ext { + + strip_basename $1 `pkg_ext` + +} + function package_name { # get the package name # in some places (like in /var/log/packages), the package name is appended with - # an -upgrade information that should be striped - basename $1 .tgz | sed -e 's/-upgraded-[0-9]*-[0-9]*-[0-9]*,[0-9]*:[0-9]*:[0-9]*$//' \ - -e 's/-[^-]*-[^-]*-[^-]*$//' + # an -upgraded information that should be striped + strip_pkg_ext $1 | \ + sed -e 's/-upgraded-[0-9]*-[0-9]*-[0-9]*,[0-9]*:[0-9]*:[0-9]*$//' \ + -e 's/-[^-]*-[^-]*-[^-]*$//' } @@ -57,7 +142,7 @@ function package_arch { # get ARCH from a package name local file pack arch - basename $1 | sed -e 's/.*\-\(.*\)\-.*.tgz$/\1/' -e 's/_slamd64$//g' -e 's/_sflack$//g' + basename $1 | sed -e "s/.*\-\(.*\)\-.*.$(pkg_ext_sed)$/\1/" -e 's/_slamd64$//g' -e 's/_sflack$//g' } @@ -65,7 +150,14 @@ function package_build { # get BUILD from a package name local file pack build - basename $1 | sed -e 's/.*\-.*\-\(.*\).tgz$/\1/' + basename $1 | sed -e "s/.*\-.*\-\(.*\).$(pkg_ext_sed)$/\1/" + +} + +function package_ext { + + # get EXT from a package name + echo $1 | sed -e "s/.*$(pkg_ext_sed)$/\1/" } @@ -1150,7 +1242,7 @@ function gen_filelist { # generate FILELIST.TXT # usage: gen_filelist - find . -type f -name '*.tgz' -follow -print | sort | tr '\n' '\0' | \ + find . -type f $(pkg_ext_find) -follow -print | sort | tr '\n' '\0' | \ xargs -0r ls -ldL --time-style=long-iso > FILELIST.TXT echo "Created new FILELIST.TXT" @@ -1172,7 +1264,7 @@ function gen_patches_filelist { cd $folder - find . -type f -name '*.tgz' -follow -print | sort | tr '\n' '\0' | \ + find . -type f $(pkg_ext_find) -follow -print | sort | tr '\n' '\0' | \ xargs -0r ls -ldL --time-style=long-iso > FILE_LIST svn_add FILE_LIST @@ -1238,7 +1330,7 @@ function gen_md5_checksums { echo 'MD5 digest for files in this directory.' > CHECKSUMS.md5 echo '' >> CHECKSUMS.md5 - find . -type f -name '*.tgz' -exec md5sum {} \; >> CHECKSUMS.md5 + find . -type f $(pkg_ext_find) -exec md5sum {} \; >> CHECKSUMS.md5 cat CHECKSUMS.md5 | gzip -9 -c - > CHECKSUMS.md5.gz svn_add CHECKSUMS.md5 @@ -1304,18 +1396,18 @@ function gen_meta { file="$1" fi - if [ "`echo $file | grep -E '(.*{1,})\-(.*[\.\-].*[\.\-].*).tgz[ ]{0,}$'`" == "" ]; then + if [ "`echo $file | grep -E "(.*{1,})\-(.*[\.\-].*[\.\-].*).$(pkg_ext_grep)[ ]{0,}$"`" == "" ]; then return fi - NAME=$(echo $file | sed -re "s/(.*\/)(.*.tgz)$/\2/") - LOCATION=$(echo $file | sed -re "s/(.*)\/(.*.tgz)$/\1/") + NAME=$(echo $file | sed -re "s/(.*\/)(.*.$(pkg_ext_sed))$/\2/") + LOCATION=$(echo $file | sed -re "s/(.*)\/(.*.$(pkg_ext_sed))$/\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 + METAFILE="$(strip_pkg_exp $NAME).meta" echo "PACKAGE NAME: $NAME" > $LOCATION/$METAFILE @@ -1336,7 +1428,7 @@ function gen_meta { echo "" >> $LOCATION/$METAFILE echo "Created metafile for `basename $file`" - ( cd `dirname $file` && svn_add `basename $file .tgz`.meta ) + ( cd `dirname $file` && svn_add `strip_pkg_exp $file`.meta ) } |