From 2e6a46ec966039ae0532b03b52405edfcab824d5 Mon Sep 17 00:00:00 2001 From: "chess.griffin" Date: Sat, 24 Jan 2009 14:10:35 +0000 Subject: [PATCH] add slakmagik's 'sbopkg subversion package maker' (sspm) to /tools directory; this nifty script will sync with the sbopkg SVN repo, build a package from the local SVN copy, and, optionally, install the SVN package; thanks to slakmagik for the contribution --- tools/sspm | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100755 tools/sspm diff --git a/tools/sspm b/tools/sspm new file mode 100755 index 0000000..71d3c17 --- /dev/null +++ b/tools/sspm @@ -0,0 +1,114 @@ +#!/bin/bash +# $Id: sspm,v 1.5 2009-01-24 00:45:41-05 j Exp j $ +# Written by slakmagik (usual symbols in spaces) +# Released under the WTFPL + +script=${0##*/} + +# USER-MODIFIABLE VARIABLES +# this needs to be where the checked out svn directory is. The 'sbopkg' part +# is 'sbopkg-read-only' if doing a default checkout and is the only thing that +# is likely to need changing. +repo="/home/chess/test/sbopkg" +remote_repo="http://sbopkg.googlecode.com/svn/trunk/" +export OUTPUT="${OUTPUT:-/tmp}" + +usage() { +cat << EOF +$script: sbopkg subversion package maker usage: $script [-b] | [-i] | [-s] + +-b build a package from local subversion repository +-i install the package +-s syncs the local repo to the remote one + +No arguments is equivalent to -bis: $script checks out the latest revision to +the subversion repository and builds and installs a package from it. +EOF +exit +} + +if (( $# == 0 )); then + build="yes" + inst="yes" + sync="yes" +else + build="no" + inst="no" + sync="no" +fi + +while getopts :bis opt; do + case $opt in + b) build="yes" ;; + i) inst="yes" ;; + s) sync="yes" ;; + *) usage ;; + esac +done + +if [[ $sync == yes ]]; then + if [ -w $repo/.. ]; then + svn checkout $remote_repo $repo || + ( echo "$script: checkout failed" 1>&2; exit 1 ) + else + printf "$script: $repo is not writable.\n" 1>&2 + printf "Change your privileges or the value of the \"repo\" " + printf "variable.\n" 1>&2 + exit 1 + fi +fi + +# this allows for a version mismatch if someone builds a package, doesn't +# install it, then syncs their repo to a newer version, then does install the +# old package. But, as the doctor said to the guy who complained that it hurt +# when he did that, don't DO that. +if [[ $build == yes || $inst == yes ]]; then + # this is for testing unaltered svn versions + svn_script="$repo/src/usr/bin/sbopkg" + if [ -r $svn_script ]; then + export VERSION="svn$(grep -m1 '$Id.*$' $svn_script | + sed 's/.* sbopkg \([^ ]*\).*/\1/')" + else + echo "$script: unable to find $svn_script." 1>&2 + echo "Please check your repository." 1>&2 + exit 1 + fi + # I use this for testing patches made against the svn repo + #export VERSION=$(date "+%Y%m%d_%H%M") + + if [[ $OUTPUT =~ "$repo/(sbopkg-$VERSION|root-tools)" ]]; then + printf "$script: the OUTPUT variable is set to a path that will be " + printf "removed.\n" 1>&2 + printf "Please alter the value of the variable.\n" 1>&2 + exit 1 + fi + + # technically, you only need to be root to install the packages and not to + # build them, but standard slackbuilds don't build as unprivileged user + # anyway + output_pkg=$OUTPUT/sbopkg-$VERSION-noarch-1_cng.tgz + su -c "( + if [[ $build == yes ]]; then + cd $repo + if [ -d sbopkg-$VERSION ] || [ -d root-tools ]; then + echo \"$script: director(y|ies) exist\" 1>&2; exit 1 + fi + cp -r src sbopkg-$VERSION + cp -r tools root-tools + tar --exclude='*.svn*' --exclude='*.rej' \ + -czvf $repo/root-tools/sbopkg-$VERSION.tar.gz sbopkg-$VERSION + cd $repo/root-tools + ./sbopkg.SlackBuild + cd $repo + rm -rf root-tools + rm -rf sbopkg-$VERSION + fi + if [[ $inst == yes ]]; then + if [ -r $output_pkg ]; then + upgradepkg --install-new --reinstall $output_pkg + else + echo \"$script: $output_pkg not found.\" 1>&2; exit 1 + fi + fi + )" +fi