aboutsummaryrefslogtreecommitdiff
path: root/tags/0.5/src
diff options
context:
space:
mode:
Diffstat (limited to 'tags/0.5/src')
-rw-r--r--tags/0.5/src/createpkg501
-rwxr-xr-xtags/0.5/src/jail-commit175
-rwxr-xr-xtags/0.5/src/jail-update61
-rwxr-xr-xtags/0.5/src/lspkg132
-rwxr-xr-xtags/0.5/src/mkbuild680
-rwxr-xr-xtags/0.5/src/mkjail113
-rwxr-xr-xtags/0.5/src/rebuildpkg87
-rwxr-xr-xtags/0.5/src/repos87
-rwxr-xr-xtags/0.5/src/simplaret1131
-rwxr-xr-xtags/0.5/src/templatepkg980
10 files changed, 0 insertions, 3947 deletions
diff --git a/tags/0.5/src/createpkg b/tags/0.5/src/createpkg
deleted file mode 100644
index a80b033..0000000
--- a/tags/0.5/src/createpkg
+++ /dev/null
@@ -1,501 +0,0 @@
-#!/bin/bash
-#
-# createpkg: package builder using http://slack.sarava.org/slackbuilds scripts
-# feedback: rhatto at riseup.net | gpl
-#
-# createpkg 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 any later version.
-#
-# createpkg 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
-#
-# /etc/simplepkg/slackbuildrc parameters:
-#
-# SLACKBUILDS_DIR="/folder/to/place/slackbuilds", defaults to /var/slackbuilds
-# SVN="svn://repository", defaults do svn://slack.sarava.org/slackbuilds
-# SYNC="yes|no", whether to always update the repository
-#
-# TODO
-#
-# - optionally show a dependency tree before create the package
-# - in function solve_dep: resolve program versions
-# - mkdir source directory - error... (please check!)
-
-#---------------------------------------------------
-# Createpkg functions
-#---------------------------------------------------
-
-CREATEPKG_VERSION="1.0.4.1"
-
-function error_codes {
-
- # Slackbuilds error codes
- ERROR_WGET=31 # wget error
- ERROR_MAKE=32 # make source error
- ERROR_INSTALL=33 # make install error
- ERROR_MD5=34 # md5sum error
- ERROR_CONF=35 # ./configure error
- ERROR_HELP=36 # dasable
- ERROR_TAR=37 # tar error
- ERROR_MKPKG=38 # makepkg error
- ERROR_GPG=39 # gpg check error
- ERROR_PATCH=40 # patch error
- ERROR_VCS=41 # cvs error
- ERROR_MKDIR=42 # make directory error
-
- # Createpkg error codes
- ERROR_INSTPKG=200 # installpkg error
- ERROR_DEPEN=201 # dependency error
- SCRIPT_OR_PACKAGE_NOT_FOUND=202 # Script or package not found
-}
-
-function eecho {
-
- # echoes a message
- # usage: eecho <message-type> <message>
- # message-type can be: commun, messag, error, normal
-
- echo -e "${1}${2}${normal}"
-
-}
-
-function handle_error {
-
- # This function deals with internal createpkg errors
- # and also with non-zero exit codes from slackbuilds
- # Input: $1 - error code
- # Output: Error mensage
- #
- # check slackbuild exit status are:
- #
- # ERROR_WGET=31; ERROR_MAKE=32; ERROR_INSTALL=33
- # ERROR_MD5=34; ERROR_CONF=35; ERROR_HELP=36
- # ERROR_TAR=37; ERROR_MKPKG=38 ERROR_GPG=39
- # ERROR_PATCH=40; ERROR_VCS=41; ERROR_MKDIR=42
- #
- # thanks to rudsonalves at yahoo.com.br for this spec.
-
- # we don't want to process when exit status = 0
- [ "$1" == "0" ] && return
-
- # Exit codes
- case $1 in
- 2) usage ;;
- 3) eecho $alert "$BASENAME: could not update the repository $2" ;;
- 4) eecho $alert "$BASENAME: could not create folder $2" ;;
- 5) eecho $alert "$BASENAME: script not found for $2" ;;
- $ERROR_WGET)
- eecho $error "$BASENAME: error downloading source/package for $2" ;;
- $ERROR_MAKE)
- eecho $error "$BASENAME: error compiling $2 source code" ;;
- $ERROR_INSTALL)
- eecho $error "$BASENAME: error installing $2" ;;
- $ERROR_MD5)
- eecho $error "$BASENAME: error on source code integrity check for $2" ;;
- $ERROR_CONF)
- eecho $error "$BASENAME: error configuring the source code for $2" ;;
- $ERROR_HELP)
- exit 0 ;; # its supposed to never happen here :P
- $ERROR_TAR)
- eecho $error "$BASENAME: error decompressing source code for $2" ;;
- $ERROR_MKPKG)
- eecho $error "$BASENAME: error creating package $2" ;;
- $ERROR_GPG)
- eecho $error "$BASENAME: error verifying GPG signature the source code for $2" ;;
- $ERROR_PATCH)
- eecho $error "$BASENAME: error patching the source code for $2" ;;
- $ERROR_VCS)
- eecho $error "$BASENAME: error downloading $2 source from version control system" ;;
- $ERROR_MKDIR)
- eecho $error "$BASENAME: make directory $2 error, aborting" ;;
- $ERROR_INSTPKG)
- eecho $error "$BASENAME: install package $2 error, aborting" ;;
- $ERROR_DEPEN)
- eecho $error "$BASENAME: dependency solve error, aborting" ;;
- *) eecho $error "$BASENAME: unknown error or user interrupt" ;;
- $SCRIPT_OR_PACKAGE_NOT_FOUND)
- eecho $error "$BASENAME: SlackBuild or package not found" ;;
- esac
-
- exit $1
-
-}
-
-function build_repo {
-
- # Checkout a new slackbuild working copy
- BASEDIR="`dirname $SLACKBUILDS_DIR`"
- mkdir -p $BASEDIR || handle_error 4 $BASEDIR
- cd $BASEDIR
- svn checkout $SVN
- cd $SLACKBUILDS_DIR
-
-}
-
-function usage {
-
- # Help mensage
- eecho $commun "Createpkg version $CREATEPKG_VERSION\n"
- eecho $commun "Usage: createpkg [--install/-i] package-name"
- eecho $commun " createpkg --no-deps/-np package-name"
- eecho $commun " createpkg --search/-s package-name"
- eecho $commun " createpkg --info/-f package-name"
- eecho $commun " createpkg --list/-l"
- eecho $commun " createpkg --sync"
- eecho $commun " createpkg --help/-h"
-}
-
-function check_config {
-
- # check the configuration
- TMP=${TMP:=/tmp};
- REPOS=${REPOS:=$TMP};
- # Create $TMP and $REPOS if need
- [ ! -e $TPM ] && mkdir $TMP
- [ ! -e $REPOS ] && mkdir $REPOS
- #
- SLACKBUILDS_DIR=${SLACKBUILDS_DIR:=/var/slackbuilds}
- SVN=${SVN:=svn://slack.sarava.org/slackbuilds}
- SYNC=${SYNC:=no}
- BASEDIR="`dirname $SLACKBUILDS_DIR`"
-
-}
-
-function solve_dep {
-
- # Solve dependency
- local PACK="$1"
- local COND="$2"
- local VER="$3"
-
- # Check package in local system
- PACK="`echo $PACK | sed -e 's/\+/\\\+/'`"
- INSTALLED=`eval "ls /var/log/packages/ | egrep -E '^$PACK-[^-]+-[^-]+-[^-]+$'"`
- CHECK=$?
-
- # TODO: Make check version procedures
- if [ -z "$INSTALLED" ]; then
- if [ $CHECK -ne 0 ]; then
- # Check package in SlackBuilds tree
- eecho $messag "$BASENAME: processing $PACKAGE dependency $PACK"
- SYNC=no CREATEPKG_CHILD=$CREATEPKG_CHILD createpkg --install $PACK
-
- # check if the package was built and installed
- EXIT_CODE="$?"
-
- if [ "$EXIT_CODE" == "5" ]; then
-
- # exit code 5 == slackbuild not found
- # try to use simplaret
- ARCH=$DEFAULT_ARCH simplaret --update
- ARCH=$DEFAULT_ARCH simplaret --install $PACK
- EXIT_CODE="$?"
- if [ "$EXIT_CODE" != "0" ]; then
- handle_error $SCRIPT_OR_PACKAGE_NOT_FOUND $PACK
- fi
-
- elif [ "$EXIT_CODE" != "0" ]; then
- handle_error $EXIT_CODE $PACK
- fi
-
- fi
- fi
-
-}
-
-function check_repo {
-
- # Verify if repository exist
- [ ! -d "$SLACKBUILDS_DIR" ] && build_repo
-
-}
-
-function sync_repo {
-
- # Synchronize repository
- cd $SLACKBUILDS_DIR
- svn update || build_repo
- #simplaret --update
-
-}
-
-function find_slackbuild {
-
- # Find SlackBuild script in the repository
- find $SLACKBUILDS_DIR -iname $1.SlackBuild
-
-}
-
-function info_builds {
-
- # Show packages info
- if [ "$PKG_PATH" != "" ]; then
- for i in $PKG_PATH; do
- PACKAGE=`basename $i .SlackBuild`
- NAME_UP=`echo $PACKAGE | tr [a-z] [A-Z]`
- eecho $commun "$NAME_UP: "
-
- PKG_DIR=`dirname $i`
- if [ -e $PKG_DIR/slack-desc ]; then
- eval "cat $PKG_DIR/slack-desc | grep '^$PACKAGE:' | cut -f2- -d:"
- eecho $normal
- else
- eval "cat $i | grep '^$PACKAGE:' | cut -f2- -d:"
- eecho $normal
- fi
-
- if [ -e $PKG_DIR/slack-required ]; then
- eecho $commun "slack-required"
- cat $PKG_DIR/slack-required | sed 's/^/ /'
- fi
- done
- fi
-
-}
-
-function list_builds {
-
- # List all available SlackBuilds
- cd $SLACKBUILDS_DIR
- echo "Sarava SlackBuilds list"
- # level 1
- for i in *; do
- if [ -d $i ]; then
- echo -e " $i: "
- (
- cd $i
- # level 2
- for j in *; do
- if [ -d $j ]; then
- eecho $commun " $j"
- (
- cd $j
- BUILD="`ls *.SlackBuild 2>/dev/null`"
- if [ "$BUILD" != "" ]; then
- # level 3
- for k in $BUILD; do
- eecho $messag " $k"
- done
- else
- BUILD=""
- fi
- for k in *; do
- if [ -d $k ]; then
- eecho $messag " $k.SlackBuild"
- fi
- done
- )
- fi
- done
- )
- fi
- done
-
-}
-
-function color_select {
-
- # Select color mode: gray, color or none (*)
- # commun - Communication
- # messag - Commum messages
- # error - Error messages
- # normal - turn off color
- case "$1" in
- 'gray')
- commun="\033[37;1m"
- messag="\033[37;1m"
- error="\033[30;1m"
- alert="\033[37m"
- normal="\033[m"
- ;;
- 'color')
- commun="\033[34;1m" # green
- messag="\033[32;1m" # blue
- error="\033[31;1m" # red
- alert="\033[33;1m" # yellow
- normal="\033[m" # normal
- ;;
- *)
- commun=""
- messag=""
- error=""
- alert=""
- normal=""
- ;;
- esac
-
-}
-
-#---------------------------------------------------
-# Starting createpkg
-#---------------------------------------------------
-# Common functions
-COMMON="/usr/libexec/simplepkg/common.sh"
-SIMPLEPKG_CONF="/etc/simplepkg/simplepkg.conf"
-
-# Loading error codes
-error_codes
-
-# First load simplepkg helper functions
-source $COMMON && source $SIMPLEPKG_CONF
-if [ $? -ne 0 ]; then
- eecho $error "error: file $COMMON not found, check your $BASENAME installation"
- exit 1
-fi
-
-# Load slackbuildrc definitions
-if [ -f ~/.slackbuildrc ]; then
- source ~/.slackbuildrc
-else
- source /etc/slackbuildrc 2>/dev/null
-fi
-
-# Select color mode: gray, color or none (*)
-color_select $COLOR
-
-# This is used to show how many children process we have
-if [ -z "$CREATEPKG_CHILD" ]; then
- CREATEPKG_CHILD="1"
-else
- let CREATEPKG_CHILD++
-fi
-
-BASENAME="`basename $0`[$CREATEPKG_CHILD]"
-
-check_config
-check_repo
-
-case $1 in
- '--search'|'-s')
- [ $# -ne 2 ] && handle_error 2 # two parameters is required
- find_slackbuild $2
- exit
- ;;
- '--info'|'-f')
- [ $# -ne 2 ] && handle_error 2 # two parameters is required
- PKG_PATH=`find_slackbuild $2`
- info_builds
- exit
- ;;
- '--install'|'-i')
- [ $# -ne 2 ] && handle_error 2 # two parameters is required
- PACKAGE="$2"
- INSTALL="1"
- ;;
- '--no-deps'|'-nd')
- [ $# -ne 2 ] && handle_error 2 # two parameters is required
- NO_DEPS="1"
- PACKAGE="$2"
- ;;
- '--sync')
- sync_repo
- exit 0
- ;;
- '--help'|'-h'|'')
- usage
- exit 0
- ;;
- '--list'|'-l')
- list_builds
- exit 0
- ;;
- *)
- if [ "${1:0:1}" != "-" ]; then
- PACKAGE="$1"
- else
- handle_error 2
- fi
- ;;
-esac
-
-# Synchronize repository
-[ "$SYNC" == "yes" ] && sync_repo
-
-# Get SlackBuild script
-BUILD_SCRIPT="`find_slackbuild $PACKAGE`"
-
-# Check SlackBuild script found
-if [ -z "$BUILD_SCRIPT" ]; then
- handle_error 5 $PACKAGE
-fi
-
-# Select one SlackBuild
-if [ "`echo $BUILD_SCRIPT | wc -w`" -gt 1 ]; then
- AUX="$PS3"
- PS3="Choice: "
- LIST=`echo $BUILD_SCRIPT | sed 's/ /\n/g' | sed -r 's/.*\/(.*)\.SlackBuild$/\1/'`" EXIT"
-
- select PACKAGE in `echo $LIST`; do
- break
- done
-
- if [ "$PACKAGE" = "EXIT" ]; then
- eecho $error "error: None package select"
- exit 1
- fi
-
- # Select only one SlackBuild in BUILD_SCRIPT
- BUILD_SCRIPT=`echo $BUILD_SCRIPT | sed 's/ /\n/g' | grep "/$PACKAGE.SlackBuild"`
- PS3="$AUX"
-else
- #PACKAGE=`echo $BUILD_SCRIPT | sed -r 's/.*\/(.*)\.SlackBuild$/\1/'`
- PACKAGE=`basename $BUILD_SCRIPT .SlackBuild`
-fi
-
-# Get dirname and script name from slackbuild
-SCRIPT_BASE="`dirname $BUILD_SCRIPT`"
-SCRIPT_NAME="`basename $BUILD_SCRIPT`"
-eecho $messag "$BASENAME: found script $PACKAGE.SlackBuild, now checking for dependencies"
-
-# Sets the package's slack-required
-if [ -f "$SCRIPT_BASE/$PACKAGE.slack-required" ]; then
- SLACK_REQUIRED="$SCRIPT_BASE/$PACKAGE.slack-required"
-elif [ -f "$SCRIPT_BASE/slack-required" ]; then
- SLACK_REQUIRED="$SCRIPT_BASE/slack-required"
-fi
-
-if [ ! -z "$SLACK_REQUIRED" -a "$NO_DEPS" != "1" ]; then
- # this routine checks for dependencies in package's slack-required
- ( grep '^[^#]' $SLACK_REQUIRED | while read dep; do
- if [ ! -z "$dep" ]; then
- PROGRAM="`echo $dep | awk '{ print $1 }'`"
- CONDITION="`echo $dep | awk '{ print $2 }' | tr [=\>\<] [egl]`"
- VERSION="`echo $dep | awk '{ print $3 }' | tr -dc '[:digit:]'`"
- solve_dep $PROGRAM $CONDITION $VERSION
- fi
- true
- done )
- if [ $? -ne 0 ]; then
- eecho $messag "$BASENAME: dependency solve error"
- exit 1
- fi
- eecho $messag "$BASENAME: done checking for $PACKAGE dependencies"
-else
- eecho $messag "$BASENAME: no unmet dependencies for $PACKAGE"
-fi
-
-eecho $messag "$BASENAME: processing $SCRIPT_NAME"
-
-# Change to script base directory
-cd $SCRIPT_BASE
-
-# Execute SlackBuild script with variables protection
-( INTERACT=no sh ./$SCRIPT_NAME )
-
-# Check if package was built
-handle_error $? $PACKAGE
-
-PKG_TGZ="`ls -1 -c $REPOS/$PACKAGE-*-*-*.tgz | head -n 1`"
-
-if [ "$INSTALL" == "1" ]; then
- # as we dont have the full package file name, we'll
- # use the newer file name that matches our wildcard:
-
- upgradepkg --install-new $PKG_TGZ
-fi
diff --git a/tags/0.5/src/jail-commit b/tags/0.5/src/jail-commit
deleted file mode 100755
index f40e5cd..0000000
--- a/tags/0.5/src/jail-commit
+++ /dev/null
@@ -1,175 +0,0 @@
-#!/bin/bash
-#
-# jail-commit: update config files from a jail to a template
-# feedback: rhatto@riseup.net | gpl
-#
-# Jail-commit 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 any later version.
-#
-# Jail-commit 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
-#
-
-COMMON="/usr/libexec/simplepkg/common.sh"
-BASENAME="`basename $0`"
-
-if [ -f "$COMMON" ]; then
- source $COMMON
- eval_config $BASENAME
-else
- echo "error: file $COMMON found, check your $BASENAME installation"
- exit 1
-fi
-
-function usage {
-
- echo $BASENAME: commit a jail configuration into a template
- echo "usage: \"$BASENAME [<jail-path> [template]]\""
- echo " \"$BASENAME --all\" to commit all templates"
- echo " \"$BASENAME --help\" for help"
-
-}
-
-function template_merge {
-
- # copy differences between the jail
- # and the template in the template folder
-
- # usage: template_merge <jail-path>
-
- if [ -z "$1" ] || [ ! -d "$TEMPLATE_BASE.d" ]; then
- return 1
- fi
-
- echo "" > $TEMPLATE_BASE.perms.tmp
- cd $TEMPLATE_BASE.d
-
- for file in `find | grep -v -e "/.svn$" | grep -v -e "/.svn/" | grep -v -e "^\.$"`; do
-
- if [[ -e "$file" && -e "$1/$file" ]]; then
-
- if [ ! -d "$file" ] && [ ! -h "$file" ]; then
- if ! diff $file $1/$file; then
- echo Updating $file
- cp -af $1/$file $file
- fi
- elif [ -h "$file" ]; then
- if [ "`readlink $file`" != "`readlink $1/$file`" ]; then
- rm -f $file
- ln -s `readlink $1/$file` $file
- fi
- fi
-
- perms="`numeric_perm $1/$file`"
- owner="`get_owner $1/$file`"
- group="`get_group $1/$file`"
-
- # secure the file
- chown root.root $TEMPLATE_BASE.d/$file
- chmod $perms $TEMPLATE_BASE.d/$file
-
- echo "$file;$owner;$group;$perms" >> $TEMPLATE_BASE.perms.tmp
-
- else
- if [ ! -e "$1/$file" ]; then
- echo $BASENAME: warning: missing file `slash $1/$file`
- fi
- fi
-
- done
-
- cat $TEMPLATE_BASE.perms.tmp | sed '/^$/d' > $TEMPLATE_BASE.perms
- rm -f $TEMPLATE_BASE.perms.tmp
-
- if ! svn_check $TEMPLATE_BASE,perms; then
- svn add $TEMPLATE_BASE,perms
- fi
-
-}
-
-function template_svn_commit {
-
- # issue a svn_commit from a template folder
- # usage: template_svn_commit <template-folder>
-
- if use_svn && [ -d "$1/.svn" ]; then
- cd $1
- echo First checking out from the repository...
- svn update
- echo Commiting changes to the repository...
- svn commit -m "changes for `date`"
- if [ "$?" != "0" ]; then
- echo $BASENAME: commit error
- fi
- fi
-
-}
-
-function do_commit {
-
- # commit jail changes to a repository
- # usage: do_commit <jailpath> [template]
-
- local jailpath template
-
- jailpath="$1"
- jail="`basename $jailpath`"
-
- if [ ! -z "$2" ]; then
- template="$2"
- else
- template="$jail"
- fi
-
- search_template $template --update
- if [ "$?" == "0" ] && ! echo "$TEMPLATE_UPDATE_LIST" | grep -q " `basename $TEMPLATE_BASE` "; then
- TEMPLATE_UPDATE_LIST=" $TEMPLATE_UPDATE_LIST `basename $TEMPLATE_BASE` " # the spaces are important
- if [ "$jailpath" == "/" ]; then
- echo Updating main installation...
- else
- echo Updating $jailpath...
- fi
- if [ -d "$TEMPLATE_BASE.d" ] || [ -a "$TEMPLATE_BASE.template" ]; then
- SILENT=yes templatepkg -u $template $jailpath
- template_merge $jailpath
- fi
- else
- if [ -z "$SILENT" ]; then
- echo $BASENAME: template $template not found
- fi
- return 1
- fi
-
-}
-
-TEMPLATE_UPDATE_LIST=""
-
-if [ "$1" == "--help" ]; then
- usage
-elif [ "$1" == "--all" ]; then
- template_svn_commit $BASE_CONF/templates
-elif echo $1 | grep -q -e "^--"; then
- usage
-elif [ ! -z "$1" ]; then
- do_commit $1 $2
- if [ "$?" == "0" ]; then
- template_svn_commit `dirname $TEMPLATE_BASE`
- fi
-else
- SILENT="yes"
- if [ -e $JAIL_LIST ]; then
- for jailpath in `cat $JAIL_LIST`; do
- do_commit $jailpath
- done
- fi
- # main jail
- do_commit / main
- template_svn_commit $BASE_CONF/templates
-fi
-
diff --git a/tags/0.5/src/jail-update b/tags/0.5/src/jail-update
deleted file mode 100755
index c5a008f..0000000
--- a/tags/0.5/src/jail-update
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/bash
-#
-# jail-update: update config files from a jail to a template
-# feedback: rhatto@riseup.net | gpl
-#
-# Jail-update 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 any later version.
-#
-# Jail-update 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
-#
-
-COMMON="/usr/libexec/simplepkg/common.sh"
-BASENAME="`basename $0`"
-
-if [ -f "$COMMON" ]; then
- source $COMMON
- eval_config $BASENAME
-else
- echo "error: file $COMMON found, check your $BASENAME installation"
- exit 1
-fi
-
-function usage {
-
- echo "$BASENAME: update a jail configuration from a template"
- echo "usage: $BASENAME <jail-path> [template]"
-
-}
-
-if [ -z "$1" ] || [ "$1" == "--help" ] || echo $1 | grep -q -e "^--"; then
- usage
- exit 1
-fi
-
-if [ -z "$2" ]; then
- template_name="`basename $1`"
-else
- template_name="$2"
-fi
-
-search_template $template_name --update
-
-if [ "$?" != "0" ]; then
- echo $BASENAME: template $template_name not found
- exit 1
-elif [ ! -d "$1" ]; then
- echo $BASENAME: jail $1 not found
- exit 1
-fi
-
-update_template_files
-copy_template_files $1
-set_jail_perms $1
-
diff --git a/tags/0.5/src/lspkg b/tags/0.5/src/lspkg
deleted file mode 100755
index 01900f2..0000000
--- a/tags/0.5/src/lspkg
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/bin/bash
-#
-# lspkg v0.3: view installed and contents of slackware packages
-#
-# feedback: rhatto at riseup.net | gpl
-#
-# Lspkg 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 any later version.
-#
-# Lspkg 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
-#
-
-COMMON="/usr/libexec/simplepkg/common.sh"
-
-if [ -f "$COMMON" ]; then
- source $COMMON
-else
- echo "error: file $COMMON not found, check your `basename $0` installation"
- exit 1
-fi
-
-function head_line {
- echo "usage: [ROOT=/otherroot] `basename $0` [option expression]"
-}
-
-function usage {
- head_line
- echo "
-options are:
-
- -v, --view: view installed package contents
- -p, --print: print the contents of a package file
- -r, --remove: remove matching packages
- -s, --search: search a file under installed packages
- -d, --description: show matching packages' descriptions
-"
-}
-
-# -----------------------------------------------------
-# lspkg
-# -----------------------------------------------------
-
-if [ $# -eq 2 ]; then
- LIST_PKGS="`ls /$ROOT/var/log/packages/$2-[0-9]* 2> /dev/null`"
- if [ -z "$LIST_PKGS" ]; then
- LIST_PKGS="`ls /$ROOT/var/log/packages/$2* 2> /dev/null`"
- fi
-elif [ $# -eq 1 ]; then
- LIST_PKGS="`ls /$ROOT/var/log/packages/$1-[0-9]* 2> /dev/null`"
- if [ -z "$LIST_PKGS" ]; then
- LIST_PKGS="`ls /$ROOT/var/log/packages/$1* 2> /dev/null`"
- fi
-else
- LIST_PKGS="`ls /$ROOT/var/log/packages/ 2> /dev/null`"
-fi
-
-LIST_PKGS="`slash $LIST_PKGS`"
-
-case $1 in
- "-h"|"--help")
- usage
- ;;
- "-v"|"--view")
- if [ ! -z "$2" ]; then
- if [ ! -z "$LIST_PKGS" ]; then
- for file in $LIST_PKGS; do
- less $file
- done
- else
- if [ ! -z "$ROOT" ]; then
- echo "$2: package not found on /$ROOT/var/log/packages"
- else
- echo "$2: package not found on /var/log/packages"
- fi
- fi
- else
- head_line
- exit 1
- fi
- ;;
- "-p"|"--print")
- if [ -f "$2" ]; then
- tar ztvf $2
- else
- echo $2: file not found
- fi
- ;;
- "-r"|"--remove")
- if [ ! -z "$2" ]; then
- if [ ! -z "$LIST_PKGS" ]; then
- removepkg /$ROOT/var/log/packages/$1-[0-9]*
- fi
- fi
- ;;
- "-s"|"--search")
- if [ ! -z "$2" ]; then
- eval "grep -l '\/$2$' /$ROOT/var/log/packages/*"
- fi
- ;;
- "-d"|"--description")
- if [ ! -z "$2" ]; then
- for file in $LIST_PKGS; do
- pack="`package_name $file`"
- echo -e " Package description for $file:\n"
- sed -n "/^$pack:/ { s/$pack://; p; }" $file
- done
- else
- head_line
- exit 1
- fi
- ;;
- *)
- if [ ! -z "$LIST_PKGS" ]; then
- for pack in $LIST_PKGS; do
- echo $pack
- done
- else
- if [ ! -z "$ROOT" ]; then
- echo "$1: package not found on /$ROOT/var/log/packages"
- else
- echo "$1: package not found on /var/log/packages"
- fi
- fi
- ;;
-esac
diff --git a/tags/0.5/src/mkbuild b/tags/0.5/src/mkbuild
deleted file mode 100755
index fce2533..0000000
--- a/tags/0.5/src/mkbuild
+++ /dev/null
@@ -1,680 +0,0 @@
-#!/bin/bash
-#
-# Script para gerar SlackBuild
-# Por Rudson R. Alves
-#
-# Este script auxilia a criação de SlackBuilds, com o modelo
-# do Luiz do Sarava Linux
-#
-# SlackBuilds são scripts utilizados no Slackware para gerar
-# pacotes tgz.
-#
-# Version 0.9.8
-PROG_VERSION=0.9.8
-
-#--------------------------------------------------------------------
-# Functions
-#--------------------------------------------------------------------
-function mkbuild_use()
-
-{
- # mkbuild help function
- echo "
-NAME
- mkbuild - create SlackBuild script from .mkbuild input file
-
-SYNOPSIS
- mkbuild [OPIONS] [mkbuild_file]
-
-DESCRIPTION
- <mkbuild_file> input file with build rules and variables
-
- Input options:
- -a, --author <author_name>
- author name
- -ai, --author_initials <initials>
- author signature
- -cs, --const_string <string>
- construction string to source name
- -u, --url <url_address>
- url address to source
- -pn, --pkg_name <package_name>
- package name
- -sn, --src_name <source_name>
- source name
- -pv, --pkg_version <version>
- package version
- -md, --model <SlackBuild_model>
- SlackBuild model file
- -j, --jobs <jobs_number>
- Number of jobs to run simultaneously
- --prefix <install_dir>
- Prefix install directory
-
- Program options:
- -h, --help
- this help mesage
- -c, --commit
- commit SlackBuilds in local svn tree
- -v, --version
- program version
-
-EXAMPLES
- mkbuild --prefix /usr/local pyrex.mkbuild
- build pyrex.SlackBuild with prefix /usr/local and pyrex.mkbuild
- variables and options definitions.
-
-AUTHOR
- Written by Rduson R. Alves
-
-AVAILABILITY
- by svn: svn checkout svn://slack.sarava.org/simplepkg
- this mkbuild is found in branches/0.6/
-
-REPORTING BUGS
- Report bugs to <alves_list@yahoo.com.br>
-
-COPYRIGHT
- Copyright © 2006 Free Software Foundation, Inc.
- This is free software. You may redistribute copies of it under the
- terms of the GNU General Public License
- <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the
- extent permitted by law.
-" | less
-}
-
-function error_codes {
-
- # Start error codes function
- NULL_STRING=499
- ERROR_FILE_NOT_FOUND=500
- ERROR_CONSTRUCTION=501
- ERROR_PROGRAM=502
- ERROR_INPUT_PAR=503
-}
-
-function mkbuild_error {
-
- # Error function
- case $1 in
- "$ERROR_FILE_NOT_FOUND")
- echo "File $2 not found!"
- ;;
- "$ERROR_CONSTRUCTION")
- echo "Construction error in $2 variable."
- ;;
- "$ERROR_PROGRAM")
- echo "Program logical error."
- ;;
- "$ERROR_INPUT_PAR")
- echo "Input parameter $2 error. See \"mkbuild --help\"."
- ;;
- *)
- echo "Unknow error!"
- ;;
- esac
- exit $1
-}
-
-function is_number {
-
- # Check if argument is a number
- local -i int
- if [ $# -eq 0 ]; then
- return 1
- else
- (let int=$1) 2>/dev/null
- return $? # Exit status of the let thread
- fi
-}
-
-function set_parameters {
-
- # Get and set mkbuild variables with parameters input
- # Use: set_parameters $@
- # where $@ are the parameters input
- #
- ALL_PAR=( $@ ) # carrega todos os parâmetros
- N_PAR=$# # carrega o número de parâmetros
-
- i=0 # inicia o contador
- # Checa todos os parâmetros passados
- while [ $i -lt $N_PAR ]; do
- # get parameter[i]
- PAR=${ALL_PAR[$i]}
- case $PAR in
- '-c'|'--commit')
- # Commit directory
- COMMIT=1
- ;;
- '-d'|'--debug')
- # Debug mode
- set -x
- ;;
- '-h'|'--help' )
- # Show help mesage
- mkbuild_use && exit 0
- ;;
- '-v'|'--version')
- # Show program version
- echo -e "\nmkbuild version $PROG_VERSION\n" && exit 0
- ;;
- '-a'|'--author')
- # Enter with author name
- let i++
- AUTHOR=${ALL_PAR[$i]}
- [ ${AUTHOR:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR AUTHOR
- ;;
- '-ai'|'--author_initials')
- # Enter with author name
- let i++
- AUTHOR_INITIALS=${ALL_PAR[$i]}
- [ ${AUTHOR_INITIALS:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR AUTHOR_INITIALS
- ;;
- '-cs'|'--const_string')
- # Enter with construction source name string
- let i++
- CONST_STRING=${ALL_PAR[$i]}
- [ ${CONST_STRING:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR CONST_STRING
- ;;
- '-md'|'--model')
- # Enter with SlackBuild model
- let i++
- MODEL=${ALL_PAR[$i]}
- [ ${MODEL:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR MODEL
- ;;
- '-j'|'--jobs')
- # Enter with SlackBuild model
- let i++
- NUMJOBS=${ALL_PAR[$i]}
- [ ${NUMJOBS:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR NUMJOBS
- [ ! is_number $NUMJOBS ] && mkbuild_error $ERROR_INPUT_PAR NUMJOBS
- NUMJOBS="-j$NUMJOBS"
- ;;
- '--prefix')
- # Enter with SlackBuild model
- let i++
- PREFIX=${ALL_PAR[$i]}
- [ ${PREFIX:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR PREFIX
- ;;
- '-pn'|'--pkg_name')
- # Enter with package name
- let i++
- PKG_NAME=${ALL_PAR[$i]}
- [ ${PKG_NAME:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR PKG_NAME
- ;;
- '-pv'|'pkg_version')
- # Enter with package version
- let i++
- VERSION=${ALL_PAR[$i]}
- [ ${VERSION:0:1} = "-" ] && mkbuild_error $ERROR_INPUT_PAR VERSION
- ;;
- '-sn'|'--src_name')
- # Enter with source name
- let i++
- SRC_NAME=${ALL_PAR[$i]}
- [ ${SRC_NAME:0:1} = '-' ] && mkbuild_error $ERROR_INPUT_PAR SRC_NAME
- ;;
- '-u'|'--url')
- # Enter with url address
- let i++
- URL=${ALL_PAR[$i]}
- [ ${URL:0:1} = '-' ] && mkbuild_error $ERROR_INPUT_PAR URL
- ;;
- *)
- # mkbuild input file
- MK_INPUT_FILE="${PAR//.mkbuild}.mkbuild"
- [ ! -e $MK_INPUT_FILE ] && mkbuild_error $ERROR_FILE_NOT_FOUND $MK_INPUT_FILE
- ;;
- esac
- let i++
- done
-}
-
-function get_variable {
-
- # Get variable value from mkbuild file (MK_INPUT_FILE)
- [ $# -ne 1 ] && mkbuild_error $ERROR_PROGRAM
- [ -z $MK_INPUT_FILE ] && echo "Warning: no [mkbuild_file]." && return 0
-
- grep "^\[\[${1}\]\]" $MK_INPUT_FILE | cut -f2 -d\"
-}
-
-function edit_file {
-
- # Edit file $3, by change string [[$1]] to $2
- local STR_OLD
- local STR_NEW
-
- [ $# -ne 3 ] && mkbuild_error $ERROR_PROGRAM
- STR_OLD=$( echo $1 | sed 's/\//\\\//g' )
- STR_NEW=$( echo $2 | sed 's/\//\\\//g' )
- eval "sed 's/\[\[$STR_OLD\]\]/$STR_NEW/' $3 > $AUX_TMP"
- mv $AUX_TMP $3
-}
-
-function edit_file_full {
-
- # Edit file $3, by change string $1 to $2
- local STR_OLD
- local STR_NEW
-
- [ $# -ne 3 ] && mkbuild_error $ERROR_PROGRAM
- STR_OLD=$( echo $1 | sed 's/\//\\\//g' )
- STR_NEW=$( echo $2 | sed 's/\//\\\//g' )
- eval "sed 's/$STR_OLD/$STR_NEW/' $3 > $AUX_TMP"
- mv $AUX_TMP $3
-}
-
-function start_build {
-
- # Build initial sections
- [ $# -ne 1 ] && mkbuild_error $ERROR_PROGRAM
-
- edit_file "SLACKBUILD AUTHOR" "$AUTHOR" $1
- edit_file "SLACKBUILD AUTHOR INITIALS" $AUTHOR_INITIALS $1
- edit_file "SOURCE NAME" "$SRC_NAME" $1
- edit_file "PROGRAM NAME" "$PKG_NAME" $1
- edit_file "PACKAGE NAME" "$PKG_NAME" $1
- edit_file "DECOMPRESSOR" "$DECOMPRESSOR" $1
- edit_file "DECOMPRESSOR TEST FLAG" "$DECOMPRESSOR_TEST_FLAG" $1
- edit_file "PROGRAM URL" "$URL" $1
- edit_file "ARCH" "$ARCH" $1
- [ `is_number $NUMJOBS` ] && NUMJOBS="-j${NUMJOBS}"
- edit_file "NUMBER OF JOBS" "$NUMJOBS" $1
- edit_file "VERSION" $VERSION $1
- edit_file "SOURCE NAME CONSTRUCTION STRING" "$CONST_STRING" $1
- edit_file "EXTENSION" "$EXTENSION" $1
- edit_file "DOWNLOAD FOLDER URL" "$URL_BASE" $1
- edit_file "OTHER CONFIGURE ARGS" "$OPTIONS" $1
- edit_file "DOCUMENTATION FILES" "$DOCFILES" $1
- edit_file "PREFIX" "$PREFIX" $1
-
- edit_file_full "\$EXTENSION" "$EXTENSION" $1
-}
-
-function clear_files {
-
- # Remove temporary files
- rm $AUX_TMP 2>/dev/null
- rm $SLACKBUILD_TEMP 2>/dev/null
-}
-
-function set_status {
-
- # Set status section
- # $1 - Section
- # $2 - Status
- # $3 - file
- [ $# -ne 3 ] && mkbuild_error $ERROR_PROGRAM
- if [ "`get_status $1 $3`" != "all" ]; then
- eval "sed 's/^<$1>.*$/<$1> $2/' $3" > $AUX_TMP
- mv $AUX_TMP $3
- else
- echo "Warning: Section $1 have status all. Can't change!"
- fi
-}
-
-function get_status {
-
- # Get status from section
- # $1 - Section
- # $2 - file
- [ $# -ne 2 ] && mkbuild_error $ERROR_PROGRAM
- eval "sed '/^<$1>.*$/! d' $2"
-}
-
-function activate_sections {
-
- # Enable and desable sections
- ACTIONS_LIST=`sed '/^#>>/,/<</ ! d; /^#/ d ' $MK_INPUT_FILE | tr -d ' '`
- for i in $ACTIONS_LIST; do
- STATUS=`echo $i | cut -f1 -d:`
- SECTION=`echo $i | cut -f2 -d:`
- set_status $SECTION $STATUS $SLACKBUILD_TEMP
- done
-}
-
-function build_slackbuild {
-
- # Remove off sections
- [ -e $SLACKBUILD ] && mv $SLACKBUILD $SLACKBUILD.old
- sed '/^<[a-z].*> off/, /^<\/[a-z].*>$/ d' $SLACKBUILD_TEMP > $AUX_TMP
- # Remove sections names
- sed '/^<.*$/ d' $AUX_TMP > $SLACKBUILD_TEMP
- # Remove clear lines
- sed ':i ; $! N; s/\n/<NL>/ ; t i' $SLACKBUILD_TEMP | sed 's/<NL><NL><NL>/<NL><NL>/g' | sed 's/<NL><NL><NL>/<NL><NL>/g' | sed 's/<NL>/\n/g' > $AUX_TMP
- sed '1,/^#\!/ {/^#\!/ b; d }' $AUX_TMP > $SLACKBUILD
-}
-
-function section_edit {
-
- # Edit sections by change you values
- [ -z $MK_INPUT_FILE ] && return 0
-
- SECTION_LIST=`grep '^#>[a-z]' $MK_INPUT_FILE | cut -c3-`
-
- # Check for sections change
- [ -z "$SECTION_LIST" ] && return 0
-
- # Change sections
- for i in $SECTION_LIST; do
- if [ "$i" = "slackdesc" ]; then
- # Special slackdesc section
- slackdesc_edit > $AUX_TMP
- mv $AUX_TMP $SLACKBUILD_TEMP
- else
- # Others sections
- section_change $i
- fi
- done
-}
-
-function slackdesc_edit {
-
- # Edit slackdesc section
- sed -n '1,/|-----/ { /<slackdesc>/ b; /|-----/ b; p; }' $SLACKBUILD_TEMP
- echo -n $PKG_NAME | tr [a-z+\-] " "
- echo -n "|-----handy-ruler"
- let N=18+${#PKG_NAME}
- for i in `seq $N $SLACKDESC_LEN`; do
- echo -n "-"
- done
- echo -en "|\n"
-
- sed -n '/#>slackdesc/,/#<slackdesc/ { /^#/ b; p }' $MK_INPUT_FILE
- sed '1, /\[\[SLACK-DESC\]\]/ d' $SLACKBUILD_TEMP
-}
-
-function section_change {
-
- # Change section lines
- [ $# -ne 1 ] && mkbuild_error $ERROR_PROGRAM
-
- # Copy first half
- eval "sed '1,/^<$1>/! d' $SLACKBUILD_TEMP > $AUX_TMP"
- # Paste new section
- eval "sed -n '/#>$1/,/#<$1/ { /^#>/ b; /^#</ b; p }' $MK_INPUT_FILE >> $AUX_TMP"
- # Copy second halt
- eval "sed '/^<\/$1>/,$ ! d' $SLACKBUILD_TEMP >> $AUX_TMP"
-
- mv $AUX_TMP $SLACKBUILD_TEMP
-}
-
-function make_slack_required {
-
- # Build slack-required file
- [ -e slack-required ] && mv slack-required slack-required.old
- [ -z "$SLACK_REQUIRED" ] && return 0
-
- echo -e "# Dependency list to $SRC_NAME\n#\n# dependency [condition] [version]]" > slack-required
-
- echo $SLACK_REQUIRED | sed 's/:/\n/g' | while read i; do
- REQ=`echo $i | awk '{ print $1 }'`
- CON=`echo $i | awk '{ print $2 }'`
- VER=`echo $i | awk '{ print $3 }'`
- echo -e "$REQ\t\t$CON\t\t$VER" >> slack-required
- done
-}
-
-function change_others_fields {
-
- # Change others fields started by '[[' in .mkbuild file
- grep '\[\[[A-Za-z]' $MK_INPUT_FILE | while read i; do
- CHANGE="`echo $i | sed 's/\[\[\(.*\)\]\]=\"\(.*\)\"/\1/'`"
- VALUE="`echo $i | sed 's/\[\[\(.*\)\]\]=\"\(.*\)\"/\2/'`"
- edit_file "$CHANGE" "$VALUE" $SLACKBUILD
- done
-}
-
-function commit_slackbuild {
-
- # Commit SlackBuild in local Slack.Sarava tree
- # Get SlackBuild path
- SLACKBUILD_PATH=`validate_parameter "$SLACKBUILD_PATH" "SLACKBUILD PATH" ""`
- if [ $? != 0 ]; then
- # Mount SlackBuild path
- AUX=`lynx -dump http://gentoo-portage.com/Search?search=$PKG_NAME | sed -n '/Results:/,+1 { /Results:/ b ; p }' | head --lines=1 | tr -d " "`
- [ ! -z $AUX ] && SLACKBUILD_PATH="`dirname $AUX | tr - /`/`basename $AUX`" || SLACKBUILD_PATH="others/unclassified/$PKG_NAME"
- fi
-
- # check SlackBuilds directory
- [ ! -e $SLACKBUILDS_DIR ] && createpkg --sync
- # change to SlackBuilds directory
- cd $SLACKBUILDS_DIR/
-
- # Add SlackBuild scripts
- # check path
- [ ! -e $SLACKBUILD_PATH ] && svn_mkdir $SLACKBUILD_PATH
- # add SlackBuild
- svn_add $SLACKBUILD $SLACKBUILD_PATH
-
- # check slack-required
- # add slack-required
- [ -e $WORK/slack-required ] && svn_add slack-required $SLACKBUILD_PATH
-
- cd $WORK
-}
-
-function svn_mkdir {
-
- # svn make directory
- [ $# -ne 1 ] && mkbuild_error 0
-
- echo "svn_mkdir $1 $2"
- DIR_LIST=`echo $1 | tr '/' ' '`
-
- DIR=""
- for i in $DIR_LIST; do
- DIR=$DIR/$i
- [ ! -e ${DIR:1} ] && svn mkdir ${DIR:1}
- done
-}
-
-function svn_add {
-
- # svn add file
- [ $# -ne 2 ] && mkbuild_error 0
-
- # copy file
- if [ -e $2/$1 ]; then
- echo "$2/$1 exist. Overwriter it."
- cp $WORK/$1 $2/
- else
- cp $WORK/$1 $2/
- # add file to svn tree
- svn add $2/$1
- fi
-}
-
-function is_number {
-
- # Check if $1 is a number
- local -i int
- if [ $# -eq 0 ]; then
- return 1
- else
- (let int=$1) 2>/dev/null
- return $? # Exit status of the let thread
- fi
-}
-
-function validate_parameter {
-
- # Validate parameter in .mkbuild file
- if [ ! -z "$1" ]; then
- echo "$1"
- else
- local STRING="`get_variable "$2"`"
- if [ -z "$STRING" ]; then
- [ ! -z "$3" ] && echo "$3" || return 1
- else
- echo "$STRING"
- fi
- fi
-}
-
-function decompress_find {
-
- # Find decompressor program and test flag
- case $EXTENSION in
- 'gz'|'GZ')
- DECOMPRESSOR="gunzip"
- DECOMPRESSOR_TEST_FLAG="-t"
- ;;
- 'bz2'|'BZ2')
- DECOMPRESSOR="bunzip2"
- DECOMPRESSOR_TEST_FLAG="-t"
- ;;
- 'zip'|'ZIP')
- DECOMPRESSOR="unzip"
- DECOMPRESSOR_TEST_FLAG="-t"
- ;;
- *)
- mkbuild_error $ERROR_CONSTRUCTION "DECOMPRESSOR"
- ;;
- esac
-}
-
-#=============================
-# Main Program
-#=============================
-#-----------------------------
-# Common functions
-COMMON="/usr/libexec/simplepkg/common.sh"
-SIMPLEPKG_CONF="/etc/simplepkg/simplepkg.conf"
-WORK=`pwd`
-LANG=en_US
-COMMIT=0
-
-if [ -f "$COMMON" ]; then
- source $COMMON
-else
- echo "error: file $COMMON found, check your $BASENAME installation"
- mk_exit 0
-fi
-
-# createpkg and mkbuild section
-SLACKBUILDS_DIR="`eval_parameter SLACKBUILDS_DIR /var/slackbuilds`"
-#-----------------------------
-
-# Start variables
-DOWNLOAD_SOURCE=0 # desable download source
-# Auxiliar file
-AUX_TMP=/tmp/mkbuild_tmp.$RANDOM
-# Derectory to SlackBuild models
-MODEL_DIR=${MODEL_DIR:="/etc/simplepkg/defaults/mkbuild"}
-# SlackDesk line length
-SLACKDESC_LEN=78
-
-# Load error codes
-error_codes
-
-[ $# -eq 0 ] && mkbuild_use && exit 1
-
-# Configure input parameters
-set_parameters $@
-
-# Get values
-# Author name
-AUTHOR=${AUTHOR:="`get_variable "SLACKBUILD AUTHOR"`"}
-[ -z "$AUTHOR" ] && mkbuild_error $ERROR_CONSTRUCTION "SLACKBUILD AUTHOR"
-
-# Author initials
-STR_MOUNT=`echo $AUTHOR | sed 's/ /\n/g' | sed 's/^\([A-Z]\).*/\1/' | sed ':i; $!N; s/\n//; ti' | tr [A-Z] [a-z]`
-AUTHOR_INITIALS="`validate_parameter "$AUTHOR_INITIALS" "SLACKBUILD AUTHOR INITIALS" "$STR_MOUNT"`" || mkbuild_error $ERROR_CONSTRUCTION "SLACKBUILD AUTHOR INITIALS"
-
-# URL program
-URL=`validate_parameter "$URL" "DOWNLOAD FOLDER URL" ""` || mkbuild_error $ERROR_CONSTRUCTION "URL"
-
-STR_MOUNT="`echo $URL | rev | cut -c1-3 | rev | tr -d '.'`"
-if [ $STR_MOUNT = "gz" -o $STR_MOUNT = "tgz" -o $STR_MOUNT = "bz2" -o $STR_MOUNT = "zip" ]; then
- SOURCE_NAME=`basename $URL`
- URL_BASE=`dirname $URL`
-else
- URL_BASE=$URL
-fi
-
-# Extension
-EXTENSION=`validate_parameter "$EXTENSION" "EXTENSION" "$STR_MOUNT"` || mkbuild_error $ERROR_CONSTRUCTION "EXTENSION"
-
-# Build archteture
-ARCH=`validate_parameter "$ARCH" "ARCH" "i486"`
-
-# Source name
-STR_MOUNT=`echo $SOURCE_NAME | sed -r 's/(.*)-(.*)\.(.*\..*)$/\1/'`
-SRC_NAME=`validate_parameter "$SRC_NAME" "SOURCE NAME" "$STR_MOUNT"` || mkbuild_error $ERROR_CONSTRUCTION "SOURCE NAME"
-
-# Package name
-STR_MOUNT=`echo $SRC_NAME | tr [A-Z_] [a-z\-]`
-PKG_NAME=`validate_parameter "$PKG_NAME" "PACKAGE NAME" "$STR_MOUNT"`
-
-# Version
-STR_MOUNT=`echo $SOURCE_NAME | sed -r 's/(.*)-(.*)\.(.*\..*)$/\2/'`
-VERSION=`validate_parameter "$VERSION" "VERSION" $STR_MOUNT` || mkbuild_error $ERROR_CONSTRUCTION "VERSION"
-
-# Construction source name string
-CONST_STRING="`validate_parameter "$CONST_STRING" "SOURCE NAME CONSTRUCTION STRING" "\\\$SRC_NAME-\\\$VERSION.tar.$EXTENSION"`"
-
-# Build Source Name
-[ -z $SOURCE_NAME ] && SOURCE_NAME=`eval "echo $CONST_STRING"`
-
-# Decompressor program and test flag
-DECOMPRESSOR=`validate_parameter "$DECOMPRESSOR" "DECOMPRESSOR" ""` || decompress_find
-
-DECOMPRESSOR_TEST_FLAG=`validate_parameter "$DECOMPRESSOR_TEST_FLAG" "DECOMPRESSOR TEST FLAG" ""` || mkbuild_error $ERROR_CONSTRUCTION "DECOMPRESSOR TEST FLAG"
-
-# Documentations list
-DOCFILES=`validate_parameter "$DOCFILES" "DOCUMENTATION FILES" "NEWS TODO README AUTHORS INSTALL ChangeLog MAINTAINERS COPYING readme.*"`
-
-# ./configure option
-OPTIONS=`validate_parameter "$OPTIONS" "OTHER CONFIGURE ARGS" ""`
-
-# PREFIX
-PREFIX=`validate_parameter "$PREFIX" "PREFIX" "/usr"`
-
-# Number of jobs
-NUMJOBS=`validate_parameter "$NUMJOBS" "NUMBER OF JOBS" ""`
-
-# Make slack-required file.
-SLACK_REQUIRED=`validate_parameter "$SLACK_REQUIRED" "SLACK REQUIRED" ""`
-
-# SlackBuild model
-MODEL=`validate_parameter "$MODEL" "SLACKBUILD MODEL" "generic.mkSlackBuild"`
-
-#
-# Start build SlackBuild
-SLACKBUILD=${PKG_NAME}.SlackBuild
-SLACKBUILD_TEMP=$SLACKBUILD.tmp
-cp $MODEL_DIR/$MODEL $SLACKBUILD_TEMP
-
-# Change Strings from model
-start_build $SLACKBUILD_TEMP
-
-# On/Off sections
-activate_sections
-
-# Change sections
-section_edit
-
-# Remove off sections
-build_slackbuild
-
-# Make slack-required file
-make_slack_required
-
-if [ -e slack-required ]; then
- DEPENDENCY_LIST="`cat slack-required | awk '{print $1}' | grep '^[a-z]' | tr '\012' ' '`"
- edit_file "REQUIRES" "$DEPENDENCY_LIST" $SLACKBUILD
-else
- edit_file "REQUIRES" "Null" $SLACKBUILD
-fi
-
-# Others changes
-change_others_fields
-
-# Clear temporary files
-clear_files
-
-[ $COMMIT -eq 1 ] && commit_slackbuild
-
diff --git a/tags/0.5/src/mkjail b/tags/0.5/src/mkjail
deleted file mode 100755
index f6c935c..0000000
--- a/tags/0.5/src/mkjail
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/bin/bash
-#
-# mkjail v0.4: chroot jail maker
-#
-# feedback: rhatto at riseup.net | GPL
-#
-# Mkjail 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 any later version.
-#
-# Mkjail 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
-#
-
-COMMON="/usr/libexec/simplepkg/common.sh"
-BASENAME="`basename $0`"
-
-if [ -f "$COMMON" ]; then
- source $COMMON
-else
- echo "error: file $COMMON found, check your `basename $0` installation"
- exit 1
-fi
-
-function usage {
-
- echo "usage: [ARCH=arch] [VERSION=version] [ROOT=/otherroot] $BASENAME <jail-name> [template]"
- exit 1
-
-}
-
-function exec_post_install_scripts {
-
- # exec post installation scripts
- # usage: exec_post_install_script <jail-root> <jail-name>
-
- local list
-
- if [ -z "$2" ]; then
- return 1
- fi
-
- echo "$BASENAME: executing template scripts..."
- if [ -d "$TEMPLATE_BASE.s" ]; then
- for file in $TEMPLATE_BASE.s/*; do
- if [ -x "$file" ]; then
- $file $1 $2
- fi
- done
- fi
-
-}
-
-function jailist_update {
-
- # update the jail list file
- # usage: jailist_update <jail-path>
-
- if [ "$ADD_TO_JAIL_LIST" == "1" ]; then
- touch $JAIL_LIST
- if ! grep -q -e "^$1\$" $JAIL_LIST; then
- echo $1 >> $JAIL_LIST
- fi
- fi
-
-}
-
-if [ -z "$1" ]; then
- usage
-else
- server="$1"
- eval_config $BASENAME -u
-fi
-
-if [ ! -z "$2" ]; then
- search_template $2
- result="$?"
-else
- search_default_template
- result="$?"
-fi
-
-if [ "$result" != "0" ]; then
- exit 1
-fi
-
-TEMPLATE="$TEMPLATE_BASE.template"
-
-if [ ! -d "$JAIL_ROOT/$server" ]; then
- mkdir -p $JAIL_ROOT/$server
-else
- if [ ! -z "`ls $JAIL_ROOT/$server | grep -v 'lost+found'`" ]; then
- echo $BASENAME: error: folder $JAIL_ROOT/$server already exists and seens to be not empty
- echo $BASENAME: probably the jail $1 already exists
- exit 1
- fi
-fi
-
-echo "$BASENAME: instaling packages into $JAIL_ROOT/$server using $TEMPLATE..."
-
-install_packages
-copy_template_files $JAIL_ROOT/$server
-set_jail_perms $JAIL_ROOT/$server
-jailist_update $JAIL_ROOT/$server
-exec_post_install_scripts $JAIL_ROOT $server
-
-echo $BASENAME: done creating $server jail
-
diff --git a/tags/0.5/src/rebuildpkg b/tags/0.5/src/rebuildpkg
deleted file mode 100755
index 6d3d10c..0000000
--- a/tags/0.5/src/rebuildpkg
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/bash
-#
-# rebuildpkg: build a package from a /var/log/packages entry
-#
-# feedback: rhatto at riseup.net | gpl
-#
-# Rebuildpkg 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 any later version.
-#
-# Rebuildpkg 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
-#
-
-COMMON="/usr/libexec/simplepkg/common.sh"
-TMP="/tmp"
-
-function usage {
- echo "usage: ROOT=/otherroot `basename $0` <package-name>"
-}
-
-if [ -f "$COMMON" ]; then
- source $COMMON
-else
- echo "error: file $COMMON found, check your `basename $0` installation"
- exit 1
-fi
-
-if [ -z "$1" ]; then
- usage
- exit 1
-fi
-
-pack="$1"
-
-for file in `ls $ROOT/var/log/packages/$pack*`; do
- if [[ "`package_name $file.tgz`" == "$pack" ]]; then
- package_file="$file"
- break
- fi
-done
-
-if [ -z "$package_file" ]; then
- echo error: package $pack does not exist
- exit 1
-fi
-
-if [ -d "$TMP/package-$pack" ]; then
- rm -rf $TMP/package-$pack
-fi
-
-mkdir $TMP/package-$pack
-cd $TMP/package-$pack
-
-for file in `grep -v -e "^PACKAGE NAME:" -e "^UNCOMPRESSED PACKAGE SIZE:" \
- -e "^COMPRESSED PACKAGE SIZE:" -e "^PACKAGE LOCATION:" \
- -e "^PACKAGE DESCRIPTION:" -e "^$pack:" -e "^FILE LIST:" $package_file`; do
-
- if [ "$file" != "install" ] && [ "$file" != "install/slack-desc" ] && [ "$file" != "install/doinst,sh" ]; then
- if [ -d /$file ]; then
- mkdir -p $TMP/package-$pack/$file
- elif [ -f /$file ]; then
- cp /$file $TMP/package-$pack/$file
- else
- echo file /$file was not found, please add it manually, exploding and making the package again
- fi
- fi
-
-done
-
-mkdir $TMP/package-$pack/install
-grep "^$pack:" $package_file > $TMP/package-$pack/install/slack-desc
-
-package_name="`grep "PACKAGE NAME:" $package_file | awk '{ print $3 }'`"
-
-if [ -f "$ROOT/var/log/scripts/$package_name" ]; then
- cp $ROOT/var/log/scripts/$package_name $TMP/package-$pack/install/doinst.sh
-fi
-
-makepkg $package_name.tgz
-mv $package_name.tgz $TMP/
-echo "done: package rebuilt and stored at $TMP/$package_name.tgz"
diff --git a/tags/0.5/src/repos b/tags/0.5/src/repos
deleted file mode 100755
index e4a17ee..0000000
--- a/tags/0.5/src/repos
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/bash
-#
-# repos script got from
-# http://software.jaos.org/BUILD/slapt-get/FAQ.html#slgFAQ17
-#
-# 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
-# any later version.
-#
-# Changes by rhatto at riseup.net to fit http://slack.sarava.org needs
-#
-
-BASENAME="`basename $0`"
-REPOS_CONF="/etc/simplepkg/repos.conf"
-COMMON="/usr/libexec/simplepkg/common.sh"
-
-if [ -f "$COMMON" ]; then
- source $COMMON
-else
- echo "error: file $COMMON found, check your $BASENAME installation"
- exit 1
-fi
-
-function usage {
-
- echo "`basename $0` [pkg [file]|all|new|svnmeta|PACKAGESTXT|FILELIST|MD5]"
-
-}
-
-function do_all {
-
- for pkg in `find . -type f -name '*.tgz' -print`; do
- gen_meta $pkg
- done
- $0 PACKAGESTXT
- $0 FILELIST
- $0 MD5
-
-}
-
-# ---------------------------------
-# main
-# ---------------------------------
-
-case "$1" in
- pkg)
- if [ -n "$2" ]; then
- gen_meta $2
- else
- usage
- fi
- ;;
- all)
- do_all
- ;;
- new)
- for pkg in `find . -type f -name '*.tgz' -print`; do
- if [ ! -f ${pkg%tgz}meta ]; then
- gen_meta $pkg
- fi
- done
- ;;
- svnmeta)
- svn_add_meta
- ;;
- PACKAGESTXT)
- gen_packages_txt .
- gen_packages_txt patches
- ;;
- FILELIST)
- gen_filelist
- gen_patches_filelist patches
- ;;
- MD5)
- gen_md5_checksums .
- gen_md5_checksums patches
- ;;
- usage)
- usage
- ;;
- *)
- do_all
- svn_add_meta
- ;;
-esac
-
diff --git a/tags/0.5/src/simplaret b/tags/0.5/src/simplaret
deleted file mode 100755
index c8cc2f7..0000000
--- a/tags/0.5/src/simplaret
+++ /dev/null
@@ -1,1131 +0,0 @@
-#!/bin/bash
-#
-# simplaret v0.2: simplepkg's retrieval tool
-# feedback: rhatto at riseup.net | gpl
-#
-# Simplaret 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 any later version.
-#
-# Simplaret 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
-#
-
-BASENAME="`basename $0`"
-REPOS_CONF="/etc/simplepkg/repos.conf"
-COMMON="/usr/libexec/simplepkg/common.sh"
-
-if [ -f "$COMMON" ]; then
- source $COMMON
-else
- echo "error: file $COMMON found, check your $BASENAME installation"
- exit 1
-fi
-
-function simplaret_usage {
-
- echo "usage: [ARCH=otherarch] [VERSION=otherversion] $BASENAME <OPTION> package-name"
- echo -e "\t OPTIONS: --install, --update, --upgrade, --search, --get, --get-patches, --purge, --remove"
- exit 1
-
-}
-
-function simplaret_get_index {
-
- for file in `simplaret_metafiles`; do
- simplaret_download $1 $file $2 --no-verbose
- done
-
-}
-
-function simplaret_backup_index {
-
- for file in `simplaret_metafiles`; do
- if [ -f "$1/$file" ]; then
- mv $1/$file $1/$file.old
- fi
- done
-
-}
-
-function simplaret_check_index {
-
- for file in `simplaret_metafiles`; do
- if [ ! -f "$1/$file" ] && [ -f "$1/$file" ]; then
- echo restoring old $file to $1...
- mv $1/$file.old $1/$file
- else
- rm -f $1/$file.old
- fi
- done
-
-}
-
-function simplaret_download {
-
- # download a file from a repo to a folder
- # usage: simplaret <repository_url> <package> <destination-folder> [--no-verbose]
-
- local protocol file
- local wget_timeout wget_passive_ftp wget_verbose
- local curl_timeout curl_passive_ftp curl_verbose
- local ncftpget_timeout ncftpget_passive_ftp
-
- protocol="`echo $1 | cut -d : -f 1`"
- file="`basename $2`"
-
- if [ ! -d "$3" ]; then
- mkdir -p $3
- fi
-
- if [ ! -z "$CONNECT_TIMEOUT" ] || [ "$CONNECT_TIMEOUT" != "0" ]; then
- wget_timeout="--timeout $CONNECT_TIMEOUT"
- ncftpget_timeout="-t $CONNECT_TIMEOUT"
- curl_timeout="--connect-timeout $CONNECT_TIMEOUT"
- fi
-
- if [ "$4" == "--no-verbose" ]; then
- wget_verbose="--no-verbose"
- curl_verbose="-#"
- echo ""
- fi
-
- if [ "$protocol" == "http" ]; then
-
- echo Getting $1/$2:
- if [ "$HTTP_TOOL" == "wget" ]; then
- wget $wget_timeout $wget_verbose $1/$2 -O $3/$file
- elif [ "$HTTP_TOOL" == "curl" ]; then
- curl $curl_timeout $curl_verbose $1/$2 > $3/$file
- else
- echo $BASENAME: error: invalid value for config variable HTTP_TOOL: $HTTP_TOOL
- echo $BASENAME: please check your config file $CONF
- exit 1
- fi
-
- elif [ "$protocol" == "ftp" ]; then
- echo Getting $1/$2:
-
- if [ "$PASSIVE_FTP" == "1" ]; then
- wget_passive_ftp="--passive-ftp"
- ncftpget_passive_ftp="-F"
- curl_passive_ftp="--ftp-pasv"
- fi
-
- if [ "$FTP_TOOL" == "ncftpget" ]; then
- ncftpget -c $ncftpget_timeout $ncftpget_passive_ftp $1/$2 > $3/$file
- elif [ "$FTP_TOOL" == "wget" ]; then
- wget $wget_timeout $wget_passive_ftp $wget_verbose $1/$2 -O $3/$file
- elif [ "$FTP_TOOL" == "curl" ]; then
- curl $curl_timeout $curl_passive_ftp $curl_verbose $1/$2 > $3/$file
- else
- echo $BASENAME: error: invalid value for config variable FTP_TOOL: $FTP_TOOL
- echo $BASENAME: please check your config file $CONF
- exit 1
- fi
-
- elif [ "$protocol" == "file" ]; then
-
- url="`echo $1 | sed -e 's/file:\/\///'`"
- if [ -f "$3/$file" ]; then
- rm -f $3/$file
- fi
- echo -n "Copying $url/$2..."
- if [ -f "$url/$2" ]; then
- cp $url/$2 $3/$file 2> /dev/null
- fi
- if [ -f "$3/$file" ]; then
- echo " done."
- else
- echo " failed."
- fi
-
- else
-
- echo $BASENAME error: invalid protocol $protocol
-
- fi
-
-}
-
-function simplaret_repository {
-
- # return a repository definition from $REPOS_CONF file
- # usage: simplaret_repository [root|repos|noarch|patches]
-
- local definition
-
- if [ -z "$1" ]; then
- definition="ROOT"
- else
- definition="`echo $1 | tr '[:lower:]' '[:upper:]'`"
- fi
-
- if [ "$definition" == "REPOS" ] || [ "$definition" == "PATCHES" ]; then
- definition="$definition-$ARCH-$VERSION"
- elif [ "$definition" == "ROOT" ]; then
- definition="$definition-$ARCH"
- fi
-
- grep -e "^$definition=" $REPOS_CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | cut -d "#" -f 1
-
-}
-
-function simplaret_repository_name {
-
- # return a repository name according the value of $repository
-
- if [ -z "$repository" ]; then
- false
- elif echo $repository | grep -qe %; then
- repository_name="`echo $repository | cut -d % -f 1`"
- if [ -z "$repository_name" ]; then
- echo $BASENAME: you should set a name for the repository $repository
- echo $BASENAME: please correct your $REPOS_CONF
- exit 1
- fi
- else
- echo $BASENAME: you should set a name for the repository $repository
- echo $BASENAME: please correct your $REPOS_CONF
- exit 1
- fi
-
-}
-
-function simplaret_repository_url {
-
- # return a repository url according the value of $repository
-
- if echo $repository | grep -qe %; then
- repository_url="`echo $repository | cut -d % -f 2`"
- if [ -z "$repository_url" ]; then
- echo $BASENAME: you should set a url for the repository $repository
- echo $BASENAME: please correct your $REPOS_CONF
- exit 1
- fi
- else
- echo $BASENAME: you should set a url for the repository $repository
- echo $BASENAME: please correct your $REPOS_CONF
- exit 1
- fi
-
- if [ "$repos_type" == "root" ]; then
- simplaret_distro_folder
- repository_url="$repository_url/$DISTRO_FOLDER/$EXTRA_FOLDER"
- fi
-
-}
-
-function simplaret_set_storage_folder {
-
- storage="$STORAGE/$ARCH/$VERSION/$repos_type"
- if [ "$repos_type" == "noarch" ]; then
- storage="$STORAGE/noarch"
- elif [ "$repos_type" == "patches" ]; then
- storage="$PATCHES_DIR/$ARCH/$VERSION"
- fi
-
-}
-
-function simplaret_update {
-
- local storage
-
- echo Updating package information for arch $ARCH and version $VERSION...
-
- for repos_type in patches root repos noarch; do
-
- simplaret_set_storage_folder
-
- for repository in `simplaret_repository $repos_type`; do
-
- simplaret_repository_name
- simplaret_repository_url
-
- if [ ! -d "$storage/$repository_name" ]; then
- mkdir -p $storage/$repository_name
- else
- simplaret_backup_index $storage/$repository_name
- fi
-
- simplaret_get_index $repository_url $storage/$repository_name
- simplaret_check_index $storage/$repository_name
-
- unset repository_name repository_url repository_protocol
-
- done
- done
-
-}
-
-function simplaret_find_package {
-
- # grep packages in a repository's file list
- # usage: simplaret_find_package <package-name|-all> <repository-folder>
-
- if [ "$1" == "-all" ]; then
- grep -e ".tgz$" $2/`simplaret_filelist` | awk '{ print $8 }'
- else
- grep $1 $2/`simplaret_filelist` | awk '{ print $8 }' | grep -e ".tgz$"
- fi
-
-}
-
-function simplaret_show_package {
-
- # print a package result
- # usage: simplaret_show_package <package-file-name> [--basename-only|--filename-only|--formatted]
-
- if [ "$2" == "--basename-only" ]; then
- echo `basename $1`
- elif [ "$2" == "--filename-only" ]; then
- echo $1
- elif [ "$2" == "--formatted" ]; then
- echo $1,$repos_type,$repository
- else
- if echo $1 | grep -q "/patches/"; then
- patch="(patch)"
- fi
- if [ "$repos_type" == "noarch" ]; then
- echo $name repository $repository_name: `basename $1` $patch
- else
- echo $name repository $repository_name, arch: $ARCH, version: $VERSION: `basename $1` $patch
- fi
- fi
- unset patch
-
-}
-
-function simplaret_filelist {
-
- if [ "$repos_type" == "patches" ]; then
- echo FILE_LIST
- else
- echo FILELIST.TXT
- fi
-
-}
-
-function simplaret_metafiles {
-
- echo `simplaret_filelist` CHECKSUMS.md5
-
-}
-
-function simplaret_search {
-
- # search packages
- # usage: simplaret_search [package-name] [-display_mode]
- # display_mode can be any accepted by simplaret_show_package
-
- local priority priority_match message pattern mode
-
- if [ ! -z "$1" ] && ! echo $1 | grep -q -e "^-"; then
- pattern="$1"
- mode="$2"
- else
- pattern="-all"
- mode="$1"
- fi
-
- for repos_type in patches root repos noarch; do
-
- name="`echo $repos_type | tr '[:lower:]' '[:upper:]'`"
- simplaret_set_storage_folder
-
- for repository in `simplaret_repository $repos_type`; do
-
- simplaret_repository_name
-
- if [ ! -f "$storage/$repository_name/`simplaret_filelist`" ]; then
- if [ "$WARNING" != "0" ] || [ ! -z "$SILENT" ]; then
- if [ "$repos_type" == "noarch" ]; then
- message=""
- else
- message="on arch $ARCH version $VERSION"
- fi
- echo warning: no file list for $repository_name repository $repository_name $message
- echo please do a simplaret --update
- fi
- else
-
- if [ "$repos_type" == "root" ]; then
- # root repositories has ROOT_PRIORITY
- for priority in $ROOT_PRIORITY; do
- for file in `simplaret_find_package $pattern $storage/$repository_name | grep "/$priority/"`; do
- simplaret_show_package $file $mode
- done
- priority_match="$priority_match|/$priority/"
- done
- # now we should return all matches that are not part of ROOT_PRIORITY
- priority_match="`echo $priority_match | sed -e 's/^|//'`"
- for file in `simplaret_find_package $pattern $storage/$repository_name | egrep -v $priority_match`; do
- simplaret_show_package $file $mode
- done
- priority_match=""
- elif [ "$repos_type" == "repos" ]; then
- # repos repositories has REPOS_PRIORITY
- for priority in $REPOS_PRIORITY; do
- for file in `simplaret_find_package $pattern $storage/$repository_name | grep "/$priority/"`; do
- simplaret_show_package $file $mode
- done
- priority_match="$priority_match|/$priority/"
- done
- # now we should return all matches that are not part of REPOS_PRIORITY
- priority_match="`echo $priority_match | sed -e 's/^|//'`"
- for file in `simplaret_find_package $pattern $storage/$repository_name | egrep -v $priority_match`; do
- simplaret_show_package $file $mode
- done
- priority_match=""
- else
- for file in `simplaret_find_package $pattern $storage/$repository_name`; do
- simplaret_show_package $file $mode
- done
- fi
-
- fi
-
- done
- done
-
-}
-
-function simplaret_purge {
-
- # purge simplaret package cache
- # usage: simplaret_purge [-w N]
-
- local mtime mtime_message which and_patches
-
- if [ "$1" == "-w" ] && [ ! -z "$2" ]; then
- mtime="-mtime +`echo "$2*7" | bc -l`"
- mtime_message="older than $2 weeks"
- elif [ "$SIMPLARET_PURGE_WEEKS" != "0" ]; then
- mtime="-mtime +`echo "$SIMPLARET_PURGE_WEEKS*7" | bc -l`"
- mtime_message="older than $SIMPLARET_PURGE_WEEKS weeks"
- else
- mtime=""
- mtime_mesage=""
- fi
-
- which="root repos noarch"
- and_patches=""
-
- if [ "$SIMPLARET_PURGE_PATCHES" == "1" ]; then
- which="patches $which"
- and_patches="including patches"
- fi
-
- if [ -z "$SILENT" ]; then
- if [ -z "$mtime_message" ]; then
- echo "$BASENAME: purging all packages for:"
- else
- echo "$BASENAME: purging all packages $mtime_message for:"
- fi
- echo -e "\t- Arch $ARCH and version $VERSION $and_patches"
- echo -e "\t- Noarch folder"
- fi
-
- for repos_type in $which; do
-
- simplaret_set_storage_folder
-
- for file in `find $storage/ $mtime 2> /dev/null`; do
- for extension in tgz asc meta txt slack-required; do
- if echo $file | grep -qe ".$extension$"; then
- rm $file
- fi
- done
- done
-
- done
-
- if [ -z "$SILENT" ]; then
- echo $BASENAME: done purging simplaret cache
- echo $BASENAME: please run $BASENAME --update to retrieve new package listings on this arch and version
- fi
-
-}
-
-function simplaret_search_and_delete {
-
- # search and delete packages
- # usage: simplaret_search_and_delete <package> <folder> [--silent]
-
- local file candidate place basename name version build
- local name_version name_build
-
- name="`package_name $1`"
-
- if [ "$name" != "$1" ]; then
- # searching by full package filename
- name_version="`package_version $1`"
- name_build="`package_build $1`"
-
- # search wheter the package filename is in the repositories
- if [ "`simplaret_search $1 | grep $1 | wc -l`" == "0" ]; then
- echo "Error: package not found: $1"
- return 1
- fi
-
- for file in `find $2/ -name $name*tgz 2> /dev/null`; do
- candidate="`basename $file`"
- version="`package_version $candidate`"
- build="`package_build $candidate`"
- if [ "`package_name $candidate`" == "$name" ]; then
-
- if [ "$name_version" == "$version" ] && \
- [ "$name_build" == "$build" ]; then
- LAST_DOWNLOADED_PACKAGE="$file"
- if [ "$3" != "--silent" ]; then
- echo Package $candidate already downloaded
- # echo Package $candidate stored at `dirname $file`
- else
- true
- # echo $file
- fi
- return 1
- else
- place="`dirname $file`"
- basename="`basename $file tgz`"
- rm -f $file
- rm -f $place/$candidate.slack-required
- rm -f $file.asc $place/$basename.meta $place/$basename.txt
- break
- fi
-
- fi
- done
-
- else
-
- for file in `find $2/ -name $name*tgz 2> /dev/null`; do
- candidate="`basename $file`"
- version="`package_version $candidate`"
- build="`package_build $candidate`"
- if [ "`package_name $candidate`" == "$name" ]; then
- # check if has the same version and build number, otherwise erase the old one
- for result in `simplaret_search $(package_name $candidate) --basename-only`; do
- if [ "`package_name $candidate`" == "`package_name $result`" ]; then
-
- if [ "$version" == "`package_version $result`" ] && \
- [ "$build" == "`package_build $result`" ]; then
- LAST_DOWNLOADED_PACKAGE="$file"
- if [ "$3" != "--silent" ]; then
- echo Package $candidate already downloaded
- # echo Package $candidate stored at `dirname $file`
- else
- true
- # echo $file
- fi
- return 1
- else
- place="`dirname $file`"
- basename="`basename $file tgz`"
- rm -f $file
- rm -f $place/$candidate.slack-required
- rm -f $file.asc $place/$basename.meta $place/$basename.txt
- break
- fi
-
- fi
- done
- fi
- done
-
- fi
-
-}
-
-function simplaret_get {
-
- # get a package
- # usage: simplaret_get <package-name|package-file-name> [--silent]
-
- local silent generate_patches search search_results
- local name version build
-
- # prevent user to stay in $storage
- cd
-
- name="`package_name $1`"
-
- if [ "$name" != "$1" ]; then
- # simplaret_get was called with the package file
- # name and not with just the package name
- version="`package_version $1`"
- build="`package_build $1`"
- else
- version=""
- build=""
- fi
-
- # first search for an already downloaded package
- for repos_type in patches root repos noarch; do
-
- simplaret_set_storage_folder
- simplaret_search_and_delete $1 $storage $2
-
- if [ "$?" == "1" ]; then
- return 0
- fi
-
- done
-
- # then search for the package in the repositories
- search="`simplaret_search $1 --formatted`"
- search_results="`echo "$search" | wc -l`"
-
- for result in $search; do
-
- # remaining search results
- let search_results--
-
- file="`echo $result | cut -d , -f 1`"
- repos_type="`echo $result | cut -d , -f 2`"
- repository="`echo $result | cut -d , -f 3`"
-
- simplaret_set_storage_folder
- simplaret_repository_name
-
- candidate="`basename $file`"
- if [ "`package_name $candidate`" == "$name" ]; then
-
- if [ ! -z "$build" ] && [ ! -z "$version" ]; then
- # simplaret_get was called with the package file
- # name and not with just the package name
- if [ "$version" != "`package_version $candidate`" ] && \
- [ "$build" != "`package_build $candidate`" ]; then
- # the package version and/or build doesnt matched
- # the desired one
- continue
- fi
- fi
-
- simplaret_repository_url
-
- # if repos_type == root, the package is a patch and
- # STORE_ROOT_PATCHES_ON_PATCHES_DIR config parameter is enabled, then
- # save it on $PATCHES_DIR/root-$repository_name, so all patches
- # are placed in the same tree
- if [ "$repos_type" == "root" ] && \
- [ "$STORE_ROOT_PATCHES_ON_PATCHES_DIR" == "1" ] && echo $file | grep -q "patches"; then
- folder="$PATCHES_DIR/$ARCH/$VERSION/root-$repository_name"
- generate_patches="1"
- else
- folder="$storage/$repository_name"
- fi
-
- # download the package
- simplaret_download $repository_url $file $folder
-
- if [ -f "$folder/$candidate.asc" ]; then
- rm $folder/$candidate.asc
- fi
-
- if [ -f "$folder/$name.slack-required" ]; then
- rm $folder/$name.slack-required
- fi
-
- # download the signature, if exist
- if simplaret_check_url $repository_url/$file.asc; then
- simplaret_download $repository_url $file.asc $folder
- fi
-
- # download slack-required, if exist
- if simplaret_check_url $repository_url/`dirname $file`/$name.slack-required; then
- simplaret_download $repository_url `dirname $file`/$name.slack-required $folder
- fi
-
- if [ ! -f "$folder/$candidate" ]; then
- LAST_DOWNLOADED_PACKAGE="0"
- if [ "$2" != "--silent" ]; then
- echo Error downloading $candidate from $repos_type repository $repository_url, please check your settings
- fi
- # check if there's also more repositories to try
- if [ "$SIMPLARET_DOWNLOAD_FROM_NEXT_REPO" != "1" ]; then
- return 1
- else
- if [ "$2" != "--silent" ]; then
- echo Trying to fetch $candidate from the next repository...
- fi
- if (($search_results <= 0)); then
- return 1
- fi
- fi
- else
- LAST_DOWNLOADED_PACKAGE="$folder/$candidate"
- if [ "$2" != "--silent" ]; then
- silent=""
- echo Package $candidate stored at $folder
- else
- # echo $folder/$candidate
- silent="--silent"
- fi
- if [ -f "$folder/$candidate.asc" ] || [ "$SIGNATURE_CHECKING" == "1" ]; then
- gpg --verify $folder/$candidate.asc $folder/$candidate
- fi
- # generate the patches FILE_LIST and PACKAGES.TXT if needed
- if [ "$generate_patches" == "1" ]; then
- gen_patches_filelst $folder
- gen_packages_txt $folder
- gen_md5_checksums $folder
- fi
- simplaret_checksum $storage/$repository_name/CHECKSUMS.md5 $folder/$candidate $silent
- return $?
- fi
-
- fi
-
- done
-
-}
-
-function simplaret_search_and_process_patch {
-
- local package_version package_build installed_version
- local installed_build repos_type get is_patch package_match
-
- # get the repository type
- repos_type="`echo $sugested | cut -d , -f 2`"
-
- # get just the file name
- sugested="`echo $sugested | cut -d , -f 1`"
-
- if echo $sugested | grep -q "patches"; then
- is_patch="yes"
- else
- is_patch="no"
- fi
-
- # now split the file name into pieces
- package_version="`package_version $sugested`"
- package_build="`package_build $sugested`"
- sugested="`package_name $sugested`"
-
- # check if the patch was already downloaded
- if echo "$DOWNLOADED_PATCHES" | grep -q " $ARCH:$VERSION:$sugested "; then
- if [ "$IS_UPGRADE" != "1" ]; then
- echo Package $sugested already downloaded
- # echo "Jail $root needs package $sugested (already downloaded, skipping)"
- return
- fi
- fi
-
- # search if its installed in the jail
- installed_packs="`ls /$root/var/log/packages/$sugested* 2> /dev/null`"
- if [ ! -z "$installed_packs" ]; then
-
- for installed in $installed_packs; do
- if [[ "$sugested" == "`package_name $installed.tgz`" ]]; then
- package_installed="1"
- installed_version="`package_version $installed.tgz`"
- installed_build="`package_build $installed.tgz`"
- break
- fi
- done
-
- get="no"
-
- # if the package is installed, download the patch
- if [ "$package_installed" == "1" ]; then
- if [ "$repos_type" == "patches" ]; then
-
- if [ "$package_version" != "$installed_version" ] || [ "$package_build" != "$installed_build" ]; then
- get="yes"
- package_match="no"
- elif [ "$DOWNLOAD_EVEN_APPLIED_PATCHES" == "1" ]; then
- get="yes"
- fi
-
- elif [ "$repos_type" == "root" ] && [ "$is_patch" == "yes" ]; then
-
- if [ "$package_version" != "$installed_version" ] || [ "$package_build" != "$installed_build" ]; then
- get="yes"
- package_match="no"
- elif [ "$DOWNLOAD_EVEN_APPLIED_PATCHES" == "1" ]; then
- get="yes"
- fi
-
- else
- # here, we're dealing with repositories other than ROOT and REPOS,
- # so we need to check if either version or build number are different,
- # otherwise all installed packages would be downloaded
- if [ "$package_version" != "$installed_version" ] || [ "$package_build" != "$installed_build" ]; then
- get="yes"
- package_match="no"
- fi
- fi
- fi
-
- # finally, get the package
- if [ "$get" == "yes" ]; then
- if [ "$IS_UPGRADE" == "1" ]; then
- if [ "$package_match" == "no" ]; then
- simplaret_install $sugested
- else
- simplaret_get $sugested
- fi
- else
- simplaret_get $sugested
- fi
- if [ "$?" == "0" ]; then
- DOWNLOADED_PATCHES="$DOWNLOADED_PATCHES $ARCH:$VERSION:$sugested " # the ending space is important
- fi
- fi
-
- fi
-
- unset package_installed get
-
-}
-
-function simplaret_get_jail_patches {
-
- # get patches from a jail
- # usage: simplaret_get_jail_patches <jail-folder>
-
- local oldarch oldversion
-
- if [ ! -z "$1" ]; then
- root="$1"
- else
- root="/"
- fi
-
- # save current arch and version
- oldarch="$ARCH"
- oldversion="$VERSION"
-
- ARCH="`default_arch $root`"
- VERSION="`default_version $root`"
-
- # in case there's something wrong with the jail, abort
- if [ -z "$VERSION" ] || [ -z "$ARCH" ]; then
- return
- fi
-
- # we need to do that for each arch/version pairs, but just once for each pair
- if ! echo "$DISTRO_UPDATED" | grep -q " $ARCH:$VERSION "; then
- simplaret_update
- DISTRO_UPDATED="$DISTRO_UPDATED $ARCH:$VERSION " # the ending space is important
- echo ""
- fi
-
- echo Fetching patches for arch $ARCH and version $VERSION for jail $root
-
- # list all available patches from PATCHES and ROOT repositories
- for sugested in `simplaret_search --formatted | grep patches | grep -v ",repos," | grep -v ",noarch,"`; do
- simplaret_search_and_process_patch
- done
-
- # grab patches from every other places
- if [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "1" ]; then
-
- for sugested in `simplaret_search --formatted | grep patches | grep ",repos," | grep ",noarch,"`; do
- simplaret_search_and_process_patch
- done
-
- for sugested in `simplaret_search --formatted | grep -v patches`; do
- simplaret_search_and_process_patch
- done
-
- fi
-
- # restore arch and version
- ARCH="$oldarch"
- VERSION="$oldversion"
-
-}
-
-function simplaret_get_patches {
-
- local jailpath
-
- if [ "$1" == "--upgrade" ]; then
- IS_UPGRADE="1"
- fi
-
- if [ ! -z "$ROOT" ]; then
- simplaret_get_jail_patches $ROOT
- return $?
- fi
-
- # first get patches from the root system
- simplaret_get_jail_patches
-
- # then get the needed patches for each installed jail
- if [ -s "$JAIL_LIST" ]; then
- for jailpath in `cat $JAIL_LIST`; do
- if [ -d "$jailpath/var/log/packages" ]; then
- ROOT="$jailpath"
- simplaret_get_jail_patches $jailpath
- fi
- done
- fi
-
- ROOT=""
-
-}
-
-function simplaret_checksum {
-
- # simplaret_checksum <md5file> <file-name> [--silent]
-
- if [ ! -f "$1" ] || [ ! -f "$2" ]; then
- if [ "$3" != "--silent" ]; then
- echo Checksum error: file not found
- fi
- return 1
- fi
-
- pack="`basename $2`"
- checksum="`grep -e "$pack\$" $1 | awk '{ print $1 }'`"
-
- if [ -z "$checksum" ]; then
- echo file $2 not in checksum $1
- return 1
- elif [ "$checksum" != "`md5sum $2 | awk '{ print $1 }'`" ]; then
- if [ "$3" != "--silent" ]; then
- echo Checksum mismatch for file `basename $file`
- fi
- return 1
- else
- if [ "$3" != "--silent" ]; then
- echo Checksum ok for file `basename $file`
- fi
- return 0
- fi
-
-}
-
-function simplaret_install {
-
- # download and install a package
- # usage: simplaret_install <package-name|package-file-name> [--skip-checks]
-
- local package root jail_arch jail_version slack_required dep dependency tmp
- local name version build
-
- name="`package_name $1`"
-
- root="/$ROOT"
- mkdir -p $root/var/log/setup/tmp
-
- if [ "`echo $1 | sed -e 's/\(..\).*/\1/g'`" == "--" ]; then
- echo $BASENAME: install: syntax error: expected package name
- return 1
- fi
-
- # now we check if ARCH and VERSION from the
- # repository are the same of the jail
- if [ "$2" != "--skip-checks" ]; then
- jail_arch="`default_arch $root`"
- jail_version="`default_version $root`"
- if [ "$ARCH" != "$jail_arch" ]; then
- echo "$BASENAME: requested repository arch ($ARCH) doesn't match jail arch ($jail_arch)"
- echo "$BASENAME: please use \"$BASENAME --get $1 --skip-checks\" to ignore this warning and install anyway"
- return
- elif [ "$VERSION" != "$jail_version" ]; then
- echo "$BASENAME: requested repository version ($VERSION) doesn't match jail version ($jail_version)"
- echo "$BASENAME: please use \"$BASENAME --get $1 --skip-checks\" to ignore this warning and install anyway"
- return 1
- fi
- fi
-
- # package="`simplaret_get $1 --silent`"
- simplaret_get $1 --silent
- package="$LAST_DOWNLOADED_PACKAGE"
-
- if [ "$package" != "0" ] && [ ! -z "$package" ]; then
- slack_required="`dirname $package`/$name.slack-required"
- if [ -f "$package" ]; then
-
- if [ -f "$slack_required" ] && [ "$DEPENDENCY_CHECKING" == "1" ]; then
- # this routine checks for dependencies in package's slack-required
- # procedure adapted from createpkg script
- ( cat $slack_required | while read dep; do
- if [ ! -z "$dep" ]; then
- dependency="`echo $dep | awk '{ print $1 }'`"
- simplaret_solve_dep $name $dependency $root
- fi
- true
- done )
- fi
-
- ROOT=$root upgradepkg --install-new $package
- LAST_DOWNLOADED_PACKAGE="0"
-
- else
- echo "Error: could not install package $1: file not found"
- LAST_DOWNLOADED_PACKAGE="0"
- return 1
- fi
- else
- echo "Error: could not install package $1"
- LAST_DOWNLOADED_PACKAGE="0"
- return 1
- fi
-
-}
-
-function simplaret_distro_folder {
-
- # first we point to the correct arch
- simplaret_set_arch
-
- # then we set the distro folder
- if [ "$ARCH" == "i386" ]; then
- DISTRO="slackware"
- DISTRO_FOLDER="$DISTRO-$VERSION"
- elif [ "$ARCH" == "x86_64" ]; then
- # EXTRA_FOLDER="tree"
- DISTRO="slamd64"
- DISTRO_FOLDER="$DISTRO-$VERSION"
- elif [ "$ARCH" == "s390" ]; then
- DISTRO="slack390"
- DISTRO_FOLDER="$DISTRO-$VERSION"
- elif [ "$ARCH" == "x86_uclibc" ]; then
- DISTRO="ucslack"
- DISTRO_FOLDER="$DISTRO-$VERSION"
- elif [ "$ARCH" == "arm" ]; then
- DISTRO="armedslack"
- DISTRO_FOLDER="$DISTRO-$VERSION"
- elif [ "$ARCH" == "powerpc" ]; then
- DISTRO="slackintosh"
- DISTRO_FOLDER="$VERSION"
- elif [ "$ARCH" == "sparc" ]; then
- DISTRO="splack"
- DISTRO_FOLDER="tree-$VERSION"
- else
- DISTRO="$ARCH"
- DISTRO_FOLDER="$DISTRO-$VERSION"
- fi
-
-}
-
-function simplaret_set_arch {
-
- # set correct value for ARCH
-
- local repos_type new_arch
-
- # any arch defined in ARCH_i386 that hasn't an entry
- # on $REPOS_CONF will be mapped to i386
-
- ARCH_i386=" nocona prescott pentium4m pentium4 pentium-m pentium3m pentium3 "
- ARCH_i386="$ARCH_i386 pentium2 i686 pentium-pro i586 pentium-mmx pentium i486 "
- ARCH_i386="$ARCH_i386 athlon-mp athlon-xp athlon4 athlon-tbird athlon k6 k6-2 "
- ARCH_i386="$ARCH_i386 k6-3 winchip-c6 winchip2 c3 c3-2 i386 "
-
- # any arch defined in ARCH_x86_64 that hasn't an entry
- # on $REPOS_CONF will be mapped to x86_64
-
- ARCH_x86_64=" k8 opteron athlon64 athlon-fx x86_64 "
-
- for repos_type in patches root repos noarch; do
- if [ -z "`simplaret_repository $repos_type`" ]; then
- # there's no repository definition for that arch
- if echo "$ARCH_i386" | grep -q " $ARCH "; then
- new_arch="i386"
- elif echo "$ARCH_x86_64" | grep -q " $ARCH "; then
- new_arch="x86_64"
- else
- echo "$BASENAME: error: no repository definition for arch $ARCH"
- echo "$BASENAME: please check your $CONF and $REPOS_CONF config files"
- exit 1
- fi
- else
- return
- fi
- done
-
- echo "$BASENAME: changing arch from $ARCH to $new_arch"
-
- ARCH="$new_arch"
-
-}
-
-function simplaret_check_url {
-
- # check if a given url exist, use just with small files
- # usage: simplaret_check_url <url>
-
- if [ -z "$1" ]; then
- return 1
- fi
-
- if [ ! -z "$CONNECT_TIMEOUT" ] || [ "$CONNECT_TIMEOUT" != "0" ]; then
- curl_timeout="--connect-timeout $CONNECT_TIMEOUT"
- fi
-
- if [ "`curl $curl_timeout -I $1 2> /dev/null | head -n 1 | awk '{ print $2 }'`" == "200" ]; then
- # server gave a 200 response, so the url exist
- return 0
- else
- # the url is missing
- return 1
- fi
-
-}
-
-function simplaret_solve_dep {
-
- # solve dependency for a package
- # this function was adapted from createpkg script
- # usage: simplaret_solve_dep <package-name> <package-depencency-name> [root-folder]
-
- local installed check exit_code
-
- local package="$1"
- local pack="$2"
- local root="/$3"
-
- pack="`echo $pack| sed -e 's/\+/\\\+/'`"
- installed=`eval "ls $root/var/log/packages/ | egrep -E '^$pack-[^-]+-[^-]+-[^-]+$'"`
- check=$?
-
- if [ -z "$installed" ]; then
- if [ $check -ne 0 ]; then
- echo "$BASENAME: processing $1 dependency $pack"
- # simplaret_install $pack
- SIMPLARET_CHILD=$SIMPLARET_CHILD ROOT=$root ARCH=$ARCH VERSION=$VERSION \
- simplaret --install $pack
- fi
- fi
-
-}
-
-if [ -z "$1" ]; then
- simplaret_usage
- exit 1
-else
- eval_config $BASENAME
-fi
-
-# This is used to show how many children process we have
-if [ -z "$SIMPLARET_CHILD" ]; then
- SIMPLARET_CHILD="1"
-else
- let SIMPLARET_CHILD++
-fi
-
-BASENAME="`basename $0`[$SIMPLARET_CHILD]"
-
-case $1 in
- "--update" | "update") simplaret_update ;;
- "--search" | "search") shift ; simplaret_search $* ;;
- "--get" | "get") shift ; simplaret_get $* ;;
- "--get-patches" | "get-patches") simplaret_get_patches ;;
- "--purge" | "purge") shift ; simplaret_purge $* ;;
- "--install" | "install") shift ; simplaret_install $* ;;
- "--upgrade" | "upgrade") simplaret_get_patches --upgrade ;;
- "--remove" | "remove") ROOT=/$ROOT removepkg $2 ;;
- *) simplaret_usage ;;
-esac
-
diff --git a/tags/0.5/src/templatepkg b/tags/0.5/src/templatepkg
deleted file mode 100755
index 4f2592f..0000000
--- a/tags/0.5/src/templatepkg
+++ /dev/null
@@ -1,980 +0,0 @@
-#!/bin/bash
-#
-# templatepkg v0.3: template maintenance script from simplepkg suite
-#
-# feedback: rhatto at riseup.net | gpl
-#
-# Templatepkg 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 any later version.
-#
-# Templatepkg 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
-#
-
-COMMON="/usr/libexec/simplepkg/common.sh"
-BASENAME="`basename $0`"
-
-if [ -f "$COMMON" ]; then
- source $COMMON
- eval_config $BASENAME
-else
- echo "error: file $COMMON found, check your $BASENAME installation"
- exit 1
-fi
-
-function usage_summary {
-
- echo "options are:"
- echo ""
- echo " -c | --create: create a template from a jail or existing template"
- echo " -u | --update: update a template from a jail"
- echo " -a | --add: add files into a template"
- echo " -d | --delete: delete files or folders from a template"
- echo " -s | --sync: sync $TEMPLATE_FOLDER working copy"
- echo " -e | --export: export $TEMPLATE_FOLDER to a svn repository"
- echo " -i | --import: grab $TEMPLATE_FOLDER from a svn repository"
- echo " -r | --remove: remove a template"
- echo " -l | --list: list templates"
- echo " -b | --batch-edit: add or edit post-installation scripts"
- echo " -p | --pack: create a package from a template"
- echo " -t | --template-edit: edit template package list"
- echo " -h | --help: display this summary"
- echo ""
-
-}
-
-function display_help {
-
- # display help
- # usage: help [help-topic]
-
- local option
-
- if [ -z "$1" ]; then
- echo "type $BASENAME --help <option> for aditional help"
- usage_summary
- exit
- fi
-
- option="$1"
-
- if ! echo $option | grep -q -e "^-"; then
- option="-`echo $option | sed -e 's/--/-/' -e 's/\(.\).*/\1/'`"
- else
- option="`echo $option | sed -e 's/--/-/' -e 's/\(..\).*/\1/'`"
- fi
-
- echo "$BASENAME: help for option $option:"
- echo ""
-
- usage_summary | grep -e "^ $option"
-
- echo ""
- case $option in
-
- "-c" | "--create")
- echo " $BASENAME $option <template> [jail-root|template-name]"
- ;;
- "-u" | "--update")
- echo " $BASENAME $option <template> [jail-root]"
- ;;
- "-a" | "--add")
- echo " $BASENAME $option <template> <file-name> [jail-root]"
- echo ""
- echo " file-name: the file or directory to be added"
- echo " jail-root: the jail under file-name is located"
- ;;
- "-d" | "--delete")
- echo " $BASENAME $option <template> <file-name> [jail-root]"
- echo ""
- echo " file-name: the file or directory to be removed"
- echo " jail-root: if specified, the file is also removed from the jail"
- ;;
- "-s" | "--sync")
- echo " $BASENAME $option"
- ;;
- "-e" | "--export")
- echo " $BASENAME $option <svn-repository>"
- ;;
- "-i" | "--import")
- echo " $BASENAME $option <svn-repository>"
- ;;
- "-r" | "--remove")
- echo " $BASENAME $option <template-name>"
- ;;
- "-l" | "--list")
- echo " $BASENAME $option [path]"
- ;;
- "-b" | "--batch-edit")
- echo " $BASENAME $option <template-name> <script-name>"
- ;;
- "-p" | "--pack")
- echo " $BASENAME $option <template-name> [version] [build] [arch]"
- ;;
- "-t" | "--template-edit")
- echo " $BASENAME $option <template-name>"
- ;;
- "-h" | "--help")
- echo " -h | --help: display this help."
- ;;
- *)
- echo $BASENAME: invalid help option $option
- esac
-
- case $option in
- "-c" | "-u" | "-a")
- echo ""
- echo " if ommited, jail-root defaults to /"
- ;;
- esac
-
- echo ""
-
-}
-
-function usage {
-
- echo "usage: $BASENAME <option> [<template> [arguments]]"
- usage_summary
- exit
-
-}
-
-function check_svn_repo {
-
- # check a svn repository URL
- # usage: set_svn_repo <repository>
-
- if [ ! -z "$1" ]; then
- if echo $1 | grep -q -v -e "^svn://"; then
- if echo $1 | grep -q -v -e "^svn+ssh://"; then
- if echo $1 | grep -q -v -e "^file://"; then
- echo $BASENAME: invalid repository URL $1
- return 1
- fi
- fi
- fi
- else
- echo $BASENAME: no repository defined
- return 1
- fi
-
-}
-
-function import_export_templates {
-
- # import from or export to $TEMPLATE_FOLDER in a svn repository
- # usage: template_export <import|export> <repository>
-
- local templates templates_folder basedir repository mode preposition
-
- if [ "$?" != 0 ]; then
- usage
- exit 1
- elif ! use_svn; then
- echo $BASENAME: simplepkg not configured to use svn
- exit 1
- fi
-
- templates_folder="$TEMPLATE_FOLDER"
- templates="`basename $TEMPLATE_FOLDER`"
- basedir="`dirname $templates_folder`"
- mode="$1"
- repository="$2"
- preposition="from"
-
- check_svn_repo $repository
-
- if [ ! -z "$2" ]; then
-
- if [ ! -d "$templates_folder/.svn" ]; then
-
- cd $basedir
-
- if [ "$mode" == "export" ]; then
- preposition="to"
- echo Exporting templates to $repository...
- svn import $templates/ $repository/ -m "initial import"
- if [ "$?" != "0" ]; then
- echo $BASENAME: export failed
- exit 1
- fi
- fi
-
- if [ -d "templates" ]; then
- mv $templates $templates.old
- fi
-
- echo Checking out templates from $repository...
- svn checkout $repository $templates
-
- if [ "$?" == "0" ]; then
- rm -rf $templates.old
- else
- rm -rf $templates
- mv $templates.old $templates
- echo $BASENAME: $mode failed
- exit 1
- fi
-
- else
- echo "$BASENAME: $templates_folder seens to be already $mode""ed $preposition $repository"
- exit 1
- fi
-
- fi
-
-}
-
-function template_create {
-
- # create a new template
-
- local template_base info_commit orig_template list
-
- if [ ! -d "`dirname $TEMPLATE_BASE`" ]; then
-
- echo Creating template `basename $TEMPLATE_BASE`...
-
- if use_svn && [ -d "`dirname $TEMPLATE_BASE`/.svn" ]; then
- cd `dirname $TEMPLATE_BASE`
- svn mkdir `dirname $TEMPLATE_BASE`
- else
- mkdir -p `dirname $TEMPLATE_BASE`
- fi
-
- else
- echo $BASENAME: template `basename $TEMPLATE_BASE` already exists
- exit 1
- fi
-
- touch $TEMPLATE_BASE.perms
- touch $TEMPLATE_BASE.template
-
- if use_svn && [ -d "`dirname $TEMPLATE_BASE`/.svn" ]; then
-
- cd `dirname $TEMPLATE_BASE`
-
- if ! svn_check $TEMPLATE_BASE.d; then
- svn mkdir $TEMPLATE_BASE.d
- info_commit="yes"
- else
- mkdir -p $TEMPLATE_BASE.d
- fi
-
- if ! svn_check $TEMPLATE_BASE.s; then
- svn mkdir $TEMPLATE_BASE.s
- info_commit="yes"
- else
- mkdir -p $TEMPLATE_BASE.s
- fi
-
- if ! svn_check $TEMPLATE_BASE.template; then
- svn add $TEMPLATE_BASE.template
- info_commit="yes"
- fi
-
- if ! svn_check $TEMPLATE_BASE.perms; then
- svn add $TEMPLATE_BASE.perms
- info_commit="yes"
- fi
-
- elif use_svn && [ -d "$TEMPLATE_FOLDER/.svn" ]; then
-
- mkdir $TEMPLATE_BASE.{d,s}
- cd $TEMPLATE_FOLDER
- svn add `basename $TEMPLATE_BASE`
- info_commit="yes"
-
- else
- mkdir $TEMPLATE_BASE.{d,s}
- fi
-
- if [ -d "/$ROOT" ]; then
- template_update
- elif [ ! -z "$ROOT" ]; then
-
- # copy from an existing template
-
- if [ -d "$TEMPLATE_FOLDER/$ROOT" ]; then
- orig_template="$TEMPLATE_FOLDER/$ROOT"
- elif [ -d "$BASE_CONF/templates/$ROOT" ]; then
- orig_template="$BASE_CONF/templates/$ROOT"
- elif [ -d "$BASE_CONF/defaults/templates/$ROOT" ]; then
- orig_template="$BASE_CONF/defaults/templates/$ROOT"
- else
- return 1
- fi
-
- if [ -f "$orig_template/$ROOT.perms" ]; then
- cat $orig_template/$ROOT.perms > $TEMPLATE_BASE.perms
- fi
-
- if [ -f "$orig_template/$ROOT.template" ]; then
- cat $orig_template/$ROOT.template > $TEMPLATE_BASE.template
- fi
-
- if use_svn && [ -d "$orig_template/.svn" ]; then
-
- cd `dirname $TEMPLATE_BASE`
-
- list="`ls $orig_template/$ROOT.d/ 2> /dev/null`"
- if [ ! -z "$list" ]; then
- echo Copying files to the new template...
- rsync -av --exclude=.svn $orig_template/$ROOT.d/ $TEMPLATE_BASE.d/
- svn add `basename $TEMPLATE_BASE`.d/*
- info_commit="yes"
- fi
-
- list="`ls $orig_template/$ROOT.s/ 2> /dev/null`"
- if [ ! -z "$list" ]; then
- echo Copying scripts to the new template...
- rsync -av --exclude=.svn $orig_template/$ROOT.s/ $TEMPLATE_BASE.s/
- svn add `basename $TEMPLATE_BASE`.s/*
- info_commit="yes"
- fi
-
- else
-
- list="`ls $orig_template/$ROOT.d/ 2> /dev/null`"
- if [ ! -z "$list" ]; then
- echo Copying files to the new template...
- rsync -av $orig_template/$ROOT.d/ $TEMPLATE_BASE.d/
- fi
-
- list="`ls $orig_template/$ROOT.s/ 2> /dev/null`"
- if [ ! -z "$list" ]; then
- echo Copying scripts to the new template...
- rsync -av $orig_template/$ROOT.s/ $TEMPLATE_BASE.s/
- fi
-
- fi
-
- else
- echo $BASENAME: warning: no root directory defined
- fi
-
- if [ "$info_commit" == "yes" ] && [ -z "$SILENT" ]; then
- echo "Please run 'jail-commit --all' to add files under $file into the svn repository"
- fi
-
-}
-
-function template_update {
-
- # update the template package list
-
- check_template_exist
-
- if [ ! -d "$ROOT/var/log/packages" ]; then
- echo $ROOT/var/log/packages: directory not found
- exit 1
- fi
-
- echo Checking package list for template `basename $TEMPLATE_BASE`...
-
- for package in `ls -1 $ROOT/var/log/packages/`; do
- pack=`package_name $package`
- if [ -f $TEMPLATE ]; then
- if ! `grep -v -e "^#" $TEMPLATE | cut -d : -f 1 | awk '{ print $1 }' | grep -q -e "^$pack\$"`; then
- echo $pack >> $TEMPLATE
- echo Added $pack # on $TEMPLATE
- fi
- else
- echo $pack >> $TEMPLATE
- echo Added $pack # on $TEMPLATE
- fi
- done
-
- # check if each package from the template is installed
- grep -v -e "^#" $TEMPLATE | cut -d : -f 1 | awk '{ print $1 }' | while read pack; do
-
- if [ ! -z "$pack" ]; then
- unset found
- for candidate in `ls $ROOT/var/log/packages/$pack* 2> /dev/null`; do
- candidate="`package_name $candidate`"
- if [ "$pack" == "$candidate" ]; then
- found="1"
- break
- fi
- done
- if [ "$found" != "1" ]; then
- # remove a non-installed package from the template
- sed "/^$pack$/d" $TEMPLATE | sed "/^$pack $/d" | sed "/^$pack:*/d" | sed "/^$pack */d" > $TEMPLATE.tmp
- cat $TEMPLATE.tmp > $TEMPLATE
- rm -f $TEMPLATE.tmp
- echo Removed $pack # from $TEMPLATE
- fi
- fi
-
- done
-
- if ! svn_check $TEMPLATE_BASE.template && [ -d "`dirname $TEMPLATE_BASE`/.svn" ]; then
- cd `dirname $TEMPLATE_BASE`
- svn add `basedir $TEMPLATE_BASE`.template
- fi
-
-}
-
-function template_add {
-
- # add a file in a template
- # usage: template_add <jail-root> <file>
-
- local info_commit cwd
-
- if [ -z "$1" ] || [ -z "$2" ]; then
- return 1
- fi
-
- check_template_exist
-
- jail="/$1"
- file="$2"
-
- if [ -a "$TEMPLATE_BASE.d/$file" ]; then
- if [ -d "$TEMPLATE_BASE.d/$file" ]; then
-
- echo $BASENAME: folder `slash $file` already on $TEMPLATE_BASE.d, checking for contents
-
- cd $jail
- for candidate in `find $file`; do
- if [ ! -a "$TEMPLATE_BASE.d/$candidate" ]; then
- mkdir -p $TEMPLATE_BASE.d/`dirname $candidate`
- cp -a $jail/$candidate $TEMPLATE_BASE.d/$candidate
- if use_svn && [ -d "$TEMPLATE_BASE.d/.svn" ]; then
- cwd="`pwd`"
- cd $TEMPLATE_BASE.d
- svn add ./$candidate
- if [ "$?" != "0" ]; then
- echo $BASENAME: error adding `slash $candidate` into the revision system
- fi
- cd $cwd
- info_commit="yes"
- else
- echo Added `slash $jail/$candidate` on `slash $TEMPLATE_BASE.d/$candidate`
- fi
- fi
- done
-
- if [ "$info_commit" == "yes" ] && [ -z "$SILENT" ]; then
- echo "Please run 'jail-commit --all' to add files under `slash $file` into the svn repository"
- fi
-
- else
- echo $BASENAME: file `slash $file` already on $TEMPLATE_BASE.d
- exit 1
- fi
- else
-
- if [ -a "$jail/$file" ]; then
-
- destination="`echo $TEMPLATE_BASE.d/$file | sed -e 's/\/$//'`"
-
- if use_svn && [ -d "$TEMPLATE_BASE.d/.svn" ]; then
-
- if [ ! -d "$TEMPLATE_BASE.d/`dirname $file`/.svn" ]; then
- mkdir -p $TEMPLATE_BASE.d/`dirname $file`/
- svn add $TEMPLATE_BASE.d/`dirname $file`/
- fi
-
- cp -a $jail/$file $destination
-
- cwd="`pwd`"
- cd $TEMPLATE_BASE.d
- svn add ./$file
-
- if [ "$?" != "0" ]; then
- echo $BASENAME: error adding `slash $candidate` into the revision system
- else
- if [ -z "$SILENT" ]; then
- echo "Please run 'jail-commit --all' to add `slash $file` into the svn repository"
- fi
- fi
-
- cd $cwd
-
- else
-
- mkdir -p $TEMPLATE_BASE.d/`dirname $file`/
- cp -a $jail/$file $destination
- echo Added `slash $jail/$file` on `slash $destination`
-
- fi
-
- else
- echo $BASENAME: `slash $jail/$file`: file not found
- exit 1
- fi
- fi
-
-}
-
-function check_template_exist {
-
- # check if a template exists
- # and create missing components
-
- local components
-
- components="template perms d s"
-
- if [ ! -d "`dirname $TEMPLATE_BASE`" ]; then
- echo $BASENAME: template not found
- exit 1
- fi
-
- for component in $components; do
-
- if [ ! -e "$TEMPLATE_BASE.$component" ]; then
-
- echo "$BASENAME: template component not found: $TEMPLATE_BASE.$component; creating..."
-
- cd `dirname $TEMPLATE_BASE`
-
- if [ "$component" == "perms" ] || [ "$component" == "template" ]; then
- touch $TEMPLATE_BASE.$component
- else
- mkdir $TEMPLATE_BASE.$component
- fi
-
- if use_svn && [ -d "`dirname $TEMPLATE_BASE`/.svn" ]; then
- svn add $TEMPLATE_BASE.$component
- info_commit="yes"
- fi
-
- elif use_svn && [ -d "`dirname $TEMPLATE_BASE`/.svn" ] && \
- ! svn_check $TEMPLATE_BASE.$component; then
-
- cd `dirname $TEMPLATE_BASE`
- svn add $TEMPLATE_BASE.$component
- info_commit="yes"
-
- fi
-
- done
-
- if [ "$info_commit" == "yes" ] && [ -z "$SILENT" ]; then
- echo "Please run 'jail-commit --all' to add new files in the svn repository"
- fi
-
-}
-
-function template_delete {
-
- # delete a file from a template
- # usage: template_delete <file> [jail-root]
-
- if [ -e "$TEMPLATE_BASE.d/$1" ]; then
-
- # first try to remove the file from the template
- if use_svn && [ -d "$TEMPLATE_BASE.d/.svn" ]; then
- cd $TEMPLATE_BASE.d
- svn del --force ./$1 || rm -rf ./$1
- if [ -z "$SILENT" ]; then
- echo "Please run 'jail-commit --all' to del $1 in the svn repository"
- fi
- else
- rm -rf $TEMPLATE_BASE.d/$1
- echo Removed $1 from $TEMPLATE_BASE.d
- fi
-
- # then, if requested, remove the file from the jail
- if [ ! -z "$2" ]; then
- if [ ! -d "$2" ]; then
- echo $BASENAME: jail not found: $2
- elif [ -e "$2/$1" ]; then
- rm -rf $2/$1
- echo Removed $1 from jail $2
- else
- echo $BASENAME: file not found: $2/$1
- fi
- fi
-
- elif [ -e "$TEMPLATE_BASE.s/$1" ]; then
- if use_svn && [ -d "$TEMPLATE_BASE.s/.svn" ]; then
- cd $TEMPLATE_BASE.s
- svn del --force ./$1 || rm -rf ./$1
- if [ -z "$SILENT" ]; then
- echo "Please run 'jail-commit --all' to del $1 in the svn repository"
- fi
- else
- rm -rf $TEMPLATE_BASE.s/$1
- echo Removed $1 from $TEMPLATE_BASE.s
- fi
- else
- if [ ! -d "$TEMPLATE_BASE.d" ]; then
- echo $BASENAME: template folder $TEMPLATE_BASE.d not found
- else
- echo $BASENAME: file $1 not found at $TEMPLATE_BASE.d
- fi
- exit 1
- fi
-
-}
-
-function template_remove {
-
- # remove a template
- # usage: template_remove
-
- local basedir template
-
- basedir="`dirname $TEMPLATE_BASE`"
- template="`basename $basedir`"
-
- if [ ! -d "$basedir" ]; then
- echo $BASENAME: template $template does not exist
- exit 1
- fi
-
- if use_svn && [ -d "$basedir/.svn" ]; then
- cd $TEMPLATE_FOLDER
- svn update
- svn del --force $template
- if [ "$?" != "0" ]; then
- echo $BASENAME: error deleting template $template
- else
- svn commit -m "deleted $template"
- if [ "$?" != "0" ]; then
- echo $BASENAME: error commiting to svn repository
- fi
- fi
- else
- rm -rf $basedir
- fi
-
-}
-
-function template_list {
-
- # list templates
- # usage: template_list [path]
-
- local list basedir template
-
- if [ "$TEMPLATE_STORAGE_STYLE" != "own-folder" ]; then
- echo "$BASENAME: option only available if TEMPLATE_STORAGE_STYLE configured as 'own-folder'"
- return 1
- fi
-
- if echo $1 | grep -q "/" || [ ! -z "$1" ]; then
-
- template="`echo $1 | cut -d "/" -f 1`"
-
- if [ -e "$BASE_CONF/defaults/templates/$1" ]; then
- list="`ls $BASE_CONF/defaults/templates/$1 2> /dev/null`"
- if [ "$?" == "0" ]; then
- list="`echo $list | xargs`"
- echo "In the default template $template: $list"
- fi
- fi
-
- if [ -e "$TEMPLATE_FOLDER/$1" ]; then
- list="`ls $TEMPLATE_FOLDER/$1 2> /dev/null`"
- if [ "$?" == "0" ]; then
- list="`echo $list | xargs`"
- echo "In the custom template $template: $list"
- fi
- fi
-
- else
-
- list="`ls $BASE_CONF/defaults/templates/$1 2> /dev/null`"
- if [ "$?" == "0" ]; then
- list="`echo $list | xargs`"
- echo "Default templates: $list"
- fi
-
- list="`ls $TEMPLATE_FOLDER/$1 2> /dev/null`"
- if [ "$?" == "0" ]; then
- list="`echo $list | xargs`"
- echo "Custom templates: $list"
- fi
-
- fi
-
-}
-
-function template_post_install_edit {
-
- # add or edit a post-installation script
- # usage: template_post_install_edit <script-name>
-
- if [ -z "$1" ]; then
- echo $BASENAME: no template specified
- exit 1
- elif echo $1 | grep -q "/"; then
- echo $BASENAME: error: invalid script name $1
- fi
-
- if [ -f "$TEMPLATE_BASE.s/$1" ]; then
- sha1sum="`sha1sum $TEMPLATE_BASE.s/$1`"
- if [ ! -z "$EDITOR" ]; then
- $EDITOR $TEMPLATE_BASE.s/$1
- else
- vi $TEMPLATE_BASE.s/$1
- fi
- if [ "$sha1sum" != "`sha1sum $TEMPLATE_BASE.s/$1`" ] && \
- [ -d "`dirname $TEMPLATE_BASE`/.svn" ] && [ -z "$SILENT" ]; then
- echo "Please run 'jail-commit --all' to send changes to the repository"
- fi
- else
-
- if [ -e "$TEMPLATE_BASE.s/$1" ]; then
-
- echo $BASENAME: file $TEMPLATE_BASE.s/$1 not a regular file
-
- elif [ -d "$TEMPLATE_BASE.s" ]; then
-
- touch $TEMPLATE_BASE.s/$1
- chmod +x $TEMPLATE_BASE.s/$1
-
- if [ -d "$TEMPLATE_BASE.s/.svn" ]; then
- cd $TEMPLATE_BASE.s
- svn add $1
- if [ -z "$SILENT" ]; then
- echo "Please run 'jail-commit --all' to send the script to the repository"
- fi
- fi
-
- echo "$BASENAME: script created; run templatepkg -p `basename $TEMPLATE_BASE` $1 again to edit it"
-
- else
- echo $BASENAME: folder not found: $TEMPLATE_BASE.s
- fi
-
- fi
-
-}
-
-function template_edit {
-
- # edit a template package list
- # usage: template_edit
-
- if [ -f "$TEMPLATE_BASE.template" ]; then
- sha1sum="`sha1sum $TEMPLATE_BASE.template`"
- if [ ! -z "$EDITOR" ]; then
- $EDITOR $TEMPLATE_BASE.template
- else
- vi $TEMPLATE_BASE.template
- fi
- if [ "$sha1sum" != "`sha1sum $TEMPLATE_BASE.template`" ] && \
- [ -d "`dirname $TEMPLATE_BASE`/.svn" ] && [ -z "$SILENT" ]; then
- echo "Please run 'jail-commit --all' to send changes to the repository"
- fi
- elif [ -e "$TEMPLATE_BASE.template" ]; then
- echo $BASENAME: file $TEMPLATE_BASE.template not a regular file
- else
- echo $BASENAME: file not found: $TEMPLATE_BASE.template
- fi
-
-}
-
-function require {
-
- # requires a string
- # usage: require [string]
-
- if [ -z "$1" ]; then
- usage
- fi
-
-}
-
-function setroot {
-
- # set ROOT variable
- # usage: setroot <value1> <value2>
-
- if [ -z "$1" ]; then
- ROOT="/"
- else
- ROOT="$1"
- fi
-
-}
-
-function create_doinst {
-
- # create a doinst.sh from a template.perms file
- # usage: create_doinst <doinst-path>
-
- rm -f $1/doinst.sh
-
- if [ -s "$TEMPLATE_BASE.perms" ]; then
- echo Creating doinst.sh...
- cat $TEMPLATE_BASE.perms | while read entry; do
- file="`echo $entry | cut -d ";" -f 1`"
- if [ -e "$TEMPLATE_BASE.d/$file" ]; then
- owner="`echo $entry | cut -d ";" -f 2`"
- group="`echo $entry | cut -d ";" -f 3`"
- perms="`echo $entry | cut -d ";" -f 4`"
- echo "( chmod $perms /$file )" >> $1/doinst.sh
- echo "( chown $owner:$group /$file )" >> $1/doinst.sh
- fi
- done
- fi
-
-}
-
-function package_template {
-
- # make a package from a template
- # usage: package_template [version] [build] [arch]
-
- local template version build arch
-
- template="`basename $TEMPLATE_BASE`"
-
- if [ ! -d "$TEMPLATE_BASE.d" ]; then
- $BASENAME: folder not found: $TEMPLATE.base.d
- return 1
- fi
-
- echo Buiding package for template $template...
-
- if [ -z "$1" ]; then
- version="1"
- else
- version="$1"
- fi
-
- if [ -z "$2" ]; then
- build="1"
- else
- build="$2"
- fi
-
- if [ -z "$3" ]; then
- arch="noarch"
- else
- arch="$3"
- fi
-
- TMP=${TMP:=/tmp}
- rm -rf $TMP/templatepkg
- mkdir -p $TMP/templatepkg
-
- rsync -av --exclude=.svn $TEMPLATE_BASE.d/ $TMP/templatepkg/
- mkdir $TMP/templatepkg/install
- create_doinst $TMP/templatepkg/install
-
- echo "template-$template: template-$template" > $TMP/templatepkg/install/slack-desc
- echo "template-$template: " >> $TMP/templatepkg/install/slack-desc
- echo "template-$template: simplepkg template $template" >> $TMP/templatepkg/install/slack-desc
-
- for ((n=1;n<=8;n++)); do
- echo "template-$template: " >> $TMP/templatepkg/install/slack-desc
- done
-
- cd $TMP/templatepkg
-
- makepkg -c n -l y $TMP/template-$template-$version-noarch-$build.tgz
-
- cd $TMP
- rm -rf templatepkg
-
-}
-
-# -----------------------------------------------------
-# main
-# -----------------------------------------------------
-
-if [ ! -z "$2" ]; then
- search_template $2 --new
-fi
-
-TEMPLATE="$TEMPLATE_BASE.template"
-
-if [ "$1" == "-u" ] || [ "$1" == "--update" ]; then
-
- require $2
- setroot $3
- template_update
-
-elif [ "$1" == "-c" ] || [ "$1" == "--create" ]; then
-
- require $2
- setroot $3
- template_create
-
-elif [ "$1" == "-a" ] || [ "$1" == "--add" ]; then
-
- require $2
-
- if [ -z "$3" ]; then
- usage
- else
- setroot $4
- fi
-
- template_add $ROOT $3
-
-elif [ "$1" == "-d" ] || [ "$1" == "--delete" ]; then
-
- require $2
-
- if [ -z "$3" ]; then
- usage
- else
- template_delete $3 $4
- fi
-
-elif [ "$1" == "-s" ] || [ "$1" == "--sync" ]; then
-
- if use_svn && [ -d "$TEMPLATE_FOLDER/.svn" ]; then
- ( cd $TEMPLATE_FOLDER && svn update )
- true
- fi
-
-elif [ "$1" == "-e" ] || [ "$1" == "--export" ]; then
-
- require $2
- import_export_templates export $2
-
-elif [ "$1" == "-i" ] || [ "$1" == "--import" ]; then
-
- require $2
- import_export_templates import $2
-
-elif [ "$1" == "-r" ] || [ "$1" == "--remove" ]; then
-
- require $2
- template_remove
-
-elif [ "$1" == "-l" ] || [ "$1" == "--list" ]; then
-
- template_list $2
-
-elif [ "$1" == "-b" ] || [ "$1" == "--batch-edit" ]; then
-
- require $3
- template_post_install_edit $3
-
-elif [ "$1" == "-t" ] || [ "$1" == "--template-edit" ]; then
-
- require $2
- template_edit
-
-elif [ "$1" == "-p" ] || [ "$1" == "--pack" ]; then
-
- require $2
- shift ; shift
- package_template $*
-
-elif [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
-
- display_help $2
-
-else
- usage
-fi
-