wok view get-java8-jre/stuff/get-java8-jre @ rev 25538

get-java8-jre: get version 8u361 by default
author Hans-G?nter Theisgen
date Fri Mar 03 17:41:58 2023 +0100 (15 months ago)
parents 3d69fd0979df
children
line source
1 #!/bin/sh
2 #
3 # get-java8-jre - create and install SliTaz package jre
4 #
5 # (C) 2023 SliTaz - GNU General Public License v3.
6 # Author : HGT 2022-10-12
7 # HGT 2022-12-30
8 # HGT 2023-03-03
9 #
11 # === Initialisations ===
13 PKGS_DB="/var/lib/tazpkg" # packages database directory
14 PACKAGE="jre"
15 CATEGORY="non-free"
16 TAGS="java"
17 SHORT_DESC="Oracle Java Runtime Environment."
18 MAINTAINER="nobody@slitaz.org"
19 LICENSE="non-free"
20 WEB_SITE="https://www.java.com/"
21 DEPENDS=""
23 # Declare functions check_root, status, ...
24 . /lib/libtaz.sh
25 # and make commandline options (if any) available as variables
27 is_installed()
28 {
29 if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
30 then #package is deemed to be installed
31 return 0
32 else
33 return 1
34 fi
35 }
37 # Show commandline options, if requested by --help
38 if [ "$help" == "yes" ]
39 then
40 echo "Commandline options:
41 $0
42 --version=<version>
43 --root=<path-to-root>
44 --install=yes|no
45 --keep=no|yes
46 --tmpdir=<directory-to-build-package>
47 --logfile=<logging-file>"
48 exit
49 fi
51 # Check for system administrator privileges
52 check_root
54 title "Package $PACKAGE will be build as SliTaz package and installed"
56 # Fetch latest version
57 # unless version is set by option --version
58 [ -z "$version" ] && version="latest"
60 # Install SliTaz package
61 # unless inhibited by option --install=no
62 [ -z "$install" ] && install="yes"
64 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
65 # unless option --keep=yes is given
66 [ -z "$keep" ] && keep="no"
68 # Directory for temporary files
69 TMP_DIR="$tmpdir"
70 [ -z "$tmpdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
72 # Logging file (unused by now)
73 LOG="$logfile"
74 [ -z "$logfile" ] && LOG=$TMP_DIR/get-$PACKAGE.log
76 cat <<EOT
77 Options in use:
78 root : $root/
79 version : $version
80 install package: $install
81 keep tazpkg : $keep
82 build directory: $TMP_DIR
83 logging file : $LOG
85 EOT
87 separator
88 newline
90 # === Remove package, if installed ===
91 if is_installed
92 then
93 echo "$PACKAGE is already installed."
94 echo -n "Would you like to remove and reinstall this package [y/n]? "
95 read answer
96 case "$answer" in
97 (y|Y)
98 action "Removing installed version..."
99 newline
100 tazpkg remove $PACKAGE --root="$root/"
101 [ ! is_installed ] &&
102 die "Can't remove installed version. Exiting."
103 ;;
104 (*)
105 echo "Leaving $PACKAGE untouched."
106 exit 0
107 ;;
108 esac
109 fi
111 # === Fetch archive file, if not existing ===
112 if [ "$version" == "latest" ]
113 then
114 # Because javascript is used
115 echo "Cannot determine latest version from $WEB_SITE"
116 echo "Creating version 8u361"
117 version=8u361
118 fi
119 # newer versions should be inserted here
120 case "$version" in
121 (8u361)
122 id="247936"
123 md5="0ae14417abb444ebb02b9815e2103550"
124 ;;
125 (8u351)
126 id="247125"
127 md5="10e8cce67c7843478f41411b7003171c"
128 ;;
129 (8u341)
130 id="246797"
131 md5="424b9da4b48848379167015dcc250d8d"
132 ;;
133 (8u321)
134 id="245795"
135 md5="df5ad55fdd604472a86a45a217032c7d"
136 ;;
137 (*)
138 echo "Cannot fetch archive for $version."
139 exit 0
140 ;;
141 esac
142 FILE="jre-$version-linux-i586.tar.gz"
143 WGET_URL="https://javadl.oracle.com/webapps/download/AutoDL?BundleId=${id}_${md5}"
144 VERSION=$version
146 CUR_DIR=$(pwd)
147 mkdir -p $TMP_DIR
148 cd $TMP_DIR
149 if [ -f $FILE ]
150 then
151 echo "Using existing archive file $FILE"
152 else
153 action "Fetching the archive"
154 newline
155 wget --no-check-certificate -O $FILE $WGET_URL
156 if [ ! -f $FILE ]
157 then
158 cd $CUR_DIR
159 rm -rf $TMP_DIR
160 echo "Could not transfer $FILE from $WGET_URL. Exiting."
161 exit 1
162 fi
163 fi
165 # === Extract files from archive ===
166 action "Extracting the archive"
167 newline
169 # extract archive to src
170 mkdir src
171 tar xzf $FILE -C src
172 # Remove archive file
173 rm -f $FILE
175 # extract version from directory name
176 VERSION="$(ls src | sed 's|jre||; s|_|.|')"
177 # rename extracted directory
178 [ ! -d "src/jre" ] &&
179 mv src/jre* src/jre
181 # === Create SliTaz package ===
183 # create directory for package creation
184 mkdir $PACKAGE-$VERSION
185 cd $PACKAGE-$VERSION
187 mkdir -p fs/usr/share/icons
189 mv ../src/jre/bin fs/usr
190 mv ../src/jre/lib fs/usr
192 # GUI jcontrol: we may not have bash (not really needed)
193 sed -i s'|/bin/bash|/bin/sh|' fs/usr/bin/jcontrol
195 # Icon for java
196 mv ../src/jre/plugin/desktop/sun_java.png fs/usr/share/icons/java.png
198 # set appropriate owner for all files
199 chown -R root:root fs
201 # Create desktop file for java control panel
202 mkdir -p fs/usr/share/applications
203 cat > fs/usr/share/applications/jcontrol.desktop <<EOT
204 [Desktop Entry]
205 Version=1.0
206 Encoding=UTF-8
207 Name=Java Control Panel
208 Exec=jcontrol
209 Terminal=false
210 Categories=Application
211 Icon=/usr/share/icons/java.png
212 Comment=Java Control Panel
213 Type=Application
214 Categories=Development;
215 EOT
217 # Create recipe for SliTaz package
218 cat > receipt <<EOT
219 # SliTaz package receipt.
221 PACKAGE="$PACKAGE"
222 VERSION="$VERSION"
223 CATEGORY="$CATEGORY"
224 TAGS="$TAGS"
225 SHORT_DESC="$SHORT_DESC"
226 MAINTAINER="$MAINTAINER"
227 LICENSE="$LICENSE"
228 WEB_SITE="$WEB_SITE"
230 DEPENDS="$DEPENDS"
231 EOT
233 cd ..
235 action "Creating the package $PACKAGE..."
236 # Pack
237 tazpkg pack $PACKAGE-$VERSION
238 # Remove package tree
239 rm -rf $PACKAGE-$VERSION
241 # === Install the SliTaz package ===
242 [ "$install" == "yes" ] &&
243 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
245 # === Cleanup ===
246 # Preserve package file, if requested
247 [ "$keep" == "yes" ] &&
248 ( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
249 echo Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR )
251 # Remove temporary build directory
252 cd $CUR_DIR
253 rm -rf $TMP_DIR