* byobu-export, byobu-config:

- comprehensively rewritten, basically put all of byobu's installed
      files in ~/.byobu, and use some clever sed scripts to fixup paths
This commit is contained in:
Dustin Kirkland 2009-12-12 10:31:25 -08:00
commit 5d3d10368a
2 changed files with 46 additions and 84 deletions

View file

@ -30,7 +30,11 @@ HOME=os.getenv("HOME")
USER=os.getenv("USER")
PKG="byobu"
SHARE='/usr/share/'+PKG
if not os.path.exists(SHARE):
SHARE = "%s/.%s/%s" % (HOME, PKG, SHARE)
DOC='/usr/share/doc/'+PKG
if not os.path.exists(DOC):
DOC = "%s/.%s/%s" % (HOME, PKG, DOC)
DEF_ESC="A"
RELOAD = "If you are using the default set of keybindings, press\n<F5> or <ctrl-a-R> to activate these changes.\n\nOtherwise, exit this screen session and start a new one."
RELOAD_FLAG="/var/run/screen/S-"+USER+"/"+PKG+".reload-required"
@ -106,8 +110,7 @@ def menu(screen, size, isInstalled):
else:
return li.current()
def messagebox(screen, width, height, title, text, \
scroll=0, \
def messagebox(screen, width, height, title, text, scroll=0, \
buttons=((_("Okay"), "okay"),(_("Cancel"), "cancel", ESC)) ):
t = Textbox(width, height, text, scroll=scroll )
@ -119,10 +122,9 @@ def messagebox(screen, width, height, title, text, \
return bb.buttonPressed(g.runOnce())
def help(screen, size, config):
for fn in glob.glob(DOC+'*/help.txt'):
f=file(fn)
text=f.read()
f.close()
f=file(DOC+'/help.txt')
text=f.read()
f.close()
text=text.replace("<esckey>", getesckey(), 1)
@ -410,7 +412,7 @@ def defaultwindows(screen, size):
def install(screen, size, isInstalled):
if not isInstalled:
out = commands.getoutput("bash /usr/share/"+PKG+"/byobu-launcher-install")
out = commands.getoutput("byobu-launcher-install")
if out == "":
out = _("Byobu will be launched automatically next time you login.")
@ -418,7 +420,7 @@ def install(screen, size, isInstalled):
buttons=((_("Menu"), )))
return 100
else:
out = commands.getoutput("bash /usr/share/"+PKG+"/byobu-launcher-uninstall")
out = commands.getoutput("byobu-launcher-uninstall")
if out == "":
out = _("Byobu will not be used next time you login.")

View file

@ -17,20 +17,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
PKG="byobu"
SHARE="/usr/share/$PKG"
DIR=`mktemp -t -d $PKG.XXXXXXXX` || error "Could not create a temporary directory"
[ -d "$TMP" ] || TMP=/tmp
# Make sure we clean up $DIR if we exit for any reason
trap "rm -rf "$DIR" 2>/dev/null || true" EXIT HUP INT QUIT TERM
trap "rm -rf "$DIR" "$file" 2>/dev/null || true" EXIT HUP INT QUIT TERM
usage() {
echo
echo "Usage:"
echo " $0 [-f TARGET.tar.gz]"
echo
echo "If TARGET.tar.gz is unspecified, a randomly generated"
echo "filename will be used."
echo "If TARGET.tar.gz is unspecified, $TMP/$PKG.tar.gz will be used."
echo
exit 1
}
@ -41,37 +42,6 @@ error() {
exit 1
}
hr() {
echo "###############################################################################"
}
header() {
hr
echo "# This GNU Screen profile was generated by the $PKG-export"
echo "# program, which is part of the $PKG package, and contains a"
echo "# subset of the functionality available from the full package."
echo "#"
echo "# For more information, source code, questions, and bugs, see:"
echo "# * https://launchpad.net/$PKG"
echo "#"
echo "# Copyright (C) 2008 Canonical Ltd."
echo "#"
echo "# Author: Dustin Kirkland <kirkland@canonical.com>"
echo "#"
echo "# This program is free software: you can redistribute it and/or modify"
echo "# it under the terms of the GNU General Public License as published by"
echo "# the Free Software Foundation, version 3 of the License."
echo "#"
echo "# This program is distributed in the hope that it will be useful,"
echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
echo "# GNU General Public License for more details."
echo "#"
echo "# You should have received a copy of the GNU General Public License"
echo "# along with this program. If not, see <http://www.gnu.org/licenses/>."
hr
}
# Handle command line parameters
file=
while [ $# -gt 1 ]; do
@ -86,60 +56,50 @@ while [ $# -gt 1 ]; do
esac
done
# Handle filename
[ $# -eq 1 ] && file="$1"
if [ -z "$file" ]; then
# Generate a temp archive filename
while true; do
file=`mktemp -t $PKG.XXXXXX` || error "Could not generate random filename"
if [ ! -e "$file.tar.gz" ]; then
mv -i "$file" "$file.tar.gz"
file="$file.tar.gz"
generated=1
break
else
rm -f "$file"
fi
done
else
echo "$file" | grep -qs "\.tar\.gz$" || error "Target file must be a '.tar.gz' archive"
if [ -e "$file" ]; then
echo `gettext "File exists"` " [$file]"
echo -n "`gettext 'Remove file? [y/N] '`"
remove=`head -n1`
if [ "$remove" = "Y" -o "$remove" = "y" ]; then
rm -f "$file"
else
exit 1
fi
file="$TMP/$PKG.tar.gz"
fi
echo "$file" | grep -qs "\.tar\.gz$" || error "Target file must be a '.tar.gz' archive"
if [ -e "$file" ]; then
echo `gettext "File exists"` " [$file]"
echo -n "`gettext 'Remove file? [y/N] '`"
remove=`head -n1`
if [ "$remove" = "Y" -o "$remove" = "y" ]; then
rm -f "$file"
else
exit 1
fi
fi
# Create workspace
PROFILE="$DIR/.byobu/profile"
STATUS="$DIR/.$PKG/status"
mkdir -p "$DIR/.$PKG/bin"
for i in etc usr/bin usr/lib usr/share/doc; do
mkdir -p "$DIR/.$PKG/$i/$PKG"
done
dpkg-query --show --showformat '${Package} ${Version}\n' $PKG > "$DIR/.$PKG/version" 2>/dev/null || true
echo "http://launchpad.net/$PKG" >> "$DIR/.$PKG/version"
header > "$PROFILE"
printf "FOREGROUND=k\nBACKGROUND=W\n" > "$DIR/.$PKG/color"
# Copy necessary scripts
cat /usr/share/byobu/profiles/common >> "$PROFILE"
cp -a /usr/share/byobu/keybindings/*-keys "$DIR/.$PKG"
cp -a /usr/lib/$PKG/* "$DIR/.$PKG/bin"
cp -a /usr/bin/$PKG-status "$DIR/.$PKG"
cp -a /usr/bin/$PKG-janitor "$DIR/.$PKG"
cp -a /usr/bin/$PKG-config "$DIR/.$PKG"
cat /etc/$PKG/statusrc > "$STATUS"
cp -a /etc/$PKG "$DIR/.$PKG/etc"
cp -a /usr/share/$PKG "$DIR/.$PKG/usr/share"
cp -a /usr/share/doc/$PKG "$DIR/.$PKG/usr/share/doc"
cp -a /usr/lib/$PKG "$DIR/.$PKG/usr/lib"
cp -a /usr/bin/$PKG-* "$DIR/.$PKG/usr/bin"
cp /etc/$PKG/statusrc "$DIR/.$PKG/status"
echo "source \$HOME/.$PKG/profile" > "$DIR/.screenrc"
echo "source \$HOME/.$PKG/usr/share/$PKG/keybindings/common" > "$DIR/.$PKG/keybindings"
cd $DIR/.$PKG; ln -s usr/lib/$PKG bin; cd -
cd $DIR/.$PKG; ln -s usr/share/$PKG/profiles/common profile; cd -
# Some gardening
# Use the local byobu-config
sed -i "s:$PKG-config:\$HOME/.$PKG/$PKG-config:" "$DIR/.$PKG/"*-keys
sed -i "s:$PKG-status:\$HOME/.$PKG/$PKG-status:" "$PROFILE"
sed -i "s:$PKG-janitor:\$HOME/.$PKG/$PKG-janitor:" "$PROFILE"
cd "$DIR/.$PKG"; ln -s f-keys keybindings; cd -
# Some gardening; update paths to be $HOME-based
for i in $(ls /usr/bin/$PKG-* | grep -v "install"); do
bin=$(basename "$i")
sed -i "s:$bin:\$HOME/.$PKG$i:g" $(find $DIR -type f)
done
sed -i "s:/etc/\$PKG:\$HOME/.$PKG/etc/\$PKG:g" $(find $DIR -type f)
rm -f $DIR/.$PKG/usr/bin/$PKG-export
# tar up the results
tar --owner=root --group=root -zcf "$file" -C "$DIR" . || error "Could not create archive"