Created
March 25, 2013 15:46
-
-
Save agateau/5238082 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
usage() { | |
cat <<EOF | |
USAGE: $(basename $0) <action> | |
Setup symlinks on an Ubuntu installation to work on Ubiquity | |
'action' must be one of: | |
- setup: Create initial symlinks | |
- status: List symlinks | |
- dev: Switch to -dev symlinks | |
- distro: Switch to -distro symlinks | |
EOF | |
} | |
cd $(dirname $0) | |
SRC_BASE_DIR=$PWD | |
action=$1 | |
switch_dir() { | |
local dir | |
local prefix | |
dir=$1 | |
suffix=$2 | |
if [ ! -h $dir ] ; then | |
echo "ERROR: $dir is not a link" | |
exit 1 | |
fi | |
sudo rm $dir | |
log sudo ln -s $(basename $dir)-$suffix $dir | |
} | |
log() { | |
echo "Running: $*" | |
$* | |
} | |
setup_ln() { | |
local src | |
local dst | |
src=$1 | |
dst=$2 | |
if [ -h $dst ] ; then | |
echo "Not altering $dst, already a link" | |
return 0 | |
fi | |
log sudo ln -s $src $dst | |
} | |
case "$action" in | |
dev|distro|status|setup) | |
;; | |
*) | |
echo "ERROR: Unkwown action '$action'." | |
echo "" | |
usage | |
exit 1 | |
;; | |
esac | |
cd /usr | |
dirs=" | |
./lib/ubiquity/plugins | |
./lib/ubiquity/ubiquity | |
./share/ubiquity/qt | |
./share/ubiquity-slideshow | |
" | |
for dir in $dirs ; do | |
case "$action" in | |
status) | |
ls -ld $dir | |
;; | |
setup) | |
if [ ! -d $dir-distro ] ; then | |
log sudo mv $dir $dir-distro | |
fi | |
setup_ln $dir-distro $dir | |
;; | |
dev) | |
switch_dir $dir "dev" | |
;; | |
distro) | |
switch_dir $dir "distro" | |
;; | |
esac | |
done | |
if [ "$action" = setup ] ; then | |
codedir=$SRC_BASE_DIR/code | |
slidedir=$SRC_BASE_DIR/slideshow | |
setup_ln $codedir/ubiquity/plugins lib/ubiquity/plugins-dev | |
setup_ln $codedir/ubiquity lib/ubiquity/ubiquity-dev | |
setup_ln $codedir/gui/qt share/ubiquity/qt-dev | |
setup_ln $slidedir/slideshows/kubuntu share/ubiquity-slideshow-dev | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment