wok annotate get-vivaldi/stuff/get-vivaldi @ rev 25037

Up glza (0.11.4)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat May 21 21:38:29 2022 +0000 (2022-05-21)
parents e5a22a781f60
children
rev   line source
al@18545 1 #!/bin/sh
Hans-G?nter@24038 2 #
Hans-G?nter@24038 3 # get-vivaldi - create and install SliTaz package vivaldi
Hans-G?nter@24038 4 #
Hans-G?nter@24038 5 # (C) 2021 SliTaz - GNU General Public License v3.
Hans-G?nter@24038 6 # Author : Aleksej Bobylev
Hans-G?nter@24038 7 # modified by Hans-Günter Theisgen on 2021-04-13
Hans-G?nter@24038 8 #
al@18545 9
Hans-G?nter@24038 10 # === Initialisations ===
al@18545 11
Hans-G?nter@24038 12 PKGS_DB="/var/lib/tazpkg" # packages database directory
Hans-G?nter@24038 13 PACKAGE="vivaldi"
Hans-G?nter@24038 14 CATEGORY="non-free"
Hans-G?nter@24038 15 SHORT=DESC="An advanced browser made with the power user in mind."
Hans-G?nter@24038 16 MAINTAINER="nobody@slitaz.org"
Hans-G?nter@24038 17 LICENSE="non-free"
Hans-G?nter@24038 18 WEB_SITE="https://vivaldi.com/"
Hans-G?nter@24038 19 # at least valid for 3.7.2218.52-1:
Hans-G?nter@24038 20 DEPENDS="at-spi2-atk bash GConf gtk+3 libcups libexif libxkbcommon mesa-wayland nss xorg-libxshmfence"
Hans-G?nter@24038 21
Hans-G?nter@24038 22 # Declare functions check_root, status, ...
Hans-G?nter@24038 23 . /lib/libtaz.sh
Hans-G?nter@24038 24 # and make commandline options (if any) available as variables
Hans-G?nter@24038 25
Hans-G?nter@24038 26 is_installed()
Hans-G?nter@24038 27 {
Hans-G?nter@24038 28 if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
Hans-G?nter@24038 29 then #package is deemed to be installed
Hans-G?nter@24038 30 return 0
Hans-G?nter@24038 31 else
Hans-G?nter@24038 32 return 1
Hans-G?nter@24038 33 fi
Hans-G?nter@24038 34 }
Hans-G?nter@24038 35
Hans-G?nter@24038 36 # Show commandline options, if requested by --help
Hans-G?nter@24038 37 if [ "$help" == "yes" ]
Hans-G?nter@24038 38 then
Hans-G?nter@24038 39 echo "Commandline options:
Hans-G?nter@24038 40 $0
Hans-G?nter@24038 41 --version=<version>
Hans-G?nter@24038 42 --root=<path-to-root>
Hans-G?nter@24038 43 --install=yes|no
Hans-G?nter@24038 44 --keep=no|yes
Hans-G?nter@24038 45 --tmpdir=<directory-to-build-package>
Hans-G?nter@24038 46 --logfile=<logging-file>"
Hans-G?nter@24038 47 exit
al@18545 48 fi
al@18545 49
Hans-G?nter@24038 50 # Check for system administrator privileges
Hans-G?nter@24038 51 check_root
Hans-G?nter@24038 52
Hans-G?nter@24038 53 title "Package $PACKAGE will be build as SliTaz package and installed"
Hans-G?nter@24038 54
Hans-G?nter@24038 55 # Fetch latest version, unless version is set by option --version
Hans-G?nter@24038 56 # For available versions look at https://vivaldi.com/download/archive/
Hans-G?nter@24038 57 [ -z "$version" ] && version="latest"
Hans-G?nter@24038 58
Hans-G?nter@24038 59 # Install SliTaz package, unless inhibited by option --install=no
Hans-G?nter@24038 60 [ -z "$install" ] && install="yes"
Hans-G?nter@24038 61
Hans-G?nter@24038 62 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
Hans-G?nter@24038 63 # unless option --keep=yes is given
Hans-G?nter@24038 64 [ -z "$keep" ] && keep="no"
Hans-G?nter@24038 65
Hans-G?nter@24038 66 # Directory for temporary files
Hans-G?nter@24038 67 TMP_DIR="$tmpdir"
Hans-G?nter@24038 68 [ -z "$tmpdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
Hans-G?nter@24038 69
Hans-G?nter@24038 70 # Logging file (unused by now)
Hans-G?nter@24038 71 LOG="$logfile"
Hans-G?nter@24038 72 [ -z "$logfile" ] && LOG=$TMP_DIR/get-$PACKAGE.log
Hans-G?nter@24038 73
Hans-G?nter@24038 74 cat <<EOT
Hans-G?nter@24038 75 Options in use:
Hans-G?nter@24038 76 root : $root/
Hans-G?nter@24038 77 version : $version
Hans-G?nter@24038 78 install package: $install
Hans-G?nter@24038 79 keep tazpkg : $keep
Hans-G?nter@24038 80 build directory: $TMP_DIR
Hans-G?nter@24038 81 logging file : $LOG
Hans-G?nter@24038 82
Hans-G?nter@24038 83 EOT
Hans-G?nter@24038 84
Hans-G?nter@24038 85 separator; newline
Hans-G?nter@24038 86
Hans-G?nter@24038 87 # === Remove package, if installed ===
Hans-G?nter@24038 88 if is_installed
Hans-G?nter@24038 89 then
Hans-G?nter@24038 90 echo "$PACKAGE is already installed."
Hans-G?nter@24038 91 echo -n "Would you like to remove and reinstall this package [y/n]? "
Hans-G?nter@24038 92 read answer
Hans-G?nter@24038 93 case "$answer" in
Hans-G?nter@24038 94 y|Y)
Hans-G?nter@24038 95 action "Removing installed version..."
Hans-G?nter@24038 96 tazpkg remove $PACKAGE --root="$root/"
Hans-G?nter@24038 97 [ ! is_installed ] &&
Hans-G?nter@24038 98 die "Can't remove installed version. Exiting."
Hans-G?nter@24038 99 ;;
Hans-G?nter@24038 100 *)
Hans-G?nter@24038 101 echo "Leaving $PACKAGE untouched."
Hans-G?nter@24038 102 exit 0
Hans-G?nter@24038 103 ;;
Hans-G?nter@24038 104 esac
al@18545 105 fi
al@18545 106
Hans-G?nter@24038 107 # === Fetch rpm package, if not existing ===
Hans-G?nter@24038 108 if [ "$version" == "latest" ]
Hans-G?nter@24038 109 then
Hans-G?nter@24038 110 dl_page='https://vivaldi.com/download'
Hans-G?nter@24038 111 dl_type='i386.rpm'
Hans-G?nter@24038 112 WGET_URL=$(busybox wget -O - "$dl_page" | sed "/$dl_type/!d;s|.*href=\"\\([^\"]*\\)\.i386\.rpm.*|\\1|")
Hans-G?nter@24038 113 VERSION=${WGET_URL#*vivaldi-stable-*}
Hans-G?nter@24038 114 WGET_URL=$WGET_URL.$dl_type
Hans-G?nter@24038 115 FILE=$(basename $WGET_URL)
Hans-G?nter@24038 116 else
Hans-G?nter@24038 117 VERSION=$version
Hans-G?nter@24038 118 FILE="${PACKAGE}-stable-${VERSION}.i386.rpm"
Hans-G?nter@24038 119 WGET_URL="https://downloads.vivaldi.com/stable/$FILE"
al@18545 120 fi
al@18545 121
Hans-G?nter@24038 122 CUR_DIR=$(pwd)
Hans-G?nter@24038 123 mkdir -p $TMP_DIR
Hans-G?nter@24038 124 cd $TMP_DIR
Hans-G?nter@24038 125 if [ -f $FILE ]
Hans-G?nter@24038 126 then
Hans-G?nter@24038 127 echo "Using existing archive file $FILE"
Hans-G?nter@24038 128 else
Hans-G?nter@24038 129 action "Fetching the archive"
Hans-G?nter@24038 130 newline
Hans-G?nter@24038 131 wget --no-check-certificate $WGET_URL
Hans-G?nter@24038 132 if [ ! -f $FILE ]
Hans-G?nter@24038 133 then
Hans-G?nter@24038 134 cd $CUR_DIR
Hans-G?nter@24038 135 rm -rf $TMP_DIR
Hans-G?nter@24038 136 echo "Could not transfer $FILE from $WGET_URL. Exiting."
Hans-G?nter@24038 137 exit 1
Hans-G?nter@24038 138 fi
Hans-G?nter@24038 139 fi
al@18545 140
Hans-G?nter@24038 141 action "Extracting the rpm package"
Hans-G?nter@24038 142 newline
Hans-G?nter@24038 143 rpm2cpio $FILE | cpio -dium
Hans-G?nter@24038 144 status
Hans-G?nter@24038 145
Hans-G?nter@24038 146 # Remove archive file
Hans-G?nter@24038 147 rm -f $FILE
Hans-G?nter@24038 148
Hans-G?nter@24038 149 # === Create SliTaz package ===
al@18545 150 # Remove updater cron job
al@18545 151 rm -r ./etc
al@18545 152
al@18545 153 # Add icons
Hans-G?nter@24038 154 for size in 16 22 24 32 48 64 128 256
Hans-G?nter@24038 155 do
Hans-G?nter@24038 156 mkdir -p "$TMP_DIR/usr/share/icons/hicolor/${size}x$size/apps"
Hans-G?nter@24038 157 ln -s /opt/vivaldi/product_logo_$size.png \
Hans-G?nter@24038 158 "$TMP_DIR/usr/share/icons/hicolor/${size}x$size/apps/vivaldi.png"
Hans-G?nter@24038 159 done
al@18545 160
al@18545 161 # Prepare to packaging
Hans-G?nter@24038 162 mkdir -p $TMP_DIR/$PACKAGE-$VERSION/fs
Hans-G?nter@24038 163 mv $TMP_DIR/opt $TMP_DIR/$PACKAGE-$VERSION/fs
Hans-G?nter@24038 164 mv $TMP_DIR/usr $TMP_DIR/$PACKAGE-$VERSION/fs
al@18545 165
Hans-G?nter@24038 166 cat > $TMP_DIR/$PACKAGE-$VERSION/receipt << EOT
Hans-G?nter@24038 167 PACKAGE="$PACKAGE"
al@18545 168 VERSION="$VERSION"
Hans-G?nter@24038 169 CATEGORY="$CATEGORY"
Hans-G?nter@24038 170 SHORT_DESC="$SHORT_DESC"
Hans-G?nter@24038 171 DEPENDS="$DEPENDS"
Hans-G?nter@24038 172 WEB_SITE="$WEB_SITE"
al@18545 173 EOT
al@18545 174
Hans-G?nter@24038 175 tazpkg pack $PACKAGE-$VERSION gzip
al@18545 176
Hans-G?nter@24038 177 # === Install the SliTaz package ===
Hans-G?nter@24038 178 [ "$install" == "yes" ] &&
Hans-G?nter@24038 179 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
al@18545 180
Hans-G?nter@24038 181 # === Cleanup ===
Hans-G?nter@24038 182 # Preserve package file, if requested
Hans-G?nter@24038 183 [ "$keep" == "yes" ] &&
Hans-G?nter@24038 184 ( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
Hans-G?nter@24038 185 echo "Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR" )
al@18545 186
Hans-G?nter@24038 187 # Remove temporary build directory
Hans-G?nter@24038 188 cd $CUR_DIR
Hans-G?nter@24038 189 rm -rf $TMP_DIR