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

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