add initial code for editing the SlackBuild. Seem to work ok but have not yet added ability to build a package using the edited SlackBuild but that is an easy addition. Can also delete the local edited copy of the SlackBuild. The rsync command was also tweaked to exclude the .sbopkg which is the text appended to the local edited SlackBuild. Edited man pages and version number in sbopkg to 0.0.4

This commit is contained in:
chess.griffin 2008-03-28 19:19:07 +00:00
parent 8e8e6714a9
commit 9fd5df4562
3 changed files with 62 additions and 10 deletions

View File

@ -31,7 +31,7 @@ SCRIPT=${0##*/}
DIAG=""
SBOPKG_CONF="${SBOPKG_CONF:-/etc/sbopkg/sbopkg.conf}"
CWD="$pwd"
VER=0.0.3
VER=0.0.4
sanity_checks () {
# Check if config file is there and if yes, set some variables
@ -124,11 +124,13 @@ info_item () {
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 \
<Cancel> to exit\n" 20 60 7 \
"README" "View the README file" \
"SlackBuild" "View the SlackBuild file" \
"Info" "View the .info file" \
"Slack-desc" "View the slack-desc file" \
"SlackBuild" "View the SlackBuild file" \
"Edit" "Create and edit a local copy of the SlackBuild file" \
"Delete" "Delete the local copy of the SlackBuild file" \
"Build" "Build a package for $APP" 2>$TMP/sbopkg_info_selection
if [ $? = 1 ]; then
@ -140,10 +142,6 @@ 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
@ -153,6 +151,16 @@ PARSED_SLACK_DESC=$(mktemp $TMP/sbopkg_parsed_slack_desc.XXXXXX)
sed -n "/^$APP: /s///p" $LOCALREPO/$SLACKVER/$CATEGORY/$APP/slack-desc > $PARSED_SLACK_DESC
dialog --title "Viewing Slack-desc" --textbox $PARSED_SLACK_DESC 0 0
fi
if [ "$S" = "SlackBuild" ]; then
dialog --title "Viewing SlackBuild" \
--textbox $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild 0 0
fi
if [ "$S" = "Edit" ]; then
edit_local_slackbuild $APP
fi
if [ "$S" = "Delete" ]; then
delete_local_slackbuild $APP
fi
if [ "$S" = "Build" ]; then
check_root
if [ $ROOT = "false" ]; then
@ -216,7 +224,7 @@ dialog --title "Displaying $SRCDIR" \
rsync_command () {
# This function holds the rsync command
/usr/bin/rsync -avz --delete --timeout=5 \
/usr/bin/rsync -avz --delete --timeout=5 --exclude="*.sbopkg" \
$RSYNCMIRROR/$SLACKVER/ $LOCALREPO/$SLACKVER/
rm -rf $TMP/sbopkg_rsync.lck
}
@ -274,9 +282,18 @@ SRCNAME=${DOWNLOAD##*/}
show_readme () {
# Show the package's text files.
# I am still not happy with how this works and am trying to think
# of a better way to have these 4 docs available for viewing from the
# cli. Maybe have -s just return the readme, as the result of a
# search, and maybe have another option like -v to view all 4 docs?
# Also, maybe have a way for the user to choose which of the 4 docs he
# wants to view? Or have a menu listing the 4 docs? Undecided.
SBODOCS="README $PKGNAME.SlackBuild $PKGNAME.info slack-desc"
for i in $SBODOCS; do
echo
echo "Viewing "$i":"
${PAGER:-more} $PKGPATH/$i
read # This was added because README was scrolling past too quickly
done
return 0
}
@ -317,6 +334,41 @@ rm -rf $TMP/sbopkg_build.lck
cd $LOCALREPO/$SLACKVER
}
edit_local_slackbuild () {
# This function allows the user to create and edit a local copy of the
# SlackBuild
check_write $LOCALREPO/$SLACKVER/$CATEGORY/$APP
if [ "$WRITE" = "false" ]; then
dialog --title "ERROR" --msgbox "You do not have write \
permissions on the target directory." 0 0
continue
fi
if [ ! -e $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild.sbopkg ]; then
cp $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild \
$LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild.sbopkg
fi
${EDITOR:-vi} $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild.sbopkg
}
delete_local_slackbuild () {
# This function allows the user to delete the local SlackBuild
check_write $LOCALREPO/$SLACKVER/$CATEGORY/$APP
if [ "$WRITE" = "false" ]; then
dialog --title "ERROR" --msgbox "You do not have write \
permissions on the target directory." 0 0
continue
fi
if [ ! -e $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild.sbopkg ]; then
dialog --title "ERROR" --msgbox "There is no local copy of the \
SlackBuild to delete." 0 0
continue
else
rm $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild.sbopkg
dialog --title "DONE" --msgbox "The local copy of the SlackBuild \
has been deleted." 0 0
fi
}
cleanup () {
rm -rf $TMP/sbopkg_*
cd $CWD

View File

@ -1,4 +1,4 @@
.TH SBOPKG.CONF 5 "Mar 2008" sbopkg-0.0.3 ""
.TH SBOPKG.CONF 5 "Mar 2008" sbopkg-0.0.4 ""
.SH NAME
.B sbopkg.conf
\- Configuration file for sbopkg

View File

@ -1,4 +1,4 @@
.TH SBOPKG 8 "Mar 2008" sbopkg-0.0.3 ""
.TH SBOPKG 8 "Mar 2008" sbopkg-0.0.4 ""
.SH NAME
.B sbopkg
\ - The SlackBuilds.org Package Browser