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

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