diff options
author | rhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58> | 2008-11-27 02:00:38 +0000 |
---|---|---|
committer | rhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58> | 2008-11-27 02:00:38 +0000 |
commit | 0f63f59fe31ab7f0bf31ba622c6b131921bb596d (patch) | |
tree | a92eb853ccb355edbbc7dae08b0b26b8306778e2 /trunk/lib | |
parent | 2b1c9862fefe57ac580cec2db4a76440dd79895e (diff) | |
download | simplepkg-0f63f59fe31ab7f0bf31ba622c6b131921bb596d.tar.gz simplepkg-0f63f59fe31ab7f0bf31ba622c6b131921bb596d.tar.bz2 |
lots of changes, see CHANGELOG for details
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@537 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'trunk/lib')
-rw-r--r-- | trunk/lib/common.sh | 133 |
1 files changed, 87 insertions, 46 deletions
diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh index 92b00bb..38afca8 100644 --- a/trunk/lib/common.sh +++ b/trunk/lib/common.sh @@ -18,6 +18,7 @@ BASE_CONF="/etc/simplepkg" CONF="$BASE_CONF/simplepkg.conf" +DEFAULT_CONF="$BASE_CONF/default/simplepkg.conf" JAIL_LIST="$BASE_CONF/jailist" SIMPLARET="simplaret" @@ -131,11 +132,13 @@ function remove_packages { function eval_parameter { - # usage: eval $1 parameter from $CONF + # usage: eval $1 parameter from $CONF or $DEFAULT_CONF # return the evaluated parameter if available or $2 $3 ... $n if grep -qe "^$1=" $CONF; then grep -e "^$1=" $CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | sed -e 's/ *#.*$//' + elif grep -qe "^$1=" $DEFAULT_CONF; then + grep -e "^$1=" $DEFAULT_CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | sed -e 's/ *#.*$//' else shift echo $* @@ -187,11 +190,12 @@ function eval_config { # simplepkg config file evaluation # usage: eval_config <program-name> [-u] - if [ -f "$CONF" ]; then + if [ -f "$DEFAULT_CONF" ]; then DEFAULT_ARCH="`eval_parameter DEFAULT_ARCH $(default_arch)`" DEFAULT_VERSION="`eval_parameter DEFAULT_VERSION $(default_version)`" + TMP="`eval_parameter TMP /tmp`" STORAGE="`eval_parameter STORAGE /var/simplaret/packages`" JAIL_ROOT="`eval_parameter JAIL_ROOT /vservers`" PATCHES_DIR="`eval_parameter PATCHES_DIR /var/simplaret/patches`" @@ -243,9 +247,8 @@ function eval_config { # now we place "patches" on the top of ROOT_PRIORITY ROOT_PRIORITY="patches `echo $ROOT_PRIORITY | sed -e 's/patches//'`" - else - echo $1 error: config file $CONFIG not found + echo $1 error: config file $DEFAULT_CONF not found exit 1 fi @@ -303,6 +306,22 @@ function eval_config { # arch and version functions # ----------------------------------------------- +function default_distro { + + # get distro name from /etc/slackware-version + if [ -f "$1/etc/slamd64-version" ]; then + echo Slamd64 + elif [ -f "$1/etc/bluewhite64-version" ]; then + echo Bluewhite64 + elif [ -f "$1/etc/sflack-version" ]; then + echo Sflack + elif [ -f "$1/etc/slackware-version" ]; then + cat $1/etc/slackware-version | awk '{ print $1 }' + else + echo Slackware + fi +} + function default_version { # get version from /etc/slackware-version @@ -466,7 +485,7 @@ function get_group { # subversion functions # ----------------------------------------------- -function use_svn { +function templates_under_svn { # check if svn usage is enabled @@ -509,6 +528,51 @@ function svn_check { } +function build_repo { + + # Checkout a new slackbuild working copy + # input: $1 - svn directory name + # $2 - svn address + [ $# -ne 2 ] && exit 5 + SVN_BASEDIR="`dirname $1`" + mkdir -p $SVN_BASEDIR || exit 4 + cd $SVN_BASEDIR + svn checkout $2 + cd $1 + +} + +function check_repo { + + # Verify if repository exist + # input: $1 - svn directory name + # $2 - svn address + [ $# -ne 2 ] && exit 5 + [ ! -d "$1" ] && build_repo $1 $2 + +} + +function sync_repo { + + # Synchronize repository + # input: $1 - svn directory name + # $2 - svn address + [ $# -ne 2 ] && exit 5 + cd $1 + svn update || build_repo $1 $2 + +} + +function svn_add { + + if ! svn_check $1; then + cwd="`pwd`" + cd `dirname $1` && svn add $1 + cd $cwd + fi + +} + # ----------------------------------------------- # update jail functions # ----------------------------------------------- @@ -518,7 +582,7 @@ function update_template_files { # update template files from svn # usage: update_template_files - if use_svn && [ -d "$TEMPLATE_BASE.d/.svn" ]; then + if templates_under_svn && [ -d "$TEMPLATE_BASE.d/.svn" ]; then echo Checking out last template revision from svn... cd `dirname $TEMPLATE_BASE` svn update @@ -563,7 +627,7 @@ function copy_template_files { if [ -d "$1" ]; then if [ -d "$TEMPLATE_BASE.d" ]; then echo "Copying template files to $1..." - if use_svn && [ -d "$TEMPLATE_BASE.d/.svn" ]; then + if templates_under_svn && [ -d "$TEMPLATE_BASE.d/.svn" ]; then rsync -av --exclude=.svn $TEMPLATE_BASE.d/ $1/ else rsync -av $TEMPLATE_BASE.d/ $1/ @@ -612,6 +676,8 @@ function gen_filelist { xargs -0r ls -ldL --time-style=long-iso > FILELIST.TXT echo "Created new FILELIST.TXT" + svn_add FILELIST.TXT + } function gen_patches_filelist { @@ -623,8 +689,12 @@ function gen_patches_filelist { cwd="`pwd`" cd $1 + find . -type f -name '*.tgz' -follow -print | sort | tr '\n' '\0' | \ xargs -0r ls -ldL --time-style=long-iso > FILE_LIST + + svn_add FILE_LIST + cd $cwd if [ "$1" == "." ]; then @@ -650,6 +720,10 @@ function gen_packages_txt { 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 + cd $cwd if [ "$1" == "." ]; then @@ -675,6 +749,10 @@ function gen_md5_checksums { 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 $cwd if [ "$1" == "." ]; then @@ -730,6 +808,8 @@ function gen_meta { echo "" >> $LOCATION/$METAFILE + svn_add $LOCATION/$METAFILE + } # ----------------------------------------------- @@ -866,45 +946,6 @@ function handle_error { } # ----------------------------------------------- -# svn functions -# ----------------------------------------------- - -function build_repo { - - # Checkout a new slackbuild working copy - # input: $1 - svn directory name - # $2 - svn address - [ $# -ne 2 ] && exit 5 - SVN_BASEDIR="`dirname $1`" - mkdir -p $SVN_BASEDIR || exit 4 - cd $SVN_BASEDIR - svn checkout $2 - cd $1 - -} - -function check_repo { - - # Verify if repository exist - # input: $1 - svn directory name - # $2 - svn address - [ $# -ne 2 ] && exit 5 - [ ! -d "$1" ] && build_repo $1 $2 - -} - -function sync_repo { - - # Synchronize repository - # input: $1 - svn directory name - # $2 - svn address - [ $# -ne 2 ] && exit 5 - cd $1 - svn update || build_repo $1 $2 - -} - -# ----------------------------------------------- # misc functions # ----------------------------------------------- |