aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/createpkg480
-rwxr-xr-xsrc/jail-commit93
-rwxr-xr-xsrc/lspkg88
-rwxr-xr-xsrc/metapkg60
-rwxr-xr-xsrc/mkjail150
-rwxr-xr-xsrc/rebuildpkg87
-rwxr-xr-xsrc/repos135
-rwxr-xr-xsrc/simplaret997
-rwxr-xr-xsrc/templatepkg220
9 files changed, 0 insertions, 2310 deletions
diff --git a/src/createpkg b/src/createpkg
deleted file mode 100644
index 5ab979f..0000000
--- a/src/createpkg
+++ /dev/null
@@ -1,480 +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="/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
-#---------------------------------------------------
-
-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 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) echo -e "$CL_ALERT $BASENAME: could not update the repository $2 $CL_OFF" ;;
- 4) echo -e "$CL_ALERT $BASENAME: could not create folder $2 $CL_OFF" ;;
- 5) echo -e "$CL_ALERT $BASENAME: script not found for $2 $CL_OFF" ;;
- $ERROR_WGET)
- echo -e "$CL_ERROR $BASENAME: error downloading source/package for $2 $CL_OFF" ;;
- $ERROR_MAKE)
- echo -e "$CL_ERROR $BASENAME: error compiling $2 source code $CL_OFF" ;;
- $ERROR_INSTALL)
- echo -e "$CL_ERROR $BASENAME: error installing $2 $CL_OFF" ;;
- $ERROR_MD5)
- echo -e "$CL_ERROR $BASENAME: error on source code integrity check for $2 $CL_OFF" ;;
- $ERROR_CONF)
- echo -e "$CL_ERROR $BASENAME: error configuring the source code for $2 $CL_OFF" ;;
- $ERROR_HELP)
- exit 0 ;; # its supposed to never happen here :P
- $ERROR_TAR)
- echo -e "$CL_ERROR $BASENAME: error decompressing source code for $2 $CL_OFF" ;;
- $ERROR_MKPKG)
- echo -e "$CL_ERROR $BASENAME: error creating package $2 $CL_OFF" ;;
- $ERROR_GPG)
- echo -e "$CL_ERROR $BASENAME: error verifying GPG signature the source code for $2 $CL_OFF" ;;
- $ERROR_PATCH)
- echo -e "$CL_ERROR $BASENAME: error patching the source code for $2 $CL_OFF" ;;
- $ERROR_VCS)
- echo -e "$CL_ERROR $BASENAME: error downloading $2 source from version control system $CL_OFF" ;;
- $ERROR_MKDIR)
- echo -e "$CL_ERROR $BASENAME: make directory $2 error, aborting $CL_OFF" ;;
- $ERROR_INSTPKG)
- echo -e "$CL_ERROR $BASENAME: install package $2 error, aborting $CL_OFF" ;;
- $ERROR_DEPEN)
- echo -e "$CL_ERROR $BASENAME: dependency solve error, aborting $CL_OFF" ;;
- *) echo -e "$CL_ERROR $BASENAME: unknown error or user interrupt $CL_OFF" ;;
- $SCRIPT_OR_PACKAGE_NOT_FOUND)
- echo -e "$CL_ERROR $BASENAME: SlackBuild or package not found $CL_OFF" ;;
- esac
-
- exit $1
-
-}
-
-function build_repo {
-
- # Checkout a new slackbuild working copy
- BASEDIR="`dirname $SLACKBUILDS`"
- mkdir -p $BASEDIR || handle_error 4 $BASEDIR
- cd $BASEDIR
- svn checkout $SVN
- cd $SLACKBUILDS
-
-}
-
-function usage {
-
- # Help mensage
- echo -e "$CL_COMMU Usage: createpkg [--install/-i] package-name $CL_OFF"
- echo -e "$CL_COMMU createpkg --no-deps/-np package-name $CL_OFF"
- echo -e "$CL_COMMU createpkg --search/-s package-name $CL_OFF"
- echo -e "$CL_COMMU createpkg --info/-f package-name $CL_OFF"
- echo -e "$CL_COMMU createpkg --list/-l $CL_OFF"
- echo -e "$CL_COMMU createpkg --sync $CL_OFF"
- echo -e "$CL_COMMU createpkg --help/-h $CL_OFF"
-
-}
-
-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=${SLACKBUILDS:=/var/slackbuilds}
- SVN=${SVN:=svn://slack.sarava.org/slackbuilds}
- SYNC=${SYNC:=no}
- BASEDIR="`dirname $SLACKBUILDS`"
-
-}
-
-function solve_dep {
- # Solve dependency
- local PACK="$1"
- local COND="$2"
- local VER="$3"
-
- # Check package in local system
- INSTALLED=`eval "ls /var/log/packages/ | egrep '^$PACK-[^-]+-[^-]+-[^-]+$'"`
- CHECK=$?
-
- # TODO: Make check version procedures
- if [ -z "$INSTALLED" ]; then
- if [ $CHECK -ne 0 ]; then
- # Check package in SlackBuilds tree
- echo -e "$CL_MENSG $BASENAME: processing $PACKAGE dependency $PACK $CL_OFF"
- 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" ] && build_repo
-
-}
-
-function sync_repo {
-
- # Synchronize repository
- cd $SLACKBUILDS
- svn update || build_repo
- #simplaret --update
-
-}
-
-function find_slackbuild {
-
- # Find SlackBuild script in the repository
- find $SLACKBUILDS -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]`
- echo -e "$CL_COMMU $NAME_UP: $CL_OFF"
-
- PKG_DIR=`dirname $i`
- if [ -e $PKG_DIR/slack-desc ]; then
- eval "cat $PKG_DIR/slack-desc | grep '^$PACKAGE:' | cut -f2- -d:"
- echo -e "$CL_OFF"
- else
- eval "cat $i | grep '^$PACKAGE:' | cut -f2- -d:"
- echo -e "$CL_OFF"
- fi
-
- if [ -e $PKG_DIR/slack-required ]; then
- echo -e "$CL_COMMU slack-required $CL_OFF"
- cat $PKG_DIR/slack-required | sed 's/^/ /'
- fi
- done
- fi
-
-}
-
-function list_builds {
-
- # List all available SlackBuilds
- cd $SLACKBUILDS
- 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
- echo -e "$CL_COMMU $j $CL_OFF"
- (
- cd $j
- BUILD="`ls *.SlackBuild 2>/dev/null`"
- if [ "$BUILD" != "" ]; then
- # level 3
- for k in $BUILD; do
- echo -e "$CL_MENSG $k $CL_OFF"
- done
- else
- BUILD=""
- fi
- for k in *; do
- if [ -d $k ]; then
- echo -e "$CL_MENSG $k.SlackBuild $CL_OFF"
- fi
- done
- )
- fi
- done
- )
- fi
- done
-}
-
-function color_select {
- # Select color mode: gray, color or none (*)
- # CL_COMMU - Communication
- # CL_MENSG - Commum messages
- # CL_ERROR - Error messages
- # CL_OFF - turn off color
- case "$1" in
- 'gray')
- CL_COMMU="\033[37;1m"
- CL_MENSG="\033[37;1m"
- CL_ERROR="\033[30;1m"
- CL_ALERT="\033[37m"
- CL_OFF="\033[m"
- ;;
- 'color')
- CL_COMMU="\033[34;1m" # green
- CL_MENSG="\033[32;1m" # blue
- CL_ERROR="\033[31;1m" # red
- CL_ALERT="\033[33;1m" # yellow
- CL_OFF="\033[m" # normal
- ;;
- *)
- CL_COMMU=""
- CL_MENSG=""
- CL_ERROR=""
- CL_ALERT=""
- CL_OFF=""
- ;;
- 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
- echo -e "$CL_ERROR error: file $COMMON not found, check your $BASENAME installation $CL_OFF"
- 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`"
-
-# 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
- echo -e "$CL_ERROR error: None package select $CL_OFF"
- 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/'`
-fi
-
-# Check SlackBuild script found
-[ -z "$BUILD_SCRIPT" ] && handle_error 5 $PACKAGE
-
-# Get dirname and script name from slackbuild
-SCRIPT_BASE="`dirname $BUILD_SCRIPT`"
-SCRIPT_NAME="`basename $BUILD_SCRIPT`"
-echo -e "$CL_MENSG $BASENAME: found script $PACKAGE.SlackBuild, now checking for dependencies $CL_OFF"
-
-# 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
- ( cat $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
- echo -e "$CL_MENSG $BASENAME: dependency solve error $CL_OFF"
- exit 1
- fi
- echo -e "$CL_MENSG $BASENAME: done checking for $PACKAGE dependencies $CL_OFF"
-else
- echo -e "$CL_MENSG $BASENAME: no unmet dependencies for $PACKAGE $CL_OFF"
-fi
-
-echo -e "$CL_MENSG $BASENAME: processing $SCRIPT_NAME $CL_OFF"
-
-# Built package
-cd $SCRIPT_BASE
-# Execute SlackBuild script with variables protection
-( INTERACT=no ./$SCRIPT_NAME )
-
-# Check if package was built
-handle_error $? $PACKAGE
-
-PKG_TGZ="`ls -1 -c $REPOS/$PACKAGE-*-*-*tgz | head -n 1`"
-
-#mkdir -p $REPOS${SCRIPT_BASE/$SLACKBUILDS}
-#mv $PKG_TGZ $REPOS${SCRIPT_BASE/$SLACKBUILDS}/
-
-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/src/jail-commit b/src/jail-commit
deleted file mode 100755
index 8de547c..0000000
--- a/src/jail-commit
+++ /dev/null
@@ -1,93 +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"
-
-if [ -f "$COMMON" ]; then
- source $COMMON
-else
- echo "error: file $COMMON found, check your `basename $0` installation"
- exit 1
-fi
-
-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
-
- rm -f $TEMPLATE_BASE.perms
- touch $TEMPLATE_BASE.perms
- cd $TEMPLATE_BASE.d
-
- for file in `find`; do
- if [[ -f "$file" && -f "$1/$file" ]]; then
- if ! diff $file $1/$file; then
- echo updating $file
- cp -af $1/$file $file
- fi
- perms="`numeric_perm $1/$file`"
- owner="`get_owner $1/$file`"
- group="`get_group $1/$file`"
- echo "$file;$owner;$group;$perms" >> $TEMPLATE_BASE.perms
- fi
- done
-
-}
-
-function template_svn_commit {
-
- if [ "$TEMPLATES_UNDER_SVN" == "1" ] && \
- [ "$TEMPLATE_STORAGE_STYLE" == "own-folder" ]; then
- cd `basedir $TEMPLATE_BASE`
- svn commit -m "changes for `date`"
- fi
-
-}
-
-if [ -f $JAIL_LIST ]; then
- for jailpath in `cat $JAIL_LIST`; do
- jail="`basename $jailpath`"
- search_template $jail --update
- if [ "$?" == "0" ]; then
- echo updating $jailpath...
- if [ -d "$TEMPLATE_BASE.d" ] || [ -a "$TEMPLATE_BASE.template" ]; then
- templatepkg -u $jail $jailpath
- template_merge $jailpath
- template_svn_commit $TEMPLATE_BASE
- fi
- fi
- done
-fi
-
-# main jail
-search_template main --update
-if [ "$?" == "0" ]; then
- if [ -a "$TEMPLATE_BASE.template" ] || [ -a "$TEMPLATE_BASE.template" ]; then
- echo updating main installation...
- templatepkg -u main
- template_merge /
- template_svn_commit $TEMPLATE_BASE
- fi
-fi
-
diff --git a/src/lspkg b/src/lspkg
deleted file mode 100755
index e3add47..0000000
--- a/src/lspkg
+++ /dev/null
@@ -1,88 +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 found, check your `basename $0` installation"
- exit 1
-fi
-
-function usage {
- echo "usage: `basename $0` [option expression]"
-}
-
-if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
- usage
- 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
-"
-elif [ "$1" == "-v" ] || [ "$1" == "--view" ] ; then
- if [ ! -z "$2" ]; then
- if $(ls /var/log/packages/$2* &> /dev/null); then
- for file in $(ls /var/log/packages/$2*); do
- less $file
- done
- else echo $2: package not found on /var/log/packages
- fi
- else
- usage
- exit 1
- fi
-elif [ "$1" == "-p" ] && [ "$1" == "--print" ]; then
- if [ -f "$2" ]; then
- tar ztvf $2
- else echo $2: file not found
- fi
-elif [ "$1" == "-r" ] && [ "$1" == "--remove" ]; then
- if [ ! -z "$2" ]; then
- if `ls /var/log/packages/$1* &> /dev/null`; then
- removepkg /var/log/packages/$1*
- fi
- fi
-elif [ "$1" == "-s" ] || [ "$1" == "--search" ]; then
- if [ ! -z "$2" ]; then
- grep $2 /var/log/packages/*
- fi
-elif [ "$1" == "-d" ] || [ "$1" == "--description" ]; then
- if [ ! -z "$1" ]; then
- for file in `lspkg $2`; do
- name="`package_name $file.tgz`"
- echo "package description for $name:"
- echo ""
- grep -e "^$name:" $file | sed -e "s/^$name:/ /"
- done
- else
- usage
- exit 1
- fi
-else
- if `ls /var/log/packages/$1* &> /dev/null`; then
- ls /var/log/packages/$1*
- else echo $1: package not found on /var/log/packages
- fi
-fi
diff --git a/src/metapkg b/src/metapkg
deleted file mode 100755
index e83ee4d..0000000
--- a/src/metapkg
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/bash
-#
-# metapkg v0.1: install or remove a pkgtool metapackage
-#
-# feedback: rhatto at riseup.net | GPL
-#
-# Metapkg 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.
-#
-# Metapkg 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
-#
-# A metapackage is a file containing a list of packages.
-# This script just installs all the packages in a metapackage.
-# Remeber that mkjail template == metapkg metapackage.
-#
-
-COMMON="/usr/libexec/simplepkg/common.sh"
-ROOT="/"
-
-function usage {
- echo "usage: [ROOT=/otherroot] `basename $0` --option [metapackage]"
- echo "options: --install, --remove"
- exit 1
-}
-
-if [ -f "$COMMON" ]; then
- source $COMMON
-else
- echo "error: file $COMMON found, check your `basename $0` installation"
- exit 1
-fi
-
-if [ -z "$2" ]; then
- usage
-else
- eval_config `basename $0` -u
-fi
-
-if [ ! -f "$BASE_CONF/$2.template" ]; then
- echo error: template $2 not found
- exit 1
-else
- TEMPLATE="$BASE_CONF/$2.template"
- unset server
-fi
-
-if [[ "$1" == "--install" ]]; then
- install_packages
-elif [[ "$1" == "--remove" ]]; then
- remove_packages
-else
- usage
-fi
diff --git a/src/mkjail b/src/mkjail
deleted file mode 100755
index 3be3efb..0000000
--- a/src/mkjail
+++ /dev/null
@@ -1,150 +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 copy_template_files {
-
- # copy template files into jail
- # usage: copy_template_files <jail-path>
-
- if [ -d "$1" ]; then
- echo "$BASENAME: copying template files..."
- if [ -d "$TEMPLATE_BASE.d" ]; then
- if [ "$TEMPLATES_UNDER_SVN" == "1" ]; then
- rsync -av --exclude=.svn $TEMPLATE_BASE.d/ $JAIL_ROOT/$server/
- else
- rsync -av $TEMPLATE_BASE.d/ $JAIL_ROOT/$server/
- fi
- fi
- fi
-
-}
-
-function set_jail_perms {
-
- # set template file permissions under a jail
- # usage: set_jail_perms <jail-path>
-
- if [ -s "$TEMPLATE_BASE.perms" ]; then
- cat $TEMPLATE_BASE.perms | while read entry; do
- file="`echo $entry | cut -d ";" -f 1`"
- if [ -a "$TEMPLATE_BASE.d/$file" ] && [ -a "$1/$file" ]; then
- owner="`echo entry | cut -d ";" -f 2`"
- group="`echo entry | cut -d ";" -f 3`"
- perms="`echo entry | cut -d ";" -f 4`"
- chmod $perms $1/$file
- chown $owner:$group $1/$file
- fi
- done
- fi
-
-}
-
-function exec_post_install_scripts {
-
- # exec post installation scripts
- # usage: exec_post_install_script <jail-root> <jail-name>
-
- if [ -z "$2" ]; then
- return 1
- fi
-
- echo "$BASENAME: executing template scripts..."
- if [ -d "$TEMPLATE_BASE.s" ]; then
- for script in `ls $TEMPLATE_BASE.s/`; do
- if [ -x "$TEMPLATE_BASE.s/$script" ]; then
- exec $TEMPLATE_BASE.s/$script $1 $2
- fi
- done
- fi
-
-}
-
-function jailist_update {
-
- # update the jail list file
- # usage: jailist_update <jail-path>
-
- if [ -f "$JAIL_LIST" ]; then
- if ! grep -q "^$1" $JAIL_LIST; then
- echo $1 >> $JAIL_LIST
- fi
- else
- echo $1 > $JAIL_LIST
- fi
-
-}
-
-if [ -z "$1" ]; then
- usage
-else
- server="$1"
- eval_config $BASENAME -u
-fi
-
-if [ ! -z "$2" ]; then
- search_template $2
- result="$?"
-else
- result="$?"
- search_default_template
-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
-exec_post_install_scripts $JAIL_ROOT $server
-jailist_update $JAIL_ROOT/$server
-
-echo $BASENAME: done creating $server jail
-
diff --git a/src/rebuildpkg b/src/rebuildpkg
deleted file mode 100755
index 6d3d10c..0000000
--- a/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/src/repos b/src/repos
deleted file mode 100755
index 465714b..0000000
--- a/src/repos
+++ /dev/null
@@ -1,135 +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
-#
-
-function svn_add_meta {
- find *meta -exec svn add {} 2> /dev/null \;
- find . -name *meta -exec svn add {} 2> /dev/null \;
-}
-
-function gen_filelist {
- for file in `find | grep -e ".tgz$"`; do ls -l $file; done > FILELIST.TXT
- echo "Created new FILELIST.TXT"
- if [ -d "patches" ]; then
- for file in `find patches | grep -e ".tgz$"`; do ls -l $file; done > patches/FILE_LIST
- echo "Created new patches/FILE_LIST"
- fi
-}
-
-function gen_packages_txt {
- echo '' > PACKAGES.TXT
- find . -type f -name '*.meta' -exec cat {} \; >> PACKAGES.TXT
- cat PACKAGES.TXT | gzip -9 -c - > PACKAGES.TXT.gz
- echo "Created new PACKAGES.TXT and PACKAGES.TXT.gz"
- if [ -d "patches" ]; then
- find patches -type f -name '*.meta' -exec cat {} \; >> patches/PACKAGES.TXT
- cat patches/PACKAGES.TXT | gzip -9 -c - > patches/PACKAGES.TXT.gz
- echo "Created new patches/PACKAGES.TXT and patches/PACKAGES.TXT.gz"
- fi
-}
-
-function gen_md5_checksums {
- echo '' > CHECKSUMS.md5
- find . -type f -name '*.tgz' -exec md5sum {} \; >> CHECKSUMS.md5
- cat CHECKSUMS.md5 | gzip -9 -c - > CHECKSUMS.md5.gz
- echo "Created new CHECKSUMS.md5 and CHECKSUMS.md5.gz"
- if [ -d "patches" ]; then
- find patches -type f -name '*.tgz' -exec md5sum {} \; >> patches/CHECKSUMS.md5
- cat patches/CHECKSUMS.md5 | gzip -9 -c - > patches/CHECKSUMS.md5.gz
- echo "Created new patches/CHECKSUMS.md5 and patches/CHECKSUMS.md5.gz"
- fi
-}
-
-function gen_meta {
- if [ ! -f $1 ]; then
- echo "File not found: $1"
- exit 1;
- else
- echo "Processing $1"
- fi
- if [ "`echo $1|grep -E '(.*{1,})\-(.*[\.\-].*[\.\-].*).tgz[ ]{0,}$'`" == "" ]; then
- return;
- fi
- NAME=$(echo $1|sed -re "s/(.*\/)(.*.tgz)$/\2/")
- LOCATION=$(echo $1|sed -re "s/(.*)\/(.*.tgz)$/\1/")
- SIZE=$( expr `gunzip -l $1 | tail -n 1|awk '{print $1}'` / 1024 )
- USIZE=$( expr `gunzip -l $1 | tail -n 1|awk '{print $2}'` / 1024 )
- REQUIRED=$(tar xzfO $1 install/slack-required 2>/dev/null|xargs -r -iZ echo -n "Z,"|sed -e "s/,$//")
- CONFLICTS=$(tar xzfO $1 install/slack-conflicts 2>/dev/null|xargs -r -iZ echo -n "Z,"|sed -e "s/,$//")
- SUGGESTS=$(tar xzfO $1 install/slack-suggests 2>/dev/null|xargs -r )
- METAFILE=${NAME%tgz}meta
- echo "PACKAGE NAME: $NAME" > $LOCATION/$METAFILE
- if [ -n "$DL_URL" ]; then
- echo "PACKAGE MIRROR: $DL_URL" >> $LOCATION/$METAFILE
- fi
- echo "PACKAGE LOCATION: $LOCATION" >> $LOCATION/$METAFILE
- echo "PACKAGE SIZE (compressed): $SIZE K" >> $LOCATION/$METAFILE
- echo "PACKAGE SIZE (uncompressed): $USIZE K" >> $LOCATION/$METAFILE
- echo "PACKAGE REQUIRED: $REQUIRED" >> $LOCATION/$METAFILE
- echo "PACKAGE CONFLICTS: $CONFLICTS" >> $LOCATION/$METAFILE
- echo "PACKAGE SUGGESTS: $SUGGESTS" >> $LOCATION/$METAFILE
- echo "PACKAGE DESCRIPTION:" >> $LOCATION/$METAFILE
- tar xzfO $1 install/slack-desc | grep -E '\w+\:'|grep -v '^#' >> $LOCATION/$METAFILE
- echo "" >> $LOCATION/$METAFILE
-}
-
-function do_all {
- for pkg in `find . -type f -name '*.tgz' -print`; do
- gen_meta $pkg
- done
- $0 PACKAGESTXT
- $0 FILELIST
- $0 MD5
-}
-
-function show_usage {
- echo "`basename $0` [pkg [file]|all|new|svnmeta|PACKAGESTXT|FILELIST|MD5]"
-}
-
-case "$1" in
- pkg)
- if [ -n "$2" ]; then
- gen_meta $2
- else
- show_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
- ;;
- FILELIST)
- gen_filelist
- ;;
- MD5)
- gen_md5_checksums
- ;;
- usage)
- show_usage
- ;;
- *)
- do_all
- svn_add_meta
- ;;
-esac
diff --git a/src/simplaret b/src/simplaret
deleted file mode 100755
index 8735074..0000000
--- a/src/simplaret
+++ /dev/null
@@ -1,997 +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: --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/$file:
- 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/$file:
-
- 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 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
- done
- 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 [ "$2" == "-w" ] && [ ! -z "$3" ]; then
- mtime="-mtime +`echo "$3*7" | bc -l`"
- mtime_message="older than $3 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
- echo "$BASENAME: purging all packages $mtime_message for:"
- 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 {
-
- local file candidate place basename
-
- for file in `find $2/ -name $1*tgz 2> /dev/null`; do
- candidate="`basename $file`"
- if [ "`package_name $candidate`" == "$1" ]; 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 [ "`package_version $candidate`" == "`package_version $result`" ] && \
- [ "`package_build $candidate`" == "`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
-
-}
-
-function simplaret_get {
-
- # get a package
- # usage: simplaret_get <package-name> [--silent]
-
- local silent
-
- # prevent user to stay in $storage
- cd
-
- # 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
- for result in `simplaret_search $1 --formatted`; do
-
- 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`" == "$1" ]; then
- simplaret_repository_url
-
- # if repos_type == root, the package is a patch and
- # STORE_ROOT_PATCHES_ON_PATCHES_DIR config parameter is enabled
- # 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"
- 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/$1.slack-required" ]; then
- rm $folder/$1.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`/$1.slack-required; then
- simplaret_download $repository_url `dirname $file`/$1.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
- return 1
- 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
- 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 oldroot
-
- if [ "$1" == "--upgrade" ]; then
- IS_UPGRADE="1"
- fi
-
- oldroot="$ROOT"
-
- # 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="$oldroot"
-
-}
-
-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> [--skip-checks]
-
- local package root jail_arch jail_version slack_required dep dependency tmp
-
- 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`/$1.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 $1 $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"
-
- installed=`eval "ls $root/var/log/packages/ | egrep '^$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") removepkg $2 ;;
- *) simplaret_usage ;;
-esac
-
diff --git a/src/templatepkg b/src/templatepkg
deleted file mode 100755
index 1382759..0000000
--- a/src/templatepkg
+++ /dev/null
@@ -1,220 +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 $0`
-else
- echo "error: file $COMMON found, check your `basename $0` installation"
- exit 1
-fi
-
-function usage {
-
- echo "usage: $BASENAME <option> <template> [arguments]"
- echo "options:"
- echo ""
- echo " -c | --create: create a template from a jail;"
- echo " -u | --update: update a template from a jail."
- echo ""
- echo " -c and -u are equivalent and their arguments are:"
- echo ""
- echo " $BASENAME -u <template> [jail-root]"
- echo ""
- echo " -a | --add: add files into a template; arguments for -a are:"
- echo ""
- echo " $BASENAME -a <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"
- echo ""
- echo " -d | --delete: delete files or folders from a template; arguments are:"
- echo ""
- echo " $BASENAME -d <template> <file-name>"
- echo ""
- echo " in all cases (-c, -u and -a), jail-root defaults to /, if ommited"
- echo ""
- exit 1
-
-}
-
-function template_update {
-
- # update the template package list
-
- if [ ! -d "$ROOT/var/log/packages" ]; then
- echo $ROOT/var/log/packages: directory not found
- exit 1
- fi
-
- 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 | grep -q -e "^$pack\$"`; then
- package_name $package >> $TEMPLATE
- fi
- else
- package_name $package >> $TEMPLATE
- fi
- done
-
- # check if each package from the template is installed
- grep -v -e "^#" $TEMPLATE | cut -d : -f 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" > $TEMPLATE.tmp
- cat $TEMPLATE.tmp > $TEMPLATE
- rm -f $TEMPLATE.tmp
- fi
- fi
-
- done
-
-}
-
-function template_add {
-
- # add a file in a template
- # usage: template_add <jail-root> <file>
-
- local info_commit
-
- mkdir -p $TEMPLATE_BASE.d
-
- if [ -z "$1" ] || [ -z "$2" ]; then
- return 1
- fi
-
- jail="/$1"
- file="$2"
-
- if [ -a "$TEMPLATE_BASE.d/$file" ]; then
- if [ -d "$TEMPLATE_BASE.d/$file" ]; then
-
- echo $BASENAME: folder $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 [ "$TEMPLATES_UNDER_SVN" == "1" ]; then
- ( cd $TEMPLATE_BASE.d && svn add $candidate )
- info_commit="yes"
- fi
- fi
- done
-
- if [ "$info_commit" == "yes" ]; then
- echo $BASENAME: please run jail-commit to add files under $file into the svn repository
- fi
-
- else
- echo $BASENAME: file $file already on $TEMPLATE_BASE.d
- exti 1
- fi
- else
- if [ -a "$jail/$file" ]; then
-
- mkdir -p $TEMPLATE_BASE.d/`dirname $file`/
- destination="`echo $TEMPLATE_BASE.d/$file | sed -e 's/\/$//'`"
- cp -a $jail/$file $destination
- if [ "$TEMPLATES_UNDER_SVN" == "1" ]; then
- ( cd $TEMPLATE_BASE.d && svn add $file )
- echo $BASENAME: please run jail-commit to add $file into the svn repository
- true
- fi
-
- else
- echo $BASENAME: $jail/$file: file not found
- exit 1
- fi
- fi
-
-}
-
-# command line parsing
-
-if [ -z "$2" ]; then
- usage
-fi
-
-search_template $2 --new
-TEMPLATE="$TEMPLATE_BASE.template"
-
-if [ "$1" == "-u" ] || [ "$1" == "--update" ] || \
- [ "$1" == "-c" ] || [ "$1" == "--create" ]; then
-
- if [ -z "$3" ]; then
- ROOT="/"
- else
- ROOT="/$3"
- fi
-
- template_update
-
-elif [ "$1" == "-a" ] || [ "$1" == "--add" ]; then
-
- if [ -z "$3" ]; then
- usage
- else
- if [ -z "$4" ]; then
- ROOT="/"
- else
- ROOT="$4"
- fi
- fi
-
- template_add $ROOT $3
-
-elif [ "$1" == "-d" ] || [ "$1" == "--delete" ]; then
-
- if [ -z "$3" ]; then
- usage
- else
-
- if [ -a "$TEMPLATE_BASE.d/$3" ]; then
- if [ "$TEMPLATES_UNDER_SVN" == "1" ]; then
- cd $TEMPLATE_BASE
- svn del --force ./$3 || rm -rf ./$3
- echo $BASENAME: please run jail-commit to del $3 in the svn repository
- else
- rm -rf $TEMPLATE_BASE.d/$3
- fi
- fi
-
- fi
-
-else
- usage
-fi
-