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

created recipe for get-java8-jre
author Hans-G?nter Theisgen
date Wed Oct 12 10:36:11 2022 +0100 (18 months ago)
parents
children 3d69fd0979df
line source
1 #!/bin/sh
2 #
3 # get-java8-jre - create and install SliTaz package jre
4 #
5 # (C) 2022 SliTaz - GNU General Public License v3.
6 # Author : HGT 2022-10-12
7 #
9 # === Initialisations ===
11 PKGS_DB="/var/lib/tazpkg" # packages database directory
12 PACKAGE="jre"
13 CATEGORY="non-free"
14 TAGS="java"
15 SHORT_DESC="Oracle Java Runtime Environment."
16 MAINTAINER="nobody@slitaz.org"
17 LICENSE="non-free"
18 WEB_SITE="https://www.java.com/"
19 DEPENDS=""
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 }
35 # Show commandline options, if requested by --help
36 if [ "$help" == "yes" ]
37 then
38 echo "Commandline options:
39 $0
40 --version=<version>
41 --root=<path-to-root>
42 --install=yes|no
43 --keep=no|yes
44 --tmpdir=<directory-to-build-package>
45 --logfile=<logging-file>"
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
55 # unless version is set by option --version
56 [ -z "$version" ] && version="latest"
58 # Install SliTaz package
59 # unless inhibited by option --install=no
60 [ -z "$install" ] && install="yes"
62 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
63 # unless option --keep=yes is given
64 [ -z "$keep" ] && keep="no"
66 # Directory for temporary files
67 TMP_DIR="$tmpdir"
68 [ -z "$tmpdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
70 # Logging file (unused by now)
71 LOG="$logfile"
72 [ -z "$logfile" ] && LOG=$TMP_DIR/get-$PACKAGE.log
74 cat <<EOT
75 Options in use:
76 root : $root/
77 version : $version
78 install package: $install
79 keep tazpkg : $keep
80 build directory: $TMP_DIR
81 logging file : $LOG
83 EOT
85 separator
86 newline
88 # === Remove package, if installed ===
89 if is_installed
90 then
91 echo "$PACKAGE is already installed."
92 echo -n "Would you like to remove and reinstall this package [y/n]? "
93 read answer
94 case "$answer" in
95 (y|Y)
96 action "Removing installed version..."
97 newline
98 tazpkg remove $PACKAGE --root="$root/"
99 [ ! is_installed ] &&
100 die "Can't remove installed version. Exiting."
101 ;;
102 (*)
103 echo "Leaving $PACKAGE untouched."
104 exit 0
105 ;;
106 esac
107 fi
109 # === Fetch archive file, if not existing ===
110 if [ "$version" == "latest" ]
111 then
112 # Because javascript is used
113 echo "Cannot determine latest version from $WEB_SITE"
114 echo "Creating version 8u341"
115 version=8u341
116 fi
117 # newer versions should be inserted here
118 case "$version" in
119 (8u341)
120 id="246797"
121 md5="424b9da4b48848379167015dcc250d8d"
122 ;;
123 (8u321)
124 id="245795"
125 md5="df5ad55fdd604472a86a45a217032c7d"
126 ;;
127 (*)
128 echo "Cannot fetch archive for $version."
129 exit 0
130 ;;
131 esac
132 FILE="jre-$version-linux-i586.tar.gz"
133 WGET_URL="https://javadl.oracle.com/webapps/download/AutoDL?BundleId=${id}_${md5}"
134 VERSION=$version
136 CUR_DIR=$(pwd)
137 mkdir -p $TMP_DIR
138 cd $TMP_DIR
139 if [ -f $FILE ]
140 then
141 echo "Using existing archive file $FILE"
142 else
143 action "Fetching the archive"
144 newline
145 wget --no-check-certificate -O $FILE $WGET_URL
146 if [ ! -f $FILE ]
147 then
148 cd $CUR_DIR
149 rm -rf $TMP_DIR
150 echo "Could not transfer $FILE from $WGET_URL. Exiting."
151 exit 1
152 fi
153 fi
155 # === Extract files from archive ===
156 action "Extracting the archive"
157 newline
159 # extract archive to src
160 mkdir src
161 tar xzf $FILE -C src
162 # Remove archive file
163 rm -f $FILE
165 # extract version from directory name
166 VERSION="$(ls src | sed 's|jre||; s|_|.|')"
167 # rename extracted directory
168 [ ! -d "src/jre" ] &&
169 mv src/jre* src/jre
171 # === Create SliTaz package ===
173 # create directory for package creation
174 mkdir $PACKAGE-$VERSION
175 cd $PACKAGE-$VERSION
177 mkdir -p fs/usr/share/icons
179 mv ../src/jre/bin fs/usr
180 mv ../src/jre/lib fs/usr
182 # GUI jcontrol: we may not have bash (not really needed)
183 sed -i s'|/bin/bash|/bin/sh|' fs/usr/bin/jcontrol
185 # Icon for java
186 mv ../src/jre/plugin/desktop/sun_java.png fs/usr/share/icons/java.png
188 # set appropriate owner for all files
189 chown -R root:root fs
191 # Create desktop file for java control panel
192 mkdir -p fs/usr/share/applications
193 cat > fs/usr/share/applications/jcontrol.desktop <<EOT
194 [Desktop Entry]
195 Version=1.0
196 Encoding=UTF-8
197 Name=Java Control Panel
198 Exec=jcontrol
199 Terminal=false
200 Categories=Application
201 Icon=/usr/share/icons/java.png
202 Comment=Java Control Panel
203 Type=Application
204 Categories=Development;
205 EOT
207 # Create recipe for SliTaz package
208 cat > receipt <<EOT
209 # SliTaz package receipt.
211 PACKAGE="$PACKAGE"
212 VERSION="$VERSION"
213 CATEGORY="$CATEGORY"
214 TAGS="$TAGS"
215 SHORT_DESC="$SHORT_DESC"
216 MAINTAINER="$MAINTAINER"
217 LICENSE="$LICENSE"
218 WEB_SITE="$WEB_SITE"
220 DEPENDS="$DEPENDS"
221 EOT
223 cd ..
225 action "Creating the package $PACKAGE..."
226 # Pack
227 tazpkg pack $PACKAGE-$VERSION
228 # Remove package tree
229 rm -rf $PACKAGE-$VERSION
231 # === Install the SliTaz package ===
232 [ "$install" == "yes" ] &&
233 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
235 # === Cleanup ===
236 # Preserve package file, if requested
237 [ "$keep" == "yes" ] &&
238 ( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
239 echo Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR )
241 # Remove temporary build directory
242 cd $CUR_DIR
243 rm -rf $TMP_DIR