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