wok annotate get-community-backgrounds/stuff/get-community-backgrounds @ rev 24095

Add jpegoptim
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Sep 01 14:04:21 2021 +0000 (2021-09-01)
parents d95ae0b39830
children
rev   line source
Hans-G?nter@22808 1 #!/bin/sh
Hans-G?nter@22808 2 #
Hans-G?nter@22808 3 # get-community-backgrounds - create and install SliTaz package community-backgrounds
Hans-G?nter@22808 4 #
Hans-G?nter@22808 5 # (C) 2020 SliTaz - GNU General Public License v3.
Hans-G?nter@22808 6 # Author : Leonardo Laporte
Hans-G?nter@22835 7 # modified by HGT on 2020-02-10
Hans-G?nter@22808 8 #
hackdorte@18985 9
Hans-G?nter@22808 10 # === Initialisations ===
hackdorte@18985 11
Hans-G?nter@22808 12 PKGS_DB="/var/lib/tazpkg" # packages database directory
Hans-G?nter@22808 13
Hans-G?nter@22808 14 PACKAGE="community-backgrounds"
hackdorte@18985 15 VERSION="001"
hackdorte@18985 16 CATEGORY="x-window"
Hans-G?nter@22808 17 TAGS="artwork background wallpaper"
hackdorte@18985 18 SHORT_DESC="Beautiful wallpapers created by the Slitaz Community."
hackdorte@18985 19 MAINTAINER="hackdorte@sapo.pt"
hackdorte@18985 20 LICENSE="BSD"
Hans-G?nter@22808 21 WEB_SITE="https://github.com/Slitaz-official/hackdorte-artwork"
hackdorte@18985 22
Hans-G?nter@22808 23 # Declare functions check_root, status, ...
Hans-G?nter@22808 24 . /lib/libtaz.sh
Hans-G?nter@22808 25 # and make commandline options (if any) available as variables
hackdorte@18985 26
Hans-G?nter@22808 27 [ -f '/etc/slitaz/slitaz.conf' ] && . /etc/slitaz/slitaz.conf
Hans-G?nter@22808 28
Hans-G?nter@22808 29 is_installed()
Hans-G?nter@22808 30 {
Hans-G?nter@22808 31 if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
Hans-G?nter@22808 32 then #package is deemed to be installed
Hans-G?nter@22808 33 return 0
Hans-G?nter@22808 34 else
Hans-G?nter@22808 35 return 1
Hans-G?nter@22808 36 fi
Hans-G?nter@22808 37 }
Hans-G?nter@22808 38
Hans-G?nter@22808 39 # Show commandline options, if requested by --help
Hans-G?nter@22808 40 if [ "$help" == "yes" ]
Hans-G?nter@22808 41 then
Hans-G?nter@22808 42 echo "Commandline options:
Hans-G?nter@22808 43 $0
Hans-G?nter@22808 44 --root=<path-to-root>
Hans-G?nter@22808 45 --install=yes|no
Hans-G?nter@22808 46 --keep=no|yes
Hans-G?nter@22808 47 --tmpdir=<directory-to-build-package>"
Hans-G?nter@22808 48 exit
hackdorte@18985 49 fi
hackdorte@18985 50
Hans-G?nter@22808 51 # Check for system administrator privileges
Hans-G?nter@22808 52 check_root
hackdorte@18985 53
Hans-G?nter@22808 54 title "Package $PACKAGE will be build as SliTaz package and installed"
hackdorte@18985 55
Hans-G?nter@22808 56 # Install SliTaz package, unless inhibited by option --install=no
Hans-G?nter@22808 57 [ -z "$install" ] && install="yes"
hackdorte@18985 58
Hans-G?nter@22808 59 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
Hans-G?nter@22808 60 # unless option --keep=yes is given
Hans-G?nter@22808 61 [ -z "$keep" ] && keep="no"
hackdorte@18985 62
Hans-G?nter@22808 63 # Directory for temporary files
Hans-G?nter@22835 64 TMP_DIR="$tmpdir"
Hans-G?nter@22835 65 [ -z "$tmpdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
hackdorte@18985 66
Hans-G?nter@22808 67 # Logging file (unused by now)
Hans-G?nter@22808 68 LOG=$TMP_DIR/get-$PACKAGE.log
hackdorte@18985 69
Hans-G?nter@22808 70 cat <<EOT
Hans-G?nter@22808 71 Options in use:
Hans-G?nter@22808 72 root : $root/
Hans-G?nter@22808 73 install package: $install
Hans-G?nter@22808 74 keep tazpkg : $keep
Hans-G?nter@22808 75 build directory: $TMP_DIR
hackdorte@18985 76
hackdorte@18985 77 EOT
hackdorte@18985 78
Hans-G?nter@22808 79 separator
Hans-G?nter@22808 80 newline
hackdorte@18985 81
Hans-G?nter@22808 82 # === Remove package, if installed ===
Hans-G?nter@22835 83 if is_installed
Hans-G?nter@22808 84 then
Hans-G?nter@22808 85 action "Removing installed version..."
Hans-G?nter@22808 86 newline
Hans-G?nter@22808 87 tazpkg remove $PACKAGE --root="$root/"
Hans-G?nter@22808 88 [ ! is_installed ] &&
Hans-G?nter@22808 89 die "Can't remove installed version. Exiting."
Hans-G?nter@22808 90 fi
hackdorte@18985 91
Hans-G?nter@22808 92 # === Fetch archive file, if not existing ===
Hans-G?nter@22808 93 FILE="master.zip"
Hans-G?nter@22808 94 WGET_URL="${WEB_SITE}/archive/$FILE"
Hans-G?nter@22808 95
Hans-G?nter@22808 96 CUR_DIR=$(pwd)
Hans-G?nter@22808 97 mkdir -p $TMP_DIR
Hans-G?nter@22808 98 cd $TMP_DIR
Hans-G?nter@22808 99 if [ -f $FILE ]
Hans-G?nter@22808 100 then
Hans-G?nter@22808 101 echo "Using existing archive file $FILE"
Hans-G?nter@22808 102 else
Hans-G?nter@22808 103 action "Fetching the archive"
Hans-G?nter@22808 104 newline
Hans-G?nter@22808 105 wget --no-check-certificate $WGET_URL
Hans-G?nter@22808 106 if [ ! -f $FILE ]
Hans-G?nter@22808 107 then
Hans-G?nter@22808 108 cd $CUR_DIR
Hans-G?nter@22808 109 rm -rf $TMP_DIR
Hans-G?nter@22808 110 echo "Could not transfer $FILE from $WGET_URL. Exiting."
Hans-G?nter@22808 111 exit 1
Hans-G?nter@22808 112 fi
Hans-G?nter@22808 113 fi
Hans-G?nter@22808 114
Hans-G?nter@22808 115 # === Extract files from archive ===
Hans-G?nter@22808 116 action "Extracting the archive"
Hans-G?nter@22808 117 newline
Hans-G?nter@22808 118 busybox unzip -o $FILE
Hans-G?nter@22808 119 status
Hans-G?nter@22808 120
Hans-G?nter@22808 121 # Remove archive file
Hans-G?nter@22808 122 rm -f $FILE
Hans-G?nter@22808 123
Hans-G?nter@22808 124 # Building Base
Hans-G?nter@22808 125 mkdir -p $PACKAGE-$VERSION/fs/usr/share/images
Hans-G?nter@22808 126 mv hackdorte-artwork-master/images/* \
Hans-G?nter@22808 127 $PACKAGE-$VERSION/fs/usr/share/images
Hans-G?nter@22808 128
Hans-G?nter@22808 129 action "Cleaning..."
Hans-G?nter@22808 130 rm -rf $PACKAGE-$VERSION/fs/usr/share/images/README.md
Hans-G?nter@22808 131 rm -rf hackdorte-artwork-master
Hans-G?nter@22808 132 status
Hans-G?nter@22808 133
Hans-G?nter@22808 134 # Create recipe for SliTaz package
Hans-G?nter@22808 135 cat > $PACKAGE-$VERSION/receipt <<EOT
Hans-G?nter@22808 136 # SliTaz package receipt.
Hans-G?nter@22808 137
Hans-G?nter@22808 138 PACKED_SIZE=""
Hans-G?nter@22808 139 UNPACKED_SIZE=""
Hans-G?nter@22808 140 PACKAGE="$PACKAGE"
Hans-G?nter@22808 141 VERSION="$VERSION"
Hans-G?nter@22808 142 CATEGORY="$CATEGORY"
Hans-G?nter@22808 143 TAGS="$TAGS"
Hans-G?nter@22808 144 SHORT_DESC="$SHORT_DESC"
Hans-G?nter@22808 145 MAINTAINER="$MAINTAINER"
Hans-G?nter@22808 146 LICENSE="$LICENSE"
Hans-G?nter@22808 147 WEB_SITE="$WEB_SITE"
Hans-G?nter@22808 148
Hans-G?nter@22808 149 EOT
Hans-G?nter@22808 150
Hans-G?nter@22808 151 action "Creating the package $PACKAGE..."
Hans-G?nter@22808 152 tazpkg pack $PACKAGE-$VERSION
Hans-G?nter@22808 153 # Remove package tree
Hans-G?nter@22808 154 rm -rf $PACKAGE-$VERSION
Hans-G?nter@22808 155
Hans-G?nter@22808 156 # === Install the SliTaz package ===
Hans-G?nter@22808 157 [ "$install" == "yes" ] &&
Hans-G?nter@22808 158 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
Hans-G?nter@22808 159
Hans-G?nter@22808 160 # === Cleanup ===
Hans-G?nter@22808 161 # Preserve package file, if requested
Hans-G?nter@22808 162 [ "$keep" == "yes" ] &&
Hans-G?nter@22808 163 ( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR;
Hans-G?nter@22808 164 echo $PACKAGE-$VERSION.tazpkg saved to $CUR_DIR )
Hans-G?nter@22808 165
Hans-G?nter@22808 166 # Remove temporary build directory
hackdorte@18985 167 cd $CUR_DIR
Hans-G?nter@22808 168 rm -rf $TMP_DIR