initial commit of sbopkg, sbopkg.conf.sample, TODO, sbopkg.conf.5, and sbopkg.8; add all except the man pages to svn propset for $Id$ tags

This commit is contained in:
chess.griffin 2008-03-24 00:42:47 +00:00
parent 0e5947600a
commit 8907ba66db
5 changed files with 588 additions and 0 deletions

View File

@ -0,0 +1,6 @@
# $Id$
#
RSYNCMIRROR=slackbuilds.org::slackbuilds
SLACKVER=12.0
LOCALREPO=/home/sbo
KEEPLOG=YES

418
src/usr/bin/sbopkg Executable file
View File

@ -0,0 +1,418 @@
#!/bin/sh
#
# $Id$
#
# sbopkg - The SlackBuilds.org Package Browser
# Copyright 2007-2008 Chess Griffin <chess@chessgriffin.com>
#
# Redistribution and use of this script, with or without modification,
# is permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Variables
DIAG=""
CONF=/etc/sbopkg/sbopkg.conf
CWD=${pwd}
VER=0.0.1
function sanity_checks
{
# Check if config file is there and if yes, set some variables
if [ ! -e $CONF ]; then
echo "ERROR: No /etc/sbopkg/sbopkg.conf file was found. Please copy over /etc/sbopkg/sbopkg.conf.sample and try again."
exit 0
else
RSYNCMIRROR=`grep RSYNCMIRROR $CONF | sed -e s/RSYNCMIRROR=//`
SLACKVER=`grep SLACKVER $CONF | sed -e s/SLACKVER=//`
LOCALREPO=`grep LOCALREPO $CONF | sed -e s/LOCALREPO=//`
LOGS=`grep KEEPLOG $CONF | sed -e s/KEEPLOG=//`
fi
}
function check_local_dir
{
# Check to see if the main local directory for the mirror exists
if [ ! -d "$LOCALREPO" ]; then
echo "Directory $LOCALREPO does not exist. Please create it and run sbopkg again."
exit 0
else
cd $LOCALREPO/$SLACKVER
fi
}
function check_root
{
# Check to see whether the user is root or not
if [ ! $( id -u ) = "0" ]; then
ROOT="false"
else
ROOT="true"
fi
}
function show_changelog
{
# Show the changelog
if [ "$DIAG" = 1 ]; then
dialog --title "SlackBuilds.org ChangeLog" --textbox ./ChangeLog.txt 0 0
else
less ./ChangeLog.txt
fi
}
function get_category_list
{
# This function displays the list of SBo categories in the dialog
rm -f /tmp/sbopkg_category_list 2> /dev/null
DIR=`ls -d */ | sed -e 's/\///'`
if [ -n "$DIR" ]; then
for i in $DIR; do
echo "$i \"Browse the $i category\"" >> /tmp/sbopkg_category_list
done
fi
}
function get_category_items_list
{
# This function makes and displays a list of all the package items in
# the selected category. Ideally, it would be nice to have this be a
# checklist where the user can select multiple applications to build
# in a queue.
CATEGORY="`cat /tmp/sbopkg_category_selection`"
cd $LOCALREPO/$SLACKVER/$CATEGORY
rm -f /tmp/sbopkg_category_items_list 2> /dev/null
DIR=`ls -d */ | sed -e 's/\///'`
if [ -n "$DIR" ]; then
for i in $DIR; do
DESC=`grep -h -Z -m1 ^$i ./$i/slack-desc* | sed -e s/$i': '//`
echo "$i \"$DESC\"" >> /tmp/sbopkg_category_items_list
done
fi
cd $LOCALREPO/$SLACKVER
}
function info_item
{
# This function shows the menu for each package where the user can see
# certain information or build the package if he is root
APP="`cat /tmp/sbopkg_item_selection`"
while [ 0 ]; do
dialog --title "$APP Information" --menu "Choose an item or press <Cancel> to exit\n" 20 60 5 \
"README" "View the README file" \
"SlackBuild" "View the SlackBuild file" \
"Info" "View the .info file" \
"Slack-desc" "View the slack-desc file" \
"Build" "Build a package for $APP" 2>/tmp/sbopkg_info_selection
if [ $? = 1 ]; then
break
fi
S="`cat /tmp/sbopkg_info_selection`"
CATEGORY="`cat /tmp/sbopkg_category_selection`"
if [ "$S" = "README" ]; then
dialog --title "Viewing README" --textbox $LOCALREPO/$SLACKVER/$CATEGORY/$APP/README 0 0
fi
if [ "$S" = "SlackBuild" ]; then
dialog --title "Viewing SlackBuild" --textbox $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild 0 0
fi
if [ "$S" = "Info" ]; then
dialog --title "Viewing .info" --textbox $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info 0 0
fi
if [ "$S" = "Slack-desc" ]; then
dialog --title "Viewing Slack-desc" --textbox $LOCALREPO/$SLACKVER/$CATEGORY/$APP/slack-desc 0 0
fi
if [ "$S" = "Build" ]; then
# If the user selects to build an app, first check to make
# they are root and continue if not. If they are root, then
# show a warning about the fact that the dialog box that shows
# the running output has a flaw - the 'Exit' button allows the
# user to exit out the running log dialog window but the build
# process will continue. Ideally, I'd like to prevent the
# user from exiting the running output dialog until the build
# process is complete. Anyone know how to do this?
check_root
if [ $ROOT = "false" ]; then
dialog --title "ERROR" --msgbox "You must run this script as the root user in order to build packages." 0 0
continue
fi
dialog --title "WARNING" --yesno "Building a package in sbopkg is still experimental. Pressing YES will continue the build and you will be presented with a text box showing the output of the build process, which is temporarily stored at /tmp/sbopkg_output. If KEEPLOG is set to YES in the configuration file, then this temporary build log will also be saved at /tmp/sbopkg-build-log. The build process will continue in the background even after pressing the EXIT button in the text box so do not start a second build until the first has completed. Do you want to continue?" 15 60 2>$?
if [ "$?" = 1 ]; then
continue
fi
if [ "$?" = 0 ]; then
OUTPUT=/tmp/sbopkg_output
search_package $APP
( build_package $APP >> $OUTPUT & ) 2>>$OUTPUT
# This is the dialog box that I'd like to keep
# displayed until the build process is over
dialog --backtitle "Building the $APP package in the background." --tailbox $OUTPUT 20 70
if [ "$LOGS" = "YES" ]; then
cat $OUTPUT >> /tmp/sbopkg-build-log
fi
rm -f $OUTPUT
fi
fi
done
}
function browse_items
{
# This function iterates through the list of software packages until
# one is chosen.
get_category_items_list
while [ 0 ]; do
dialog --title "Browsing the $CATEGORY category" --menu "Please select a software package" 20 70 15 --file /tmp/sbopkg_category_items_list 2>/tmp/sbopkg_item_selection
if [ $? = 1 ]; then
break
fi
info_item
done
}
function browse_categories
{
# This function iterates through the category list until one is
# chosen.
get_category_list
while [ 0 ]; do
dialog --title "Choose a category" --menu "Please select the category you wish to browse." 20 70 12 --file /tmp/sbopkg_category_list 2>/tmp/sbopkg_category_selection
if [ $? = 1 ]; then
break
fi
browse_items
done
}
function rsync_repo
{
# This function does the rsync with SBo.
if [ "$DIAG" = 1 ]; then
OUTPUT=/tmp/sbopkg_output
( /usr/bin/rsync -avz $RSYNCMIRROR/$SLACKVER/ $LOCALREPO/$SLACKVER/ >> $OUTPUT & ) 2>>$OUTPUT
dialog --backtitle "Rsyncing with SlackBuilds.org" --tailbox $OUTPUT 20 70
rm -f $OUTPUT
else
/usr/bin/rsync -avz $RSYNCMIRROR/$SLACKVER/ $LOCALREPO/$SLACKVER/
fi
}
function search_package ()
{
# Search for package name and exit if not found. If it is found,
# populate various variables with data about the package for
# displaying information and building.
PKG=$1
PKGPATH=`find -name $PKG`
if [ ! `find -name "$PKG"` ]; then
if [ "$DIAG" = 1 ]; then
dialog --title "ERROR" --textbox "Package $PKG not found" 0 0
continue
else
echo "Package $PKG not found. Exiting."
exit 0
fi
fi
TESTPKGNAME=`echo $PKG | sed 's/.*\///'`
PKGNAME=`echo $PKG | sed 's/.*\///'`
DNLD=`grep DOWNLOAD $PKGPATH/$PKG.info | sed -e s/DOWNLOAD=// | sed -e s/\"//g`
SRCNAME=`echo $DNLD | sed 's/.*\///'`
MD5=`grep MD5SUM $PKGPATH/$PKG.info | sed -e s/MD5SUM=// | sed -e s/\"//g`
}
function show_readme
{
# Show the package's README file.
cat $PKGPATH/README
exit 0
}
function build_package ()
{
# Start fetching and building the package.
echo ; echo "Building $PKG"
cd $PKGPATH
if [ ! -e "$SRCNAME" ];
then echo "Downloading source code for "$SRCNAME"..."
wget -T 20 $DNLD || exit 1
#curl $DNLD || exit 1
fi
echo "Checking MD5SUM for "$SRCNAME"..."
MD5CHK=`md5sum $SRCNAME | sed -e 's/ .*$//'`
if [ "$MD5CHK" == $MD5 ]; then
echo "OK"
else
echo "MD5SUM check failed. Exiting."
continue
fi
echo "Building Slackware package for "$SRCNAME"..."
sh $PKG.SlackBuild
echo "Done building $PKG."
cd $LOCALREPO/$SLACKVER
}
function cleanup
{
# If the temp files are there, delete them all. Right now, I have
# this test to see if the main menu temp file is there, since it
# always is. It would be cleaner if the 'if [ -e ] could test on
# anything in /tmp/sbopkg*, like: 'if [ -e /tmp/sbopkg_* ]; then' but
# that does not work. I have not bothered trying to figure out the
# right syntax.
if [ -e /tmp/sbopkg_main_menu_answer ]; then
rm -r /tmp/sbopkg_*
fi
cd $CWD
}
function main_menu
{
# This is the main dialog menu.
while [ 0 ]; do
dialog --title "SlackBuilds.org Package Browser (sbopkg version $VER)" --menu \
"\nChoose one of the following or press <Cancel> to exit\n" \
15 60 4 \
"Rsync" "Rsync with SlackBuilds.org" \
"ChangeLog" "View the SlackBuilds.org ChangeLog" \
"Browse" "Browse the local SlackBuilds.org repo" \
"Exit" "Exit sbopkg" 2>/tmp/sbopkg_main_menu_answer
if [ $? = 1 ]; then
clear
cleanup
exit 0
fi
R="`cat /tmp/sbopkg_main_menu_answer`"
if [ "$R" = "Rsync" ]; then
rsync_repo
fi
if [ "$R" = "Browse" ]; then
browse_categories
fi
if [ "$R" = "ChangeLog" ]; then
show_changelog
fi
if [ "$R" = "Exit" ]; then
clear
cleanup
exit 0
fi
done
}
# END OF FUNCTIONS. What comes below is the actual start of the
# script when it is first run.
sanity_checks
# If there are no command line options then we will use the dialog
# version of sbopkg
if [ $# -eq 0 ]; then
DIAG=1
check_local_dir
main_menu
exit 0
fi
# This is the command line options and help
while getopts "b:d:hlrs:" OPT
do
case $OPT in
b ) BUILD="${OPTARG}"
;;
d ) LOCALREPO=${OPTARG}
;;
h ) echo
echo "sbopkg v$VER"
echo "Usage: $0 [OPTIONS] <packagename(s)>"
echo "Options are:"
echo " -b package Build a package."
echo " -d localdir Location of local SlackBuilds.org mirror."
echo " This is currently set to $LOCALREPO"
echo " -h Display this help message."
echo " -l Display the SlackBuilds.org ChangeLog.txt and then quit."
echo " -r Rsync the SlackBuilds.org respository with"
echo " the local mirror and then quit."
echo " -s package Search for a package and, if found, display the README."
echo
exit
;;
l ) CHANGELOG=1
;;
r ) RSY=1
;;
s ) SEARCH="${OPTARG}"
;;
* ) echo "No options given. Run '$0 -h' for help. Exiting."
exit 0
;;
esac
done
# End of option parsing.
shift $(($OPTIND - 1))
check_local_dir
# The build feature does not work with > 1 package at the moment.
# Have not investigated further.
if [ -n "$BUILD" ]; then
check_root
if [ $ROOT = "false" ]; then
echo "You must run this script as the root user in order to build packages."
exit 0
fi
for PKGBUILD in ${BUILD}; do
echo "Building $PKGBUILD"
search_package $PKGBUILD
build_package $PKGBUILD
done
exit 0
fi
if [ -n "$CHANGELOG" ]; then
show_changelog
cleanup
exit 0
fi
if [ -n "$RSY" ];
then echo "Rsyncing with Slackbuilds.org repository into $LOCALREPO."
rsync_repo
cleanup
echo "Finished rsync."
exit 0
fi
# The search feature is not working with > 1 package at the moment.
# Have not yet investigated further.
if [ -n "$SEARCH" ]; then
for PKGSEARCH in ${SEARCH}; do
echo "Searching for $PKGSEARCH"
search_package $PKGSEARCH
show_readme
done
exit 0
fi
cleanup
echo "All done."
exit 0

