rev |
line source |
Hans-G?nter@21192
|
1 #!/bin/sh
|
Hans-G?nter@21192
|
2 #
|
Hans-G?nter@21192
|
3 # get-google-earth - create and install SliTaz package google-earth
|
Hans-G?nter@21192
|
4 #
|
Hans-G?nter@22837
|
5 # (C) 2020 SliTaz - GNU General Public License v3.
|
Hans-G?nter@21192
|
6 # Author : unknown
|
Hans-G?nter@21192
|
7 # modified by HGT on 2019-04-05
|
Hans-G?nter@22837
|
8 # modified by HGT on 2020-02-10
|
Hans-G?nter@21192
|
9 #
|
pascal@589
|
10
|
Hans-G?nter@21192
|
11 # === Initialisations ===
|
pascal@1706
|
12
|
Hans-G?nter@21192
|
13 PKGS_DB="/var/lib/tazpkg" # packages database directory
|
Hans-G?nter@21192
|
14 PACKAGE="google-earth" # package to create and install
|
Hans-G?nter@22837
|
15 CATEGORY="non-free"
|
Hans-G?nter@22837
|
16 TAGS="maps"
|
Hans-G?nter@22837
|
17 LICENSE="non-free"
|
Hans-G?nter@21192
|
18 WEB_SITE="https://google.com/earth/"
|
Hans-G?nter@21192
|
19 DEPENDS="libglu-mesa"
|
Hans-G?nter@21192
|
20
|
Hans-G?nter@21192
|
21 # Declare functions check_root, status, ...
|
Hans-G?nter@21192
|
22 . /lib/libtaz.sh
|
Hans-G?nter@21192
|
23 # and make commandline options (if any) available as variables
|
Hans-G?nter@21192
|
24
|
Hans-G?nter@21192
|
25 is_installed()
|
Hans-G?nter@21192
|
26 {
|
Hans-G?nter@21192
|
27 if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
|
Hans-G?nter@21192
|
28 then #package is deemed to be installed
|
Hans-G?nter@21192
|
29 return 0
|
Hans-G?nter@21192
|
30 else
|
Hans-G?nter@21192
|
31 return 1
|
Hans-G?nter@21192
|
32 fi
|
Hans-G?nter@21192
|
33 }
|
Hans-G?nter@21192
|
34
|
Hans-G?nter@21192
|
35
|
Hans-G?nter@21192
|
36 # Show commandline options, if requested by --help
|
Hans-G?nter@21192
|
37 if [ "$help" == "yes" ]
|
Hans-G?nter@21192
|
38 then
|
Hans-G?nter@21192
|
39 echo "Commandline options:
|
Hans-G?nter@21192
|
40 $0
|
Hans-G?nter@21192
|
41 --version=<version>
|
Hans-G?nter@21192
|
42 --root=<path-to-root>
|
Hans-G?nter@21192
|
43 --install=yes|no
|
Hans-G?nter@21192
|
44 --keep=no|yes
|
Hans-G?nter@21192
|
45 --tmpdir=<directory-to-build-package>"
|
Hans-G?nter@21192
|
46 exit
|
pascal@589
|
47 fi
|
pascal@589
|
48
|
Hans-G?nter@21192
|
49 # Check for system administrator privileges
|
Hans-G?nter@21192
|
50 check_root
|
Hans-G?nter@21192
|
51
|
Hans-G?nter@21192
|
52 title "Package $PACKAGE will be build as SliTaz package and installed"
|
Hans-G?nter@21192
|
53
|
Hans-G?nter@21192
|
54 # Fetch latest version, unless version is set by option --version
|
Hans-G?nter@21192
|
55 [ -z "$version" ] && version="latest"
|
Hans-G?nter@21192
|
56
|
Hans-G?nter@21192
|
57 # Install SliTaz package, unless inhibited by option --install=no
|
Hans-G?nter@21192
|
58 [ -z "$install" ] && install="yes"
|
Hans-G?nter@21192
|
59
|
Hans-G?nter@21192
|
60 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
|
Hans-G?nter@21192
|
61 # unless option --keep=yes is given
|
Hans-G?nter@21192
|
62 [ -z "$keep" ] && keep="no"
|
Hans-G?nter@21192
|
63
|
Hans-G?nter@21192
|
64 # Directory for temporary files
|
Hans-G?nter@22837
|
65 TMP_DIR="$tmpdir"
|
Hans-G?nter@22837
|
66 [ -z "$tmpdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
|
Hans-G?nter@21192
|
67
|
Hans-G?nter@21192
|
68 # Logging file (unused by now)
|
Hans-G?nter@22837
|
69 LOG="$logfile"
|
Hans-G?nter@22837
|
70 [ -z "$logfile" ] && LOG=$TMP_DIR/get-$PACKAGE.log
|
Hans-G?nter@21192
|
71
|
Hans-G?nter@21192
|
72 cat <<EOT
|
Hans-G?nter@21192
|
73 Options in use:
|
Hans-G?nter@21192
|
74 root : $root/
|
Hans-G?nter@21192
|
75 version : $version
|
Hans-G?nter@21192
|
76 install package: $install
|
Hans-G?nter@21192
|
77 keep tazpkg : $keep
|
Hans-G?nter@21192
|
78 build directory: $TMP_DIR
|
Hans-G?nter@21192
|
79
|
Hans-G?nter@21192
|
80 EOT
|
Hans-G?nter@21192
|
81
|
Hans-G?nter@21192
|
82 separator; newline
|
Hans-G?nter@21192
|
83
|
Hans-G?nter@21192
|
84 # === Remove package, if installed ===
|
Hans-G?nter@22837
|
85 if is_installed
|
Hans-G?nter@22837
|
86 then
|
Hans-G?nter@22837
|
87 echo "$PACKAGE is already installed."
|
Hans-G?nter@22837
|
88 echo -n "Would you like to remove and reinstall this package [y/n]? "
|
Hans-G?nter@22837
|
89 read answer
|
Hans-G?nter@22837
|
90 case "$answer" in
|
Hans-G?nter@22837
|
91 y|Y)
|
Hans-G?nter@22837
|
92 action "Removing installed version..."
|
Hans-G?nter@22837
|
93 tazpkg remove $PACKAGE --root="$root/"
|
Hans-G?nter@22837
|
94 [ ! is_installed ] &&
|
Hans-G?nter@22837
|
95 die "Can't remove installed version. Exiting."
|
Hans-G?nter@22837
|
96 ;;
|
Hans-G?nter@22837
|
97 *)
|
Hans-G?nter@22837
|
98 echo "Leaving $PACKAGE untouched."
|
Hans-G?nter@22837
|
99 exit 0
|
Hans-G?nter@22837
|
100 ;;
|
Hans-G?nter@22837
|
101 esac
|
pascal@589
|
102 fi
|
pascal@589
|
103
|
Hans-G?nter@21192
|
104 # === Fetch archive file, if not existing ===
|
pascal@593
|
105
|
Hans-G?nter@21192
|
106 if [ "$version" == "latest" ]
|
Hans-G?nter@21192
|
107 then
|
Hans-G?nter@21192
|
108 FILE="google-earth-stable_current_i386.deb"
|
Hans-G?nter@21192
|
109 WGET_URL="https://dl.google.com/dl/earth/client/current/$FILE"
|
Hans-G?nter@21192
|
110 else
|
Hans-G?nter@21192
|
111 # only available version is 7.3.0.3832-r0
|
Hans-G?nter@21192
|
112 FILE="google-earth-pro-stable_${version}_i386.deb"
|
Hans-G?nter@21192
|
113 V1=${version%%.*}
|
Hans-G?nter@21192
|
114 V3=${version%.*}
|
Hans-G?nter@21192
|
115 WGET_URL="https://dl.google.com/dl/earth/client/GE$V1/release_${V3//./_}/$FILE"
|
pascal@3893
|
116 fi
|
pascal@3893
|
117
|
Hans-G?nter@21192
|
118 CUR_DIR=$(pwd)
|
Hans-G?nter@21192
|
119 mkdir -p $TMP_DIR
|
Hans-G?nter@21192
|
120 cd $TMP_DIR
|
Hans-G?nter@21192
|
121 if [ -f $FILE ]
|
Hans-G?nter@21192
|
122 then
|
Hans-G?nter@21192
|
123 echo "Using existing archive file $FILE"
|
Hans-G?nter@21192
|
124 else
|
Hans-G?nter@21192
|
125 action "Fetching the archive"
|
Hans-G?nter@21192
|
126 newline
|
Hans-G?nter@21192
|
127 wget --no-check-certificate $WGET_URL
|
Hans-G?nter@21192
|
128 if [ ! -f $FILE ]
|
Hans-G?nter@21192
|
129 then
|
Hans-G?nter@21192
|
130 cd $CUR_DIR
|
Hans-G?nter@21192
|
131 rm -rf $TMP_DIR
|
Hans-G?nter@22837
|
132 echo "Could not transfer $FILE from $WGET_URL. Exiting."
|
Hans-G?nter@21192
|
133 exit 1
|
Hans-G?nter@21192
|
134 fi
|
Hans-G?nter@21192
|
135 fi
|
pascal@589
|
136
|
Hans-G?nter@21192
|
137 # === Extract files from archive ===
|
Hans-G?nter@21192
|
138 action "Extracting the archive"
|
pascal@589
|
139
|
Hans-G?nter@21192
|
140 mkdir $PACKAGE
|
Hans-G?nter@21192
|
141 # Extract metadata
|
Hans-G?nter@21192
|
142 dpkg-deb -e $FILE $PACKAGE/meta
|
Hans-G?nter@21192
|
143 # Extract files
|
Hans-G?nter@21192
|
144 dpkg-deb -x $FILE $PACKAGE/fs
|
Hans-G?nter@21192
|
145 status
|
pascal@1706
|
146
|
Hans-G?nter@21192
|
147 # Remove archive file
|
Hans-G?nter@21192
|
148 rm -f $FILE
|
pascal@589
|
149
|
Hans-G?nter@21192
|
150 # === Create SliTaz package ===
|
jozee@4989
|
151
|
Hans-G?nter@21192
|
152 # Prepare metadata for SliTaz package
|
Hans-G?nter@21192
|
153 sed '/^Description:/,$!d; /^Description:/d' $PACKAGE/meta/control \
|
Hans-G?nter@21192
|
154 > $PACKAGE/description.txt
|
Hans-G?nter@21192
|
155
|
Hans-G?nter@21192
|
156 SHORT_DESC="$(sed '/^Description:/!d; s/.*: //' $PACKAGE/meta/control)"
|
Hans-G?nter@21192
|
157 MAINTAINER="$(sed '/^Maintainer:/!d; s/.*: //' $PACKAGE/meta/control)"
|
Hans-G?nter@21192
|
158 VERSION="$( sed '/^Version:/!d; s/.*: //' $PACKAGE/meta/control)"
|
Hans-G?nter@21192
|
159 VERSION=${VERSION%-*} # remove -r* suffix
|
Hans-G?nter@21192
|
160
|
Hans-G?nter@21192
|
161 mv $PACKAGE $PACKAGE-$VERSION
|
Hans-G?nter@21192
|
162
|
Hans-G?nter@21192
|
163 cd $PACKAGE-$VERSION
|
Hans-G?nter@21192
|
164
|
Hans-G?nter@21192
|
165 # Create recipe for SliTaz package
|
Hans-G?nter@21192
|
166 cat > receipt <<EOT
|
Hans-G?nter@21192
|
167 # SliTaz package receipt.
|
Hans-G?nter@21192
|
168
|
Hans-G?nter@21192
|
169 PACKAGE="$PACKAGE"
|
pascal@589
|
170 VERSION="$VERSION"
|
Hans-G?nter@21192
|
171 CATEGORY="$CATEGORY"
|
Hans-G?nter@22837
|
172 TAGS="$TAGS"
|
Hans-G?nter@21192
|
173 SHORT_DESC="$SHORT_DESC"
|
Hans-G?nter@21192
|
174 MAINTAINER="$MAINTAINER"
|
Hans-G?nter@22837
|
175 LICENSE="$LICENSE"
|
Hans-G?nter@21192
|
176 WEB_SITE="$WEB_SITE"
|
Hans-G?nter@21192
|
177
|
pascal@1706
|
178 DEPENDS="$DEPENDS"
|
Hans-G?nter@21192
|
179
|
Hans-G?nter@21192
|
180 post_install()
|
Hans-G?nter@21192
|
181 {
|
Hans-G?nter@21192
|
182 # Due to different conventions in Debian
|
Hans-G?nter@21192
|
183 [ -L /lib/ld-lsb.so.3 ] || ln -s ld-2.14.1.so /lib/ld-lsb.so.3
|
Hans-G?nter@21192
|
184 }
|
pascal@589
|
185 EOT
|
pascal@1173
|
186
|
Hans-G?nter@21192
|
187 # Copy desktop file
|
Hans-G?nter@21192
|
188 cp fs/opt/google/earth/pro/google-earth-pro.desktop \
|
Hans-G?nter@21192
|
189 fs/usr/share/applications/$PACKAGE.desktop
|
Hans-G?nter@21192
|
190
|
Hans-G?nter@21192
|
191 cd $TMP_DIR
|
Hans-G?nter@21192
|
192
|
Hans-G?nter@21192
|
193 action "Creating the package $PACKAGE..."
|
pascal@1173
|
194 # Pack
|
jozee@4989
|
195 tazpkg pack $PACKAGE-$VERSION
|
jozee@4989
|
196
|
Hans-G?nter@21192
|
197 # Remove package tree
|
jozee@4989
|
198 rm -rf $PACKAGE-$VERSION
|
pascal@589
|
199
|
Hans-G?nter@21192
|
200 # === Install the SliTaz package ===
|
Hans-G?nter@21192
|
201 [ "$install" == "yes" ] &&
|
Hans-G?nter@21192
|
202 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
|
pascal@589
|
203
|
Hans-G?nter@21192
|
204 # === Cleanup ===
|
Hans-G?nter@21192
|
205 # Preserve package file, if requested
|
Hans-G?nter@22837
|
206 [ "$keep" == "yes" ] &&
|
Hans-G?nter@22837
|
207 ( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
|
Hans-G?nter@22837
|
208 echo Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR )
|
Hans-G?nter@21192
|
209
|
Hans-G?nter@21192
|
210 # Remove temporary build directory
|
pascal@593
|
211 cd $CUR_DIR
|
pascal@593
|
212 rm -rf $TMP_DIR
|