2009-01-24 15:10:35 +01:00
|
|
|
#!/bin/bash
|
2009-01-24 19:07:48 +01:00
|
|
|
# $Id$
|
2009-01-24 15:10:35 +01:00
|
|
|
# Written by slakmagik <jsun freeshell org> (usual symbols in spaces)
|
|
|
|
# Released under the WTFPL
|
|
|
|
|
|
|
|
script=${0##*/}
|
|
|
|
|
|
|
|
# USER-MODIFIABLE VARIABLES
|
2009-09-27 02:17:20 +02:00
|
|
|
# this needs to be where the checked out svn directory is.
|
|
|
|
repo="/tmp/sbopkg-read-only"
|
2009-01-24 15:10:35 +01: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
|
|
|
|
}
|
|
|
|
|
|
|
|
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 02:17:20 +02:00
|
|
|
# Make sure we are root.
|
|
|
|
if (( $(id -u) != 0 )); then
|
|
|
|
echo "$script: $script must be run by the root user." 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2009-01-24 15:10:35 +01:00
|
|
|
if [[ $sync == yes ]]; then
|
2009-09-27 02:17:20 +02:00
|
|
|
if [[ -w $repo ]] || [[ ! -e $repo && -w ${repo%/*} ]]; then
|
2009-01-24 15:10:35 +01:00
|
|
|
svn checkout $remote_repo $repo ||
|
2009-09-27 02:17:20 +02:00
|
|
|
{ echo "$script: checkout failed" 1>&2; exit 1; }
|
2009-01-24 15:10:35 +01:00
|
|
|
else
|
|
|
|
printf "$script: $repo is not writable.\n" 1>&2
|
2009-01-24 19:07:48 +01:00
|
|
|
printf "Change your privileges or the value of the \"repo\" " 1>&2
|
2009-01-24 15:10:35 +01:00
|
|
|
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
|
2009-03-10 03:53:20 +01:00
|
|
|
svn_script="$repo/src/usr/sbin/sbopkg"
|
2009-01-24 15:10:35 +01:00
|
|
|
if [ -r $svn_script ]; then
|
2009-02-12 22:52:39 +01:00
|
|
|
export VERSION=svn$(svnversion $repo)
|
2009-01-24 15:10:35 +01:00
|
|
|
else
|
|
|
|
echo "$script: unable to find $svn_script." 1>&2
|
|
|
|
echo "Please check your repository." 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $OUTPUT =~ "$repo/(sbopkg-$VERSION|root-tools)" ]]; then
|
2009-01-24 19:07:48 +01:00
|
|
|
printf "$script: the OUTPUT variable is set to a path that will " 1>&2
|
|
|
|
printf "be removed.\n" 1>&2
|
2009-01-24 15:10:35 +01:00
|
|
|
printf "Please alter the value of the variable.\n" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
output_pkg=$OUTPUT/sbopkg-$VERSION-noarch-1_cng.tgz
|
2009-09-27 02:17:20 +02:00
|
|
|
if [[ $build == yes ]]; then
|
|
|
|
cd $repo
|
|
|
|
if [ -d sbopkg-$VERSION ] || [ -d root-tools ]; then
|
|
|
|
echo "$script: director(y|ies) exist" 1>&2; exit 1
|
2009-01-24 15:10:35 +01:00
|
|
|
fi
|
2009-09-27 02:17:20 +02: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
|
|
|
|
echo "$script: $output_pkg not found." 1>&2; exit 1
|
2009-01-24 15:10:35 +01:00
|
|
|
fi
|
2009-09-27 02:17:20 +02:00
|
|
|
fi
|
2009-01-24 15:10:35 +01:00
|
|
|
fi
|