summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrolltarball.sh106
1 files changed, 36 insertions, 70 deletions
diff --git a/rolltarball.sh b/rolltarball.sh
index 456d3d5..8852ca2 100755
--- a/rolltarball.sh
+++ b/rolltarball.sh
@@ -22,14 +22,13 @@
# Please increase version number before each commit which includes changes to
# this script.
-MYVERSION='2.1'
+MYVERSION='2.2'
# ********** Begin functions **********
usage() {
- if [ -n "$1" ]
- then
+ if [[ -n "$1" ]] ; then
eerror $1
else
cat <<-USAGE_HEADER
@@ -91,8 +90,7 @@ eerror() {
die() {
- if [ "$#" -gt 0 ]
- then
+ if [[ "$#" -gt 0 ]] ; then
eerror ${*}
fi
exit 1
@@ -100,16 +98,14 @@ die() {
einfo() {
- if [ "${VERBOSE}" -ge "1" ]
- then
+ if [[ "${VERBOSE}" -ge "1" ]] ; then
echo -e " ${GOOD}*${NORMAL} ${*}"
fi
}
ebegin() {
- if [ "${VERBOSE}" -ge "1" ]
- then
+ if [[ "${VERBOSE}" -ge "1" ]] ; then
echo -e " ${GOOD}*${NORMAL} ${*}..."
fi
}
@@ -117,22 +113,18 @@ ebegin() {
eend() {
- if [ "$#" -eq 0 ] || ([ -n "$1" ] && [ "$1" -eq 0 ])
- then
- if [ "${VERBOSE}" -ge "1" ]
- then
+ if [[ "$#" -eq 0 ]] || { [[ -n "$1" ]] && [[ "$1" -eq 0 ]] ; } ; then
+ if [[ "${VERBOSE}" -ge "1" ]] ; then
echo -e "${ENDCOL} ${BRACKET}[ ${GOOD}ok${BRACKET} ]${NORMAL}"
fi
else
retval=$1
- if [ "$#" -ge 2 ]
- then
+ if [[ "$#" -ge 2 ]] ; then
shift
eerror "${*}"
fi
- if [ "${VERBOSE}" -ge "1" ]
- then
+ if [[ "${VERBOSE}" -ge "1" ]] ; then
echo -e "${ENDCOL} ${BRACKET}[ ${BAD}!!${BRACKET} ]${NORMAL}"
fi
return ${retval}
@@ -142,16 +134,14 @@ eend() {
ewarn() {
- if [ "${VERBOSE}" -ge "2" ]
- then
+ if [[ "${VERBOSE}" -ge "2" ]] ; then
echo -e " ${WARN}*${NORMAL} ${*}"
fi
}
edebug() {
- if [ "${VERBOSE}" -ge "4" ]
- then
+ if [[ "${VERBOSE}" -ge "4" ]] ; then
echo -e " ${HILITE}*${NORMAL} ${*}"
fi
}
@@ -202,22 +192,19 @@ UPLOAD_MIRROR=0
VERBOSE=1
# load configuration
-if [ -e ~/.apache-rolltarball ]
-then
+if [[ -e ~/.apache-rolltarball ]] ; then
. ~/.apache-rolltarball
edebug "Loaded configuration from ~/.apache-rolltarball"
fi
-if [ "${COLOR}" -eq "0" ]
-then
+if [[ "${COLOR}" -eq "0" ]] ; then
nocolor;
else
color;
fi
# Process command line
-until [ -z "$1" ]
-do
+until [[ -z "$1" ]] ; do
case "$1" in
--*)
# long options
@@ -233,7 +220,7 @@ do
no-copy) COPYTO=;;
datestamp) DATESTAMP=${VALUE};;
devspace) UPLOAD_DEV=1;;
- no-devspace) UPLOAD_DEV=0;;
+ no-devspace) UPLOAD_DEV=0;;
digest) DIGEST=1;;
no-digest) DIGEST=0;;
ebuild) MOD_EBUILD=1;;
@@ -255,8 +242,7 @@ do
# short options
OPTLIST=${1/-/}
shift
- while [ -n "${OPTLIST}" ]
- do
+ while [[ -n "${OPTLIST}" ]] ; do
OPT=${OPTLIST:0:1}
OPTLIST=${OPTLIST#?}
case "${OPT}" in
@@ -287,8 +273,7 @@ do
done
;;
*)
- if [ -n "${EBUILD}" ]
- then
+ if [[ -n "${EBUILD}" ]] ; then
usage "Only one ebuild can be specified"
else
EBUILD=$1
@@ -298,33 +283,27 @@ do
esac
done
-if [ -z "${EBUILD}" ]
-then
+if [[ -z "${EBUILD}" ]] ; then
usage "You must specify an ebuild"
fi
-if [ "${EBUILD##*.}" != "ebuild" ]
-then
+if [[ "${EBUILD##*.}" != "ebuild" ]] ; then
usage "You must specify an ebuild"
fi
-if [ ! -f ${EBUILD} ]
-then
+if [[ ! -f ${EBUILD} ]] ; then
die "Ebuild ${EBUILD} does not exist or is not a file"
fi
-if [ "${VERBOSE}" -lt "0" ]
-then
+if [[ "${VERBOSE}" -lt "0" ]] ; then
VERBOSE=0
fi
-if [ "${VERBOSE}" -gt "4" ]
-then
+if [[ "${VERBOSE}" -gt "4" ]] ; then
VERBOSE=4
fi
-if [ "${VERBOSE}" -ge "3" ]
-then
+if [[ "${VERBOSE}" -ge "3" ]] ; then
edebug "Program output enabled"
exec 9>&1
else
@@ -332,13 +311,11 @@ else
exec 9>/dev/null
fi
-if [ "${ASK}" -eq "1" ]
-then
+if [[ "${ASK}" -eq "1" ]] ; then
PRETEND=1
fi
-if [ -z "${G_USER}" ]
-then
+if [[ -z "${G_USER}" ]] ; then
G_USER="$(git log --pretty=fuller -1 | sed -n '/^Commit:/s&.*<\([[:alnum:]\._-]\+\)@.*>&\1&p')"
einfo "Detected Gentoo Developer: ${G_USER}"
fi
@@ -363,8 +340,7 @@ git pull >&9
eend $? "git update failed!" || die
new_mtime=$(stat --format=%Y $0)
-if [ "${my_mtime}" -ne "${new_mtime}" ]
-then
+if [[ "${my_mtime}" -ne "${new_mtime}" ]] ; then
einfo "A new version of $0 is available"
einfo "Please restart $0"
die
@@ -406,8 +382,7 @@ edebug " TB_DIR: ${TB_DIR}"
# simply returns true or false based on whether we are in pretend mod or not
pretend() {
- if [ "${PRETEND}" -eq 1 ]
- then
+ if [[ "${PRETEND}" -eq 1 ]] ; then
true
return $?
else
@@ -440,10 +415,8 @@ build_tarball() {
rm -rf ${TB_DIR} || ewarn "Couldn't clean up, manually remove ${TB_DIR}/"
}
- if [ -n "${COPYTO}" ]
- then
- if [ -d ${COPYTO} -a -w ${COPYTO} ]
- then
+ if [[ -n "${COPYTO}" ]] ; then
+ if [[ -d ${COPYTO} ]] && [[ -w ${COPYTO} ]] ; then
pretend && einfo " Copy ${TB} to ${COPYTO}"
pretend || {
ebegin "Copying ${TB} to ${COPYTO}"
@@ -457,8 +430,7 @@ build_tarball() {
edebug "Copy not enabled"
fi
- if [ "${UPLOAD_DEV}" -eq 1 ]
- then
+ if [[ "${UPLOAD_DEV}" -eq 1 ]] ; then
pretend && einfo " Upload ${TB} to"
pretend && einfo " http://dev.gentoo.org/~${G_USER}/dist/apache/"
pretend || {
@@ -477,8 +449,7 @@ build_tarball() {
edebug "Upload to devspace not enabled"
fi
- if [ "${UPLOAD_MIRROR}" -eq 1 ]
- then
+ if [[ "${UPLOAD_MIRROR}" -eq 1 ]] ; then
pretend && einfo " Upload ${TB} to mirror://gentoo/"
pretend || {
ebegin "Uploading ${TB} to mirror://gentoo/"
@@ -494,10 +465,8 @@ build_tarball() {
edebug "Upload to mirrors not enabled"
fi
- if [ "${MOD_EBUILD}" -eq 1 ]
- then
- if [ -r ${EBUILD} ]
- then
+ if [[ "${MOD_EBUILD}" -eq 1 ]] ; then
+ if [[ -r ${EBUILD} ]] ; then
pretend && einfo " Update GENTOO_PATCHSTAMP, GENTOO_DEVELOPER and GENTOO_PATCHNAME"
pretend || {
ebegin "Updating GENTOO_PATCHSTAMP, GENTOO_DEVELOPER and GENTOO_PATCHNAME"
@@ -517,8 +486,7 @@ build_tarball() {
edebug "Modify ebuild not enabled"
fi
- if [ "${DIGEST}" -eq 1 ]
- then
+ if [[ "${DIGEST}" -eq 1 ]] ; then
pretend && einfo " Regenerate digests"
pretend || {
ebegin "Regenerating digests"
@@ -530,13 +498,11 @@ build_tarball() {
fi
pretend && einfo "No actions actually taken"
- if [ "${ASK}" -eq 1 ]
- then
+ if [[ "${ASK}" -eq 1 ]] ; then
einfo "Would you like to perform the above actions?"
echo -n "Type 'Yes' or 'No'> "
read ask_in
- if [ "${ask_in}" == "Yes" -o "${ask_in}" == "yes" ]
- then
+ if [[ "${ask_in}" == [Yy]es ]] ; then
ASK=0
PRETEND=0
build_tarball