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