-
Notifications
You must be signed in to change notification settings - Fork 28
/
install.sh
executable file
·99 lines (86 loc) · 2.98 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/sh
PYTHON=python3
BINDIR=$HOME/bin; LIBDIR=$HOME/lib/python SHAREDIR=$HOME/share
default_flavor () {
if ! $PYTHON -c 'import gtk' >/dev/null 2>&1 \
&& $PYTHON -c 'import tkinter' > /dev/null 2>&1; then
echo tk
else
echo gtk
fi
}
site_packages () {
$PYTHON -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())'
}
usage () {
cat <<EOF
Usage: ./install.sh [-f tk|gtk] [-u|-p PREFIX] [-P PYTHON] [-t TARGET]
-f: choose the flavor to install
-u: install to $HOME
-p: install to $PREFIX
-P: Python executable to use
-t: install inside TARGET (for package building)
EOF
exit
}
while getopts "f:ut:p:P:" opt
do
case "$opt" in
f) FLAVOR=$OPTARG ;;
u) BINDIR=$HOME/bin; LIBDIR=$HOME/lib/python; SHAREDIR=$HOME/share ;;
t) TARGET=$OPTARG ;;
P) PYTHON=$OPTARG ;;
p) FPYTHON=`which $PYTHON`;
BINDIR=`dirname $FPYTHON`;
SHAREDIR=`dirname $BINDIR`/share;
LIBDIR=`site_packages $PYTHON` ;;
*) usage ;;
esac
done
if [ -z "$FLAVOR" ]; then FLAVOR=`default_flavor`; fi
mkdir -p $TARGET$BINDIR $TARGET$LIBDIR $TARGET$SHAREDIR/applications \
$TARGET$SHAREDIR/pixmaps
install --mode=644 cropgui.desktop $TARGET$SHAREDIR/applications
install --mode=644 cropgui.png $TARGET$SHAREDIR/pixmaps
case $FLAVOR in
gtk)
echo "Installing gtk version of cropgui"
install --mode=755 cropgtk.py $TARGET$BINDIR/cropgui && \
install --mode=644 cropgui_common.py filechooser.py cropgui.glade \
stock-rotate-90-16.png stock-rotate-270-16.png \
$TARGET$LIBDIR
;;
tk)
echo "Installing tkinter version of cropgui"
install --mode=755 cropgui.py $TARGET$BINDIR/cropgui && \
install --mode=644 log.py cropgui_common.py $TARGET$LIBDIR
;;
*)
echo "Unknown flavor $FLAVOR"
exit 1
;;
esac
if [ $? -ne 0 ]; then exit $?; fi
chmod +x $TARGET$BINDIR/cropgui
if [ -z "$TARGET" ] && ! (cd /tmp; $PYTHON -c 'import cropgui_common') > /dev/null 2>&1; then
echo "*** Failed to import cropgui_common.py"
echo " You must add $LIBDIR to PYTHONPATH"
exit 1
fi
echo "Installed cropgui $FLAVOR"
# installation script for cropgui, a graphical front-end for lossless jpeg
# cropping
# Copyright (C) 2009 Jeff Epler <jepler@unpythonic.net>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA