|
1 |
#!/bin/bash
|
|
2 |
#
|
|
3 |
|
|
4 |
#set -x
|
|
5 |
|
|
6 |
if [ ! -f "gvSIG.sh" ] ; then
|
|
7 |
echo "Usage: $0"
|
|
8 |
echo " Current folder can be a gvSIG installation"
|
|
9 |
exit -1
|
|
10 |
fi
|
|
11 |
|
|
12 |
GVSIG_INSTALLTION="$PWD"
|
|
13 |
TARGET_FOLDER="/tmp/gvsig-deb"
|
|
14 |
|
|
15 |
function message() {
|
|
16 |
echo $@
|
|
17 |
}
|
|
18 |
|
|
19 |
#=============================
|
|
20 |
# Load debian.control values
|
|
21 |
#
|
|
22 |
typeset -l Package
|
|
23 |
eval $(sed -n 's/\([A-Za-z0-9]*\)[ ]*:[ ]*\(.*\)/\1="\2"/p' "$GVSIG_INSTALLTION/tools/debian.control")
|
|
24 |
|
|
25 |
#=============================
|
|
26 |
# Prepare target folder
|
|
27 |
|
|
28 |
message "Prepare package folder in $TARGET_FOLDER"
|
|
29 |
sudo rm -rf "$TARGET_FOLDER"
|
|
30 |
mkdir -p "$TARGET_FOLDER"
|
|
31 |
|
|
32 |
mkdir -p "$TARGET_FOLDER/DEBIAN"
|
|
33 |
mkdir -p "$TARGET_FOLDER/usr/bin"
|
|
34 |
mkdir -p "$TARGET_FOLDER/usr/share/applications"
|
|
35 |
mkdir -p "$TARGET_FOLDER/usr/share/menu"
|
|
36 |
mkdir -p "$TARGET_FOLDER/usr/share/pixmaps"
|
|
37 |
mkdir -p "$TARGET_FOLDER/usr/local/bin"
|
|
38 |
mkdir -p "$TARGET_FOLDER/usr/local/lib/${Package}/${Version}-${Architecture}"
|
|
39 |
|
|
40 |
#===========================================
|
|
41 |
# Create gvsig launcher in /usr/local/bin
|
|
42 |
|
|
43 |
message "Create gvsig launcher in $TARGET_FOLDER/usr/local/bin"
|
|
44 |
echo "#!/bin/sh
|
|
45 |
exec /usr/local/lib/${Package}/default/gvSIG.sh
|
|
46 |
" > "$TARGET_FOLDER/usr/local/bin/${Package}"
|
|
47 |
|
|
48 |
#============================================
|
|
49 |
# Link gvSIG launcher to /usr/bin
|
|
50 |
|
|
51 |
message "Link gvSIG launcher to $TARGET_FOLDER/usr/bin"
|
|
52 |
cd "$TARGET_FOLDER/usr/bin"
|
|
53 |
ln -s "../local/bin/${Package}" .
|
|
54 |
|
|
55 |
#============================================
|
|
56 |
# Link installation to default folder
|
|
57 |
|
|
58 |
message "Link installation to default folder"
|
|
59 |
cd "$TARGET_FOLDER/usr/local/lib/${Package}"
|
|
60 |
ln -s "${Version}-${Architecture}" "default"
|
|
61 |
|
|
62 |
#===========================================
|
|
63 |
# Create postinst for install dsktop icons
|
|
64 |
|
|
65 |
message "Creating post installation script"
|
|
66 |
cat <<EOF-postinst >"$TARGET_FOLDER/DEBIAN/postinst"
|
|
67 |
#!/bin/sh
|
|
68 |
set -e
|
|
69 |
if [ "$1" = "configure" ] && [ -x "`which update-menus 2>/dev/null`" ]; then
|
|
70 |
update-menus
|
|
71 |
fi
|
|
72 |
EOF-postinst
|
|
73 |
|
|
74 |
|
|
75 |
#===========================================
|
|
76 |
# Create menu entry file, icon and desktop file
|
|
77 |
|
|
78 |
message "Create desktop file, icon and menu entry file"
|
|
79 |
|
|
80 |
DesktopCategory="Graphics"
|
|
81 |
cp "$GVSIG_INSTALLTION/gvsig-icon48x48.png" "$TARGET_FOLDER/usr/share/pixmaps/${Package}.png"
|
|
82 |
|
|
83 |
cat <<EOF-menu >"$TARGET_FOLDER/usr/share/menu/${Package}"
|
|
84 |
?package(${Package}):command="/usr/local/bin/${Package}" icon="/usr/share/pixmaps/${Package}.png" needs="X11" section="Applications/${DesktopCategory}" title="gvSIG desktop" hotkey="gvSIG"
|
|
85 |
EOF-menu
|
|
86 |
|
|
87 |
cat <<EOF-desktop-file >"$TARGET_FOLDER/usr/share/applications/${Package}.desktop"
|
|
88 |
Name=gvSIG desktop
|
|
89 |
Version=${Version}
|
|
90 |
Exec=${Package}
|
|
91 |
Comment=
|
|
92 |
Icon=/usr/share/pixmaps/${Package}.png
|
|
93 |
Type=Application
|
|
94 |
Terminal=false
|
|
95 |
StartupNotify=true
|
|
96 |
Encoding=UTF-8
|
|
97 |
Categories=${DesktopCategory};
|
|
98 |
EOF-desktop-file
|
|
99 |
|
|
100 |
#============================================
|
|
101 |
# Copy files to target folder
|
|
102 |
|
|
103 |
message "Copy installation files..."
|
|
104 |
cd "$GVSIG_INSTALLTION"
|
|
105 |
|
|
106 |
cp "tools/debian.control" "$TARGET_FOLDER/DEBIAN/control"
|
|
107 |
cp -R . "$TARGET_FOLDER/usr/local/lib/${Package}/${Version}-${Architecture}"
|
|
108 |
|
|
109 |
#============================================
|
|
110 |
# Fix permissions
|
|
111 |
|
|
112 |
message "Fix permissions"
|
|
113 |
cd "$TARGET_FOLDER"
|
|
114 |
|
|
115 |
find . -type d -exec chmod go=rx,u=rwx {} ';'
|
|
116 |
find . -type f -exec chmod go=r,u=rw {} ';'
|
|
117 |
|
|
118 |
chmod go=rx,u=rwx "DEBIAN/postinst"
|
|
119 |
chmod go=r,u=rw "usr/share/applications/${Package}.desktop"
|
|
120 |
chmod go=rx,u=rwx "usr/local/bin/${Package}"
|
|
121 |
chmod go=rx,u=rwx "usr/local/lib/${Package}/${Version}-${Architecture}/gvSIG.sh"
|
|
122 |
|
|
123 |
sudo chown -R root.root .
|
|
124 |
|
|
125 |
#============================================
|
|
126 |
# Create debian package
|
|
127 |
|
|
128 |
cd "$TARGET_FOLDER"
|
|
129 |
|
|
130 |
message "Creating debian package in $TARGET_FOLDER/${Package}_${Version}_${Architecture}.deb"
|
|
131 |
sudo dpkg -b . "${Package}_${Version}_${Architecture}.deb"
|
|
132 |
|
0 |
133 |
|