25
src/usr/doc/TODO Normal file
View File

@ -0,0 +1,25 @@
# $Id$
Sbopkg TODO
* Add ability to search or build more than one package at a time using
command line only.
* When using the dialog interface, change the listing of packages to
be a checklist or radiolist whereby the user can select more than
one package to build at a time. This would possibly change how the
user would be able to view the README, slack-desc etc. since a
checklist or radiolist would not present the current 'view' menu.
Not sure how the order of packages selected would be set.
* Fix the way packages are built in the dialog so the display showing
the build process cannot be exited. This is confusing as it
currently stands and the warning that is displayed is not an
adequate solution. Look at how pkgtool removes packges.
* Add ability to view more than just the README from the command line.
* Allow user to change the config file location via command line, i.e.
with a '-c ~/.sbopkg.conf'
* Include ability to work with more than one repo with different
Slackware versions, i.e. /home/sbo/11.0 and /home/sbo/12.0. The
first menu in the dialog after selecting "Browse" would be a menu
showing the various Slackware versions in the local mirror.
* More error checking, such as making sure the user running the script
has write permissions on the local mirror.
* General code cleanups.

View File

@ -0,0 +1,57 @@
.TH SBOPKG.CONF 5 "Mar 2008" sbopkg-0.0.1 ""
.SH NAME
.B sbopkg.conf
\- Configuration file for sbopkg
.SH DESCRIPTION
The sbopkg.conf file contains configuration settings for
.B sbopkg
(8), a tool for interacting with the SlackBuilds.org ("SBo")
repository, a collection of third-party SlackBuild scripts to build
Slackware packages. A sample file is provided at
/etc/sbopkg/sbopkg.conf.sample.
The different configuration options are:
.TP 5
.B RSYNCMIRROR
.br
This option allows the user to set the rsync mirror of the SBo
repository that will be used by sbopkg.
The default value of RSYNCMIRROR is slackbuilds.org::slackbuilds
.TP 5
.B SLACKVER
.br
This option allows the user to set the Slackware version in order to
rsync with the matching SBo repository.
The default value of SLACKVER is 12.0
.TP 5
.B LOCALREPO
.br
This option allows the user to set the location of the local rsync
mirror of the SBo repository.
The default value of LOCALREPO is /home/sbo.
.TP 5
.B KEEPLOG
.br
This option should be set to YES or NO. This option allows the user
to choose whether to keep a permanent log of packages that are build
with sbopkg in order to go back and review the build, and any errors,
after exiting sbopkg. If set to YES, this permanent log is saved at
/tmp/sbopkg-build-log.
The default value of KEEPLOG is YES.
.SH FILES
.TP 5
.B /etc/sbopkg/sbopkg.conf
.SH "SEE ALSO"
.BR sbopkg (8)

