2009-01-24 15:10:35 +01:00
|
|
|
#!/bin/bash
|
2009-01-24 19:07:48 +01:00
|
|
|
# $Id$
|
2011-03-10 05:17:52 +01:00
|
|
|
# Written by slakmagik <slakmagik@gmail.com>
|
2009-01-24 15:10:35 +01:00
|
|
|
# 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"
|
2015-06-11 18:32:54 +02:00
|
|
|
remote_repo="https://github.com/sbopkg/sbopkg.git"
|
2009-01-24 15:10:35 +01:00
|
|
|
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 05:17:52 +01:00
|
|
|
printe() {
|
|
|
|
printf "$script: $@" | tr -s ' ' | fmt -sw78 >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2009-01-24 15:10:35 +01: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 02:17:20 +02:00
|
|
|
# Make sure we are root.
|
|
|
|
if (( $(id -u) != 0 )); then
|
2011-03-10 05:17:52 +01:00
|
|
|
printe "$script must be run by the root user."
|
2009-09-27 02:17:20 +02:00
|
|
|
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
|
2015-06-11 18:32:54 +02:00
|
|
|
git checkout $remote_repo $repo || printe "checkout failed"
|
2009-01-24 15:10:35 +01:00
|
|
|
else
|
2011-03-10 05:17:52 +01:00
|
|
|
printe "$repo is not writable.\nChange your privileges or the \
|
|
|
|
value of the \"repo\" variable.\n"
|
2009-01-24 15:10:35 +01: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
|
2015-06-11 18:32:54 +02:00
|
|
|
git_script="$repo/src/usr/sbin/sbopkg"
|
|
|
|
if [ -r $git_script ]; then
|
|
|
|
export VERSION=git$(gitversion $repo)
|
2009-01-24 15:10:35 +01:00
|
|
|
else
|
2015-06-11 18:32:54 +02:00
|
|
|
printe "unable to find $git_script.\nPlease check your repository."
|
2009-01-24 15:10:35 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $OUTPUT =~ "$repo/(sbopkg-$VERSION|root-tools)" ]]; then
|
2011-03-10 05:17:52 +01: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 15:10:35 +01:00
|
|
|
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
|
2011-03-10 05:17:52 +01:00
|
|
|
printe "director(y|ies) exist(s)"
|
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
|
2011-03-10 05:17:52 +01:00
|
|
|
printe "$output_pkg not found."
|
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
|