2009-01-24 17:10:35 +03:00
|
|
|
#!/bin/bash
|
2009-01-24 21:07:48 +03:00
|
|
|
# $Id$
|
2011-03-10 07:17:52 +03:00
|
|
|
# Written by slakmagik <slakmagik@gmail.com>
|
2009-01-24 17:10:35 +03:00
|
|
|
# Released under the WTFPL
|
|
|
|
|
|
|
|
script=${0##*/}
|
|
|
|
|
|
|
|
# USER-MODIFIABLE VARIABLES
|
2009-09-27 04:17:20 +04:00
|
|
|
# this needs to be where the checked out svn directory is.
|
|
|
|
repo="/tmp/sbopkg-read-only"
|
2009-01-24 17:10:35 +03:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2011-03-10 07:17:52 +03:00
|
|
|
printe() {
|
|
|
|
printf "$script: $@" | tr -s ' ' | fmt -sw78 >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2009-01-24 17:10:35 +03:00
|
|
|
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
|
|
|
|
|
2009-09-27 04:17:20 +04:00
|
|
|
# Make sure we are root.
|
|
|
|
if (( $(id -u) != 0 )); then
|
2011-03-10 07:17:52 +03:00
|
|
|
printe "$script must be run by the root user."
|
2009-09-27 04:17:20 +04:00
|
|
|
fi
|
|
|
|
|
2009-01-24 17:10:35 +03:00
|
|
|
if [[ $sync == yes ]]; then
|
2009-09-27 04:17:20 +04:00
|
|
|
if [[ -w $repo ]] || [[ ! -e $repo && -w ${repo%/*} ]]; then
|
2011-03-10 07:17:52 +03:00
|
|
|
svn checkout $remote_repo $repo || printe "checkout failed"
|
2009-01-24 17:10:35 +03:00
|
|
|
else
|
2011-03-10 07:17:52 +03:00
|
|
|
printe "$repo is not writable.\nChange your privileges or the \
|
|
|
|
value of the \"repo\" variable.\n"
|
2009-01-24 17:10:35 +03:00
|
|
|
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
|
2009-03-10 05:53:20 +03:00
|
|
|
svn_script="$repo/src/usr/sbin/sbopkg"
|
2009-01-24 17:10:35 +03:00
|
|
|
if [ -r $svn_script ]; then
|
2009-02-13 00:52:39 +03:00
|
|
|
export VERSION=svn$(svnversion $repo)
|
2009-01-24 17:10:35 +03:00
|
|
|
else
|
2011-03-10 07:17:52 +03:00
|
|
|
printe "unable to find $svn_script.\nPlease check your repository."
|
2009-01-24 17:10:35 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $OUTPUT =~ "$repo/(sbopkg-$VERSION|root-tools)" ]]; then
|
2011-03-10 07:17:52 +03:00
|
|
|
printe "the OUTPUT variable is set to a path that will be \
|
|
|
|
removed.\nPlease alter the value of the variable.\n"
|
2009-01-24 17:10:35 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
output_pkg=$OUTPUT/sbopkg-$VERSION-noarch-1_cng.tgz
|
2009-09-27 04:17:20 +04:00
|
|
|
if [[ $build == yes ]]; then
|
|
|
|
cd $repo
|
|
|
|
if [ -d sbopkg-$VERSION ] || [ -d root-tools ]; then
|
2011-03-10 07:17:52 +03:00
|
|
|
printe "director(y|ies) exist(s)"
|
2009-01-24 17:10:35 +03:00
|
|
|
fi
|
2009-09-27 04:17:20 +04:00
|
|
|
cp -r src sbopkg-$VERSION
|
|
|
|
cp -r tools root-tools
|
|
|
|
tar --exclude='*.svn*' --exclude='*.rej' \
|
|
|
|
--exclude='*~' --exclude='tags' \
|
|
|
|
-czvf $repo/root-tools/sbopkg-$VERSION.tar.gz sbopkg-$VERSION
|
|
|
|
cd $repo/root-tools
|
|
|
|
sh 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
|
2011-03-10 07:17:52 +03:00
|
|
|
printe "$output_pkg not found."
|
2009-01-24 17:10:35 +03:00
|
|
|
fi
|
2009-09-27 04:17:20 +04:00
|
|
|
fi
|
2009-01-24 17:10:35 +03:00
|
|
|
fi
|