]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
added createpkg
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Mon, 18 Sep 2006 21:50:54 +0000 (21:50 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Mon, 18 Sep 2006 21:50:54 +0000 (21:50 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@2 04377dda-e619-0410-9926-eae83683ac58

createpkg [new file with mode: 0644]
simplepkg.SlackBuild

diff --git a/createpkg b/createpkg
new file mode 100644 (file)
index 0000000..0faa82d
--- /dev/null
+++ b/createpkg
@@ -0,0 +1,182 @@
+#!/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
+#
+
+COMMON="/usr/libexec/simplepkg/common.sh"
+SLACKBUILDRC="/etc/slackbuildrc"
+
+if [ -f "$COMMON" ]; then
+  source $COMMON
+else
+  echo "error: file $COMMON found, check your `basename $0` installation"
+  exit 1
+fi
+
+function safe_exit {
+
+  # exit codes
+  case $1 in
+    2) echo Could not create folder $2;;
+    3) echo Could not update the repository $2 ;;
+    4) usage ;;
+    5) echo Script not found;;
+    *) exit 1
+  esac
+
+  exit $1
+
+}
+
+function build_repo {
+
+  BASEDIR="`dirname $SLACKBUILDS`"
+  mkdir -p $BASEDIR || safe_exit 2 $BASEDIR
+  cd $BASEDIR
+  svn checkout $SVN
+  cd $SLACKBUILDS
+
+}
+
+function usage {
+
+  echo "usage: createpkg [--install] package-name"
+  echo "       createpkg --search package-name"
+  echo "       createpkg --sync"
+  
+}
+
+function check_config {
+
+  if [ -f "$SLACKBUILDRC" ]; then
+    source $SLACKBUILDRC
+  fi
+
+  TMP=${TMP:=/tmp}
+  REPOS=${REPOS:=$TMP}
+  SLACKBUILDS=${SLACKBUILDS:=/var/slackbuilds}
+  SVN=${SVN:=svn://slack.sarava.org/slackbuilds}
+  SYNC=${SYNC:=no}
+  BASEDIR="`dirname $SLACKBUILDS`"
+
+}
+
+function solve_dep {
+
+  # TODO: solve dep with version checking
+
+  pack="$1"
+  for candidate in `ls /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
+    createpkg --install $pack
+  fi
+
+}
+
+function check_repo {
+
+  if [ ! -d "$SLACKBUILDS" ]; then
+    build_repo
+  fi
+
+}
+
+function sync_repo {
+
+  cd $SLACKBUILDS
+  svn update || build_repo
+
+}
+
+function find_script {
+
+  find $SLACKBUILDS | grep -v .svn | grep $1.SlackBuild
+
+}
+
+check_config
+check_repo
+
+if [ -z "$1" ]; then
+  safe_exit 4
+elif [ "$1" == "--sync" ]; then
+  sync_repo 
+  exit
+elif [ "$1" == "--search" ]; then
+  find_script $2
+  exit
+elif [ "$1" == "--install" ]; then
+  PACKAGE="$2"
+  INSTALL="1"
+else
+  PACKAGE="$1"
+fi
+
+if [ "$SYNC" == "yes" ]; then
+  sync_repo
+fi
+
+BUILD_SCRIPT="`find_script $PACKAGE`"
+
+if [ -z "$BUILD_SCRIPT" ]; then
+  safe_exit 5
+fi
+
+SCRIPT_BASE="`dirname $BUILD_SCRIPT`"
+
+if [ -f "$SCRIPT_BASE/$PACKAGE.slack-required" ]; then
+  SLACK_REQ="$SCRIPT_BASE/$PACKAGE.slack-required"
+elif [ -f "$SCRIPT_BASE/slack-required" ]; then
+  SLACK_REQ="$SCRIPT_BASE/slack-required"
+fi
+
+if [ ! -z "$SLACK_REQ" ]; then
+
+  cat $SLACK_REQ | while read dep; do
+    dep="`echo $dep | sed -e 's/>=/equalorgreater/' -e 's/=</equalorless/' -e 's/</less/' -e 's/>/greater/' -e 's/=/equal/'`"
+    solve_dep $dep
+  done
+
+fi
+
+cd $SCRIPT_BASE
+INTERACT=no ./`basename $BUILD_SCRIPT`
+
+VERSION="`grep -e '^VERSION=' $BUILD_SCRIPT | head -n 1 | sed -e "s/VERSION//g" -e 's/=//g' -e 's/-//g' | cut -d ":" -f 2 | cut -d "}" -f 1`"
+BUILD="`grep -e '^BUILD=' $BUILD_SCRIPT | head -n 1 | sed -e "s/BUILD//g" -e 's/=//g' | cut -d ":" -f 2 | cut -d "}" -f 1`"
+_ARCH="`grep -e '^ARCH' $BUILD_SCRIPT | head -n 1 | cut -d "=" -f 2 | sed -e 's/"//g'`"
+
+if [ "$_ARCH" == "noarch" ]; then
+  ARCH="noarch"
+fi
+
+if [ "$INSTALL" == "1" ]; then
+  installpkg $REPOS/$PACKAGE-$VERSION-$ARCH-$BUILD.tgz
+fi
+
index 338af4415a563f3cce9902c9f1f4f879d6da1223..42c0135867e938336465260452f701376c763759 100755 (executable)
@@ -12,7 +12,7 @@ ARCH="noarch"
 LIBEXEC="/usr/libexec/$PACKAGE"
 BINDIR="/usr/sbin"
 DOC_DIR="/usr/doc"
-BINARY_LIST="mkjail templatepkg jail-update jail-upgrade lspkg metapkg rebuildpkg simplaret"
+BINARY_LIST="mkjail templatepkg jail-update jail-upgrade lspkg metapkg rebuildpkg simplaret createpkg"
 LIB_LIST="common.sh"
 DOC_LIST="COPYING TODO CHANGELOG README README.pt_BR README.simplaret README.simplaret.pt_BR"