remove the function to create the LOCALREPO/SLACKVER and essentially move it to the sanity checks function with the other create directory commands; lots of tweaks and cleanups to the various error code checks and displayed messages

This commit is contained in:
chess.griffin 2008-08-27 02:18:48 +00:00
parent f97244d0cf
commit cef3a124a7

View file

@ -57,34 +57,42 @@ else
fi fi
done done
if [ "$MISSING" ]; then if [ "$MISSING" ]; then
echo
echo "ERROR"
echo "$SCRIPT: Can't find a value for variable(s):" echo "$SCRIPT: Can't find a value for variable(s):"
echo "$MISSING" echo "$MISSING"
echo "Please correct this error and run $SCRIPT again." echo "Please correct this error and run $SCRIPT again."
exit 1 exit 1
fi fi
fi fi
if [ ! -d "$LOCALREPO" ]; then if [ ! -d "$LOCALREPO/$SLACKVER" ]; then
echo "Creating local repo directory $LOCALREPO for the rsync \ echo
mirror." echo "Creating local repo directory $LOCALREPO/$SLACKVER"
echo "for the rsync mirror."
echo
read -s -n 1 -p "Press any key to continue or Ctrl-C to exit." read -s -n 1 -p "Press any key to continue or Ctrl-C to exit."
echo echo
# One of these days, I'll see about implementing a cleaner way of # One of these days, I'll see about implementing a cleaner way of
# exiting with a nice error message if the user does not have # exiting with a nice error message if the user does not have
# sufficient permissions to create these directories. For now, # sufficient permissions to create these directories. For now,
# the || exit 1 will suffice. # the || exit 1 will suffice.
mkdir -p $LOCALREPO || exit 1 mkdir -p $LOCALREPO/$SLACKVER || exit 1
else else
cd $LOCALREPO cd $LOCALREPO
fi fi
if [ ! -d "$SRCDIR" ]; then if [ ! -d "$SRCDIR" ]; then
echo
echo "Creating local cache directory $SRCDIR to keep \ echo "Creating local cache directory $SRCDIR to keep \
downloaded sources." downloaded sources."
echo
read -s -n 1 -p "Press any key to continue or Ctrl-C to exit." read -s -n 1 -p "Press any key to continue or Ctrl-C to exit."
echo echo
mkdir -p $SRCDIR || exit 1 mkdir -p $SRCDIR || exit 1
fi fi
if [ ! -d "$TMP" ]; then if [ ! -d "$TMP" ]; then
echo
echo "Creating local TMP directory $TMP." echo "Creating local TMP directory $TMP."
echo
read -s -n 1 -p "Press any key to continue or Ctrl-C to exit." read -s -n 1 -p "Press any key to continue or Ctrl-C to exit."
echo echo
mkdir -p $TMP || exit 1 mkdir -p $TMP || exit 1
@ -111,72 +119,51 @@ fi
} }
check_if_repo_exists () { check_if_repo_exists () {
# Check to see if $LOCALREPO/$SLACKVER exists # Check to see if $LOCALREPO/$SLACKVER exists and not empty
if [ ! -d $LOCALREPO/$SLACKVER ]; then if [ ! -d $LOCALREPO/$SLACKVER/* ]; then
if [ "$DIAG" = 1 ]; then if [ "$DIAG" = 1 ]; then
dialog --title "ERROR" --msgbox "The directory \ dialog --title "ERROR" --msgbox "The directory \
$LOCALREPO/$SLACKVER was not found. Please make sure your \ $LOCALREPO/$SLACKVER was not found or is empty. Please make \
repository directory is set correctly and that you have done an \ sure your repository directory is set correctly and that you \
rsync first." 12 30 have done an rsync first." 12 30
continue continue
else else
echo "The directory $LOCALREPO/$SLACKVER was not found." echo
echo "Please make sure your respository directory is set" echo "ERROR"
echo "correctly and that you have done an rsync first." echo "The directory $LOCALREPO/$SLACKVER was not found"
echo "or is empty. Please make sure your respository"
echo "directory is set correctly and that you have done"
echo "an rsync first."
exit 0 exit 0
fi fi
fi fi
} }
check_slack_version () {
# Check to see if the SLACKVER directory is found; if not, offer to
# create it.
if [ ! -d "$LOCALREPO/$SLACKVER" ]; then
if [ "$DIAG" = 1 ]; then
dialog --title "Create directory?" --yesno "The directory \
$LOCALREPO/$SLACKVER was not found. Would you like to create it? \
Select YES to create or NO to cancel." 10 30
if [ $? = 0 ]; then
check_write $LOCALREPO
if [ "$WRITE" = "false" ]; then
dialog --title "ERROR" --msgbox "You do not have \
write permissions on the target directory." 8 30
continue
else
mkdir -p $LOCALREPO/$SLACKVER
dialog --title "Done" --msgbox "The directory has been \
created." 8 30
continue
fi
else
continue
fi
else
echo "$SCRIPT: Directory $LOCALREPO does not exist."
echo "Please create it and run $SCRIPT again." 1>&2
exit 1
fi
else
cd $LOCALREPO/$SLACKVER
fi
}
show_changelog () { show_changelog () {
# Show the SlackBuilds.org changelog. # Show the SlackBuilds.org changelog.
check_if_repo_exists check_if_repo_exists
cd $LOCALREPO/$SLACKVER cd $LOCALREPO/$SLACKVER
if [ "$DIAG" = 1 ]; then if [ ! -e ./ChangeLog.txt ]; then
if [ ! -e ./ChangeLog.txt ]; then if [ "$DIAG" = 1 ]; then
dialog --title "ERROR" --msgbox "No ChangeLog.txt \ dialog --title "ERROR" --msgbox "No ChangeLog.txt \
found. Please make sure your repository directory is set \ found. Please make sure your repository directory is set \
correctly and that you have done an rsync first." 10 30 correctly and that you have done an rsync first." 10 30
continue continue
else else
dialog --title "SlackBuilds.org ChangeLog.txt" --textbox \ echo
./ChangeLog.txt 0 0 echo "ERROR"
echo "No ChangeLog.txt found. Please make sure your"
echo "repository directory is set correctly and that"
echo "you have done an rsync first. Exiting."
exit 0
fi fi
else else
${PAGER:-more} ./ChangeLog.txt if [ "$DIAG" = 1 ]; then
dialog --title "SlackBuilds.org ChangeLog.txt" --textbox \
./ChangeLog.txt 0 0
else
${PAGER:-more} ./ChangeLog.txt
fi
fi fi
} }
@ -588,6 +575,7 @@ rsync_command () {
$RSYNCMIRROR/$SLACKVER/ $LOCALREPO/$SLACKVER/ $RSYNCMIRROR/$SLACKVER/ $LOCALREPO/$SLACKVER/
echo echo
echo "Rsync with SlackBuilds.org complete." echo "Rsync with SlackBuilds.org complete."
echo
rm -rf $TMP/sbopkg_rsync.lck rm -rf $TMP/sbopkg_rsync.lck
} }
@ -833,12 +821,15 @@ fi
cleanup () { cleanup () {
check_write $TMP check_write $TMP
if [ $WRITE = "false" ]; then if [ $WRITE = "false" ]; then
echo
echo "ERROR"
echo "Sbopkg attempted to clean out leftover files in \$TMP," echo "Sbopkg attempted to clean out leftover files in \$TMP,"
echo "which is set to $TMP in sbopkg.conf, but" echo "which is set to $TMP in sbopkg.conf, but"
echo "it appears that you do not have sufficient permissions to" echo "it appears that you do not have sufficient permissions to"
echo "do so. Please check your \$TMP setting in sbopkg.conf," echo "do so. Please check your \$TMP setting in sbopkg.conf,"
echo "verify that your permissions are correct, or manually" echo "verify that your permissions are correct, or manually"
echo "delete any leftover files in \$TMP. Exiting." echo "delete any leftover files in \$TMP. Exiting."
echo
exit 0 exit 0
else else
rm -rf $TMP/sbopkg_* rm -rf $TMP/sbopkg_*