82
src/usr/man/man8/sbopkg.8 Normal file
View File

@ -0,0 +1,82 @@
.TH SBOPKG 8 "Mar 2008" sbopkg-0.0.1 ""
.SH NAME
.B sbopkg
\ - The SlackBuilds.org Package Browser
.SH SYNOPSIS
.B sbopkg
.B [options]
.SH DESCRIPTION
Sbopkg is a command-line and dialog-based tool to interact with the
SlackBuilds.org ("SBo") repository, a collection of third-party
SlackBuild scripts to build Slackware packages.
.SH INSTRUCTIONS
Before sbopkg can be used, a configuration file must be created at
/etc/sbopkg/sbopkg.conf. A sample file is provided at
/etc/sbopkg/sbopkg.conf.sample. See
.B sbopkg.conf
(5) for more information about the configuration file.
Sbopkg can be run from the command line by simply invoking "sbopkg."
Doing so will launch the dialog-based interface, and the menus
provided should be fairly explanatory. The main menu allows the user
to rsync with the SlackBuilds.org repository, view the ChangeLog, and
browse the local copy of the SBo repository. Once the browse function
is chosen, the user can select the category of software to view.
After choosing a category, the user can then view the various software
packages available in the local SBo repository. Selecting a package
will display another menu allowing the user to view the package's
README, SlackBuild, .info, or slack-desc file. Additionally, if
sbopkg is run with root privileges, then the user can choose to build
a package as well. Please note that the package-building featue of
sbopkg is still considered experimental but has worked well in
testing. Currently, the dialog interface displays a text window
showing the build process. Pressing "Exit" from this window will not
stop the build process and it will continue in the background.
Therefore, it is recommended not to start another build until the
first has completed. If KEEPLOG is set to YES in the sbopkg.conf
file, then a permanent log of the build process is saved in
/tmp/sbopkg-build-log.
Alternatively, sbopkg can be run from the command line without using
the dialog interface. Executing "sbopkg -h" will display a list of
options available from the command line.
.SH OPTIONS
.TP 5
.B -b PACKAGE
\ Search for and build PACKAGE from the local SBo repository
.TP 5
.B -d DIRECTORY
\ Manually specify the full path to the DIRECTORY containing the
\ local SBo repository
.TP 5
.B -h
\ Display the help
.TP 5
.B -l
\ Display the SBo ChangeLog.txt and quit
.TP 5
.B -r
\ Rsync the local repository with SlackBuilds.org and quit
.TP 5
.B -s PACKAGE
\ Search for PACKAGE and, if found, display the README
.SH FILES
.B /etc/sbopkg/sbopkg.conf
\ - File to specify configuration options.
.SH "SEE ALSO"
.BR sbopkg.conf (5)
.SH AUTHOR
Chess Griffin
<chess@chessgriffin.com>