mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 14:24:39 -07:00
* 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:
parent
7a577e4b12
commit
5d3d10368a
2 changed files with 46 additions and 84 deletions
18
byobu-config
18
byobu-config
|
@ -30,7 +30,11 @@ HOME=os.getenv("HOME")
|
||||||
USER=os.getenv("USER")
|
USER=os.getenv("USER")
|
||||||
PKG="byobu"
|
PKG="byobu"
|
||||||
SHARE='/usr/share/'+PKG
|
SHARE='/usr/share/'+PKG
|
||||||
|
if not os.path.exists(SHARE):
|
||||||
|
SHARE = "%s/.%s/%s" % (HOME, PKG, SHARE)
|
||||||
DOC='/usr/share/doc/'+PKG
|
DOC='/usr/share/doc/'+PKG
|
||||||
|
if not os.path.exists(DOC):
|
||||||
|
DOC = "%s/.%s/%s" % (HOME, PKG, DOC)
|
||||||
DEF_ESC="A"
|
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 = "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"
|
RELOAD_FLAG="/var/run/screen/S-"+USER+"/"+PKG+".reload-required"
|
||||||
|
@ -106,8 +110,7 @@ def menu(screen, size, isInstalled):
|
||||||
else:
|
else:
|
||||||
return li.current()
|
return li.current()
|
||||||
|
|
||||||
def messagebox(screen, width, height, title, text, \
|
def messagebox(screen, width, height, title, text, scroll=0, \
|
||||||
scroll=0, \
|
|
||||||
buttons=((_("Okay"), "okay"),(_("Cancel"), "cancel", ESC)) ):
|
buttons=((_("Okay"), "okay"),(_("Cancel"), "cancel", ESC)) ):
|
||||||
|
|
||||||
t = Textbox(width, height, text, scroll=scroll )
|
t = Textbox(width, height, text, scroll=scroll )
|
||||||
|
@ -119,10 +122,9 @@ def messagebox(screen, width, height, title, text, \
|
||||||
return bb.buttonPressed(g.runOnce())
|
return bb.buttonPressed(g.runOnce())
|
||||||
|
|
||||||
def help(screen, size, config):
|
def help(screen, size, config):
|
||||||
for fn in glob.glob(DOC+'*/help.txt'):
|
f=file(DOC+'/help.txt')
|
||||||
f=file(fn)
|
text=f.read()
|
||||||
text=f.read()
|
f.close()
|
||||||
f.close()
|
|
||||||
|
|
||||||
text=text.replace("<esckey>", getesckey(), 1)
|
text=text.replace("<esckey>", getesckey(), 1)
|
||||||
|
|
||||||
|
@ -410,7 +412,7 @@ def defaultwindows(screen, size):
|
||||||
|
|
||||||
def install(screen, size, isInstalled):
|
def install(screen, size, isInstalled):
|
||||||
if not isInstalled:
|
if not isInstalled:
|
||||||
out = commands.getoutput("bash /usr/share/"+PKG+"/byobu-launcher-install")
|
out = commands.getoutput("byobu-launcher-install")
|
||||||
if out == "":
|
if out == "":
|
||||||
out = _("Byobu will be launched automatically next time you login.")
|
out = _("Byobu will be launched automatically next time you login.")
|
||||||
|
|
||||||
|
@ -418,7 +420,7 @@ def install(screen, size, isInstalled):
|
||||||
buttons=((_("Menu"), )))
|
buttons=((_("Menu"), )))
|
||||||
return 100
|
return 100
|
||||||
else:
|
else:
|
||||||
out = commands.getoutput("bash /usr/share/"+PKG+"/byobu-launcher-uninstall")
|
out = commands.getoutput("byobu-launcher-uninstall")
|
||||||
if out == "":
|
if out == "":
|
||||||
out = _("Byobu will not be used next time you login.")
|
out = _("Byobu will not be used next time you login.")
|
||||||
|
|
||||||
|
|
112
byobu-export
112
byobu-export
|
@ -17,20 +17,21 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
PKG="byobu"
|
PKG="byobu"
|
||||||
SHARE="/usr/share/$PKG"
|
|
||||||
DIR=`mktemp -t -d $PKG.XXXXXXXX` || error "Could not create a temporary directory"
|
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
|
# 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() {
|
usage() {
|
||||||
echo
|
echo
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo " $0 [-f TARGET.tar.gz]"
|
echo " $0 [-f TARGET.tar.gz]"
|
||||||
echo
|
echo
|
||||||
echo "If TARGET.tar.gz is unspecified, a randomly generated"
|
echo "If TARGET.tar.gz is unspecified, $TMP/$PKG.tar.gz will be used."
|
||||||
echo "filename will be used."
|
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -41,37 +42,6 @@ error() {
|
||||||
exit 1
|
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
|
# Handle command line parameters
|
||||||
file=
|
file=
|
||||||
while [ $# -gt 1 ]; do
|
while [ $# -gt 1 ]; do
|
||||||
|
@ -86,60 +56,50 @@ while [ $# -gt 1 ]; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Handle filename
|
||||||
[ $# -eq 1 ] && file="$1"
|
[ $# -eq 1 ] && file="$1"
|
||||||
|
|
||||||
if [ -z "$file" ]; then
|
if [ -z "$file" ]; then
|
||||||
# Generate a temp archive filename
|
file="$TMP/$PKG.tar.gz"
|
||||||
while true; do
|
fi
|
||||||
file=`mktemp -t $PKG.XXXXXX` || error "Could not generate random filename"
|
echo "$file" | grep -qs "\.tar\.gz$" || error "Target file must be a '.tar.gz' archive"
|
||||||
if [ ! -e "$file.tar.gz" ]; then
|
if [ -e "$file" ]; then
|
||||||
mv -i "$file" "$file.tar.gz"
|
echo `gettext "File exists"` " [$file]"
|
||||||
file="$file.tar.gz"
|
echo -n "`gettext 'Remove file? [y/N] '`"
|
||||||
generated=1
|
remove=`head -n1`
|
||||||
break
|
if [ "$remove" = "Y" -o "$remove" = "y" ]; then
|
||||||
else
|
rm -f "$file"
|
||||||
rm -f "$file"
|
else
|
||||||
fi
|
exit 1
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create workspace
|
# Create workspace
|
||||||
PROFILE="$DIR/.byobu/profile"
|
for i in etc usr/bin usr/lib usr/share/doc; do
|
||||||
STATUS="$DIR/.$PKG/status"
|
mkdir -p "$DIR/.$PKG/$i/$PKG"
|
||||||
mkdir -p "$DIR/.$PKG/bin"
|
done
|
||||||
dpkg-query --show --showformat '${Package} ${Version}\n' $PKG > "$DIR/.$PKG/version" 2>/dev/null || true
|
dpkg-query --show --showformat '${Package} ${Version}\n' $PKG > "$DIR/.$PKG/version" 2>/dev/null || true
|
||||||
echo "http://launchpad.net/$PKG" >> "$DIR/.$PKG/version"
|
echo "http://launchpad.net/$PKG" >> "$DIR/.$PKG/version"
|
||||||
header > "$PROFILE"
|
|
||||||
printf "FOREGROUND=k\nBACKGROUND=W\n" > "$DIR/.$PKG/color"
|
printf "FOREGROUND=k\nBACKGROUND=W\n" > "$DIR/.$PKG/color"
|
||||||
|
|
||||||
# Copy necessary scripts
|
# Copy necessary scripts
|
||||||
cat /usr/share/byobu/profiles/common >> "$PROFILE"
|
cp -a /etc/$PKG "$DIR/.$PKG/etc"
|
||||||
cp -a /usr/share/byobu/keybindings/*-keys "$DIR/.$PKG"
|
cp -a /usr/share/$PKG "$DIR/.$PKG/usr/share"
|
||||||
cp -a /usr/lib/$PKG/* "$DIR/.$PKG/bin"
|
cp -a /usr/share/doc/$PKG "$DIR/.$PKG/usr/share/doc"
|
||||||
cp -a /usr/bin/$PKG-status "$DIR/.$PKG"
|
cp -a /usr/lib/$PKG "$DIR/.$PKG/usr/lib"
|
||||||
cp -a /usr/bin/$PKG-janitor "$DIR/.$PKG"
|
cp -a /usr/bin/$PKG-* "$DIR/.$PKG/usr/bin"
|
||||||
cp -a /usr/bin/$PKG-config "$DIR/.$PKG"
|
cp /etc/$PKG/statusrc "$DIR/.$PKG/status"
|
||||||
cat /etc/$PKG/statusrc > "$STATUS"
|
|
||||||
echo "source \$HOME/.$PKG/profile" > "$DIR/.screenrc"
|
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
|
# Some gardening; update paths to be $HOME-based
|
||||||
# Use the local byobu-config
|
for i in $(ls /usr/bin/$PKG-* | grep -v "install"); do
|
||||||
sed -i "s:$PKG-config:\$HOME/.$PKG/$PKG-config:" "$DIR/.$PKG/"*-keys
|
bin=$(basename "$i")
|
||||||
sed -i "s:$PKG-status:\$HOME/.$PKG/$PKG-status:" "$PROFILE"
|
sed -i "s:$bin:\$HOME/.$PKG$i:g" $(find $DIR -type f)
|
||||||
sed -i "s:$PKG-janitor:\$HOME/.$PKG/$PKG-janitor:" "$PROFILE"
|
done
|
||||||
cd "$DIR/.$PKG"; ln -s f-keys keybindings; cd -
|
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 up the results
|
||||||
tar --owner=root --group=root -zcf "$file" -C "$DIR" . || error "Could not create archive"
|
tar --owner=root --group=root -zcf "$file" -C "$DIR" . || error "Could not create archive"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue