wok view get-google-earth/stuff/get-google-earth @ rev 25037

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