aboutsummaryrefslogtreecommitdiff
path: root/trunk/lib/common.sh
diff options
context:
space:
mode:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2008-09-03 23:56:27 +0000
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2008-09-03 23:56:27 +0000
commit02c35be015c168aa9ad36cb328b29f23b38dd437 (patch)
tree273d47baeaffdae525b238935d1241822416fd33 /trunk/lib/common.sh
parentcb96b77a89846024572c1b7503c102fee573f458 (diff)
downloadsimplepkg-02c35be015c168aa9ad36cb328b29f23b38dd437.tar.gz
simplepkg-02c35be015c168aa9ad36cb328b29f23b38dd437.tar.bz2
merging with changes made since 21th May
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@514 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'trunk/lib/common.sh')
-rw-r--r--trunk/lib/common.sh42
1 files changed, 40 insertions, 2 deletions
diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh
index 0fe546c..06c19d7 100644
--- a/trunk/lib/common.sh
+++ b/trunk/lib/common.sh
@@ -27,7 +27,11 @@ SIMPLARET="simplaret"
function package_name {
- basename $1 .tgz | sed -e 's/-[^-]*-[^-]*-[^-]*$//'
+ # 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/-[^-]*-[^-]*-[^-]*$//'
}
@@ -77,6 +81,7 @@ function install_packages {
fi
root="$JAIL_ROOT/$server"
+ mkdir -p $root/var/log/packages
# now tries to install each package listed in the template
for pack in `cat $TEMPLATE | grep -v -e "^#" | cut -d : -f 1 | awk '{ print $1 }'`; do
@@ -521,6 +526,35 @@ function update_template_files {
}
+function update_jail_packages {
+
+ # update jail packages according the template
+ # usage: update_jail_packages <jail-path>
+
+ # check if installed packages are listed in the template
+ for pack in `ls -1 $1/var/log/packages/`; do
+ pack=`package_name $pack`
+ if ! `grep -v -e "^#" $TEMPLATE_BASE.template | cut -d : -f 1 | awk '{ print $1 }' | grep -q -e "^$pack\$"`; then
+ ROOT=$1 removepkg $pack
+ fi
+ done
+
+ # check if each package from the template is installed
+ grep -v -e "^#" $TEMPLATE_BASE.template | cut -d : -f 1 | awk '{ print $1 }' | while read pack; do
+
+ # check if the package is installed
+ pack="`echo $pack | sed -e 's/\+/\\\+/'`"
+ installed=`eval "ls /$1/var/log/packages/ | egrep -E '^$pack-[^-]+-[^-]+-[^-]+$'"`
+ check=$?
+
+ if [ -z "$installed" ] || [ "$check" != "0" ]; then
+ # the package isn't installed
+ ROOT=$1 simplaret install $pack
+ fi
+ done
+
+}
+
function copy_template_files {
# copy template files into jail
@@ -735,6 +769,7 @@ function error_codes {
ERROR_MKBUILD_CONSTRUCTION=501
ERROR_MKBUILD_PROGRAM=502
ERROR_MKBUILD_INPUT_PAR=503
+ ERROR_MKBUILD_SVN=504
# Mkpatch error codes
ERROR_MKPATCH=600
@@ -815,9 +850,11 @@ function handle_error {
eecho $error "$BASENAME: Program logical error." ;;
$ERROR_MKBUILD_INPUT_PAR)
eecho $error "$BASENAME: Input parameter $2 error. See \"mkbuild --help\"." ;;
-
$ERROR_MKPATCH)
eecho $error "$BASENAME: Mkpatch error. Check .mkbuild file." ;;
+ $ERROR_MKBUILD_SVN)
+ eecho $error "$BASENAME: SVN or empty URL. Disable this sections in .mkbuild file:\n - download_source;\n - md5sum_download_and_check_0;\n - md5sum_download_and_check_1;\n - gpg_signature_check\n - untar_source"
+ ;;
#
# Others errors
*)
@@ -953,4 +990,5 @@ function is_number {
(let int=$1) 2>/dev/null
return $? # Exit status of the let thread
fi
+
}