wok rev 22808
updated get-community-backgrounds (002 -> 1.00)
author | Hans-G?nter Theisgen |
---|---|
date | Wed Jan 29 09:15:22 2020 +0100 (2020-01-29) |
parents | 0467021a4935 |
children | e2f8a574b574 |
files | get-community-backgrounds/receipt get-community-backgrounds/stuff/get-community-backgrounds |
line diff
1.1 --- a/get-community-backgrounds/receipt Wed Jan 29 07:32:34 2020 +0100 1.2 +++ b/get-community-backgrounds/receipt Wed Jan 29 09:15:22 2020 +0100 1.3 @@ -1,21 +1,22 @@ 1.4 # SliTaz package receipt. 1.5 1.6 PACKAGE="get-community-backgrounds" 1.7 -VERSION="002" 1.8 +VERSION="1.00" 1.9 CATEGORY="x-window" 1.10 +TAGS="artwork background wallpaper" 1.11 SHORT_DESC="Beautiful wallpapers created by the Slitaz Community." 1.12 MAINTAINER="hackdorte@sapo.pt" 1.13 -LICENSE="BSD" 1.14 -WEB_SITE="https://github.com/hackdorte/slitaz-community-backgrounds" 1.15 -TAGS="artwork background wallpaper" 1.16 +LICENSE="GPLv3" 1.17 +WEB_SITE="https://github.com/Slitaz-official/hackdorte-artwork" 1.18 1.19 # Rules to gen a SliTaz package suitable for Tazpkg. 1.20 genpkg_rules() 1.21 { 1.22 - mkdir -p $fs/usr/bin 1.23 - cp stuff/* $fs/usr/bin 1.24 + mkdir -p $fs/usr/bin 1.25 + cp stuff/* $fs/usr/bin 1.26 } 1.27 + 1.28 post_install() 1.29 { 1.30 [ "$1" ] || get-community-backgrounds 1.31 -} 1.32 \ No newline at end of file 1.33 +}
2.1 --- a/get-community-backgrounds/stuff/get-community-backgrounds Wed Jan 29 07:32:34 2020 +0100 2.2 +++ b/get-community-backgrounds/stuff/get-community-backgrounds Wed Jan 29 09:15:22 2020 +0100 2.3 @@ -1,78 +1,167 @@ 2.4 -#!/bin/sh -e 2.5 +#!/bin/sh 2.6 +# 2.7 +# get-community-backgrounds - create and install SliTaz package community-backgrounds 2.8 +# 2.9 +# (C) 2020 SliTaz - GNU General Public License v3. 2.10 +# Author : Leonardo Laporte 2.11 +# modified by HGT on 2020-01-29 2.12 +# 2.13 2.14 -[ -f '/etc/slitaz/slitaz.conf' ] && . /etc/slitaz/slitaz.conf 2.15 -[ -z "$INSTALLED" ] && INSTALLED='/var/lib/tazpkg/installed' 2.16 +# === Initialisations === 2.17 2.18 -PACKAGE="get-community-backgrounds" 2.19 -PKGNAME="slitaz-community-backgrounds" 2.20 +PKGS_DB="/var/lib/tazpkg" # packages database directory 2.21 + 2.22 +PACKAGE="community-backgrounds" 2.23 VERSION="001" 2.24 CATEGORY="x-window" 2.25 +TAGS="artwork background wallpaper" 2.26 SHORT_DESC="Beautiful wallpapers created by the Slitaz Community." 2.27 MAINTAINER="hackdorte@sapo.pt" 2.28 LICENSE="BSD" 2.29 -WEB_SITE="https://github.com/hackdorte/slitaz-community-backgrounds" 2.30 -TAGS="artwork background wallpaper" 2.31 +WEB_SITE="https://github.com/Slitaz-official/hackdorte-artwork" 2.32 2.33 -ROOT="$1" 2.34 -[ -d "$ROOT" ] || ROOT="" 2.35 +# Declare functions check_root, status, ... 2.36 +. /lib/libtaz.sh 2.37 +# and make commandline options (if any) available as variables 2.38 2.39 -if [ $(id -u) -ne 0 ]; then 2.40 - echo -e "\nYou must be root to run `basename $0`." 2.41 - echo -e "Please type 'su' and root password to become super-user.\n" 2.42 - exit 0 2.43 +[ -f '/etc/slitaz/slitaz.conf' ] && . /etc/slitaz/slitaz.conf 2.44 + 2.45 +is_installed() 2.46 +{ 2.47 + if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ] 2.48 + then #package is deemed to be installed 2.49 + return 0 2.50 + else 2.51 + return 1 2.52 + fi 2.53 +} 2.54 + 2.55 +# Show commandline options, if requested by --help 2.56 +if [ "$help" == "yes" ] 2.57 + then 2.58 + echo "Commandline options: 2.59 + $0 2.60 + --root=<path-to-root> 2.61 + --install=yes|no 2.62 + --keep=no|yes 2.63 + --tmpdir=<directory-to-build-package>" 2.64 + exit 2.65 fi 2.66 2.67 -if [ -d $ROOT$INSTALLED/$PKGNAME ]; then 2.68 - [ -n "$ROOT" ] && exit 1 2.69 - tazpkg remove $PKGNAME 2.70 - [ -d $INSTALLED/$PKGNAME ] && exit 1 2.71 -fi 2.72 +# Check for system administrator privileges 2.73 +check_root 2.74 2.75 -# Source Download 2.76 -TARBALL="master.zip" 2.77 -URL="${WEB_SITE}/archive/$TARBALL" 2.78 -TMP_DIR="$(mktemp -d)" 2.79 -CUR_DIR=$(pwd) 2.80 -cd $TMP_DIR 2.81 -busybox wget -O $TARBALL $URL 2.82 +title "Package $PACKAGE will be build as SliTaz package and installed" 2.83 2.84 -if [ ! -f $TARBALL ]; then 2.85 - echo "Could not download $TARBALL. Exiting." 2.86 - exit 1 2.87 -fi 2.88 +# Install SliTaz package, unless inhibited by option --install=no 2.89 +[ -z "$install" ] && install="yes" 2.90 2.91 -# Unzip Package 2.92 -busybox unzip $TARBALL 2.93 +# Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation, 2.94 +# unless option --keep=yes is given 2.95 +[ -z "$keep" ] && keep="no" 2.96 2.97 -# Building Base 2.98 -mkdir -p $PKGNAME-$VERSION/fs/usr/share/images 2.99 -mv $PKGNAME-master/* $PKGNAME-$VERSION/fs/usr/share/images 2.100 -rm -irf $PKGNAME-$VERSION/fs/usr/share/images/README.md 2.101 -rm -irf $PKGNAME-master 2.102 -rm -irf $TARBALL 2.103 +# Directory for temporary files 2.104 +[ -z "$tempdir" ] && TMP_DIR="/tmp/get-$PACKAGE" 2.105 2.106 +# Logging file (unused by now) 2.107 +LOG=$TMP_DIR/get-$PACKAGE.log 2.108 2.109 -# Writing The Receipt 2.110 -cat > $PKGNAME-$VERSION/receipt <<EOT 2.111 -PACKAGE="$PKGNAME" 2.112 -VERSION="$VERSION" 2.113 -CATEGORY="x-window" 2.114 -SHORT_DESC="$SHORT_DESC" 2.115 -WEB_SITE="$WEB_SITE" 2.116 -MAINTAINER="$MAINTAINER" 2.117 -TAGS="$TAGS" 2.118 +cat <<EOT 2.119 +Options in use: 2.120 + root : $root/ 2.121 + install package: $install 2.122 + keep tazpkg : $keep 2.123 + build directory: $TMP_DIR 2.124 2.125 EOT 2.126 2.127 -# Creating The Tazpkg Package 2.128 -tazpkg pack $PKGNAME-$VERSION 2.129 +separator 2.130 +newline 2.131 2.132 -# Install Package 2.133 -tazpkg -i $PKGNAME-$VERSION.tazpkg --root=$ROOT 2.134 -case " $@ " in 2.135 -*\ --k*) mv $PKGNAME-$VERSION.tazpkg $CUR_DIR ;; 2.136 -esac 2.137 +# === Remove package, if installed === 2.138 +if [ is_installed ] 2.139 + then 2.140 + action "Removing installed version..." 2.141 + newline 2.142 + tazpkg remove $PACKAGE --root="$root/" 2.143 + [ ! is_installed ] && 2.144 + die "Can't remove installed version. Exiting." 2.145 +fi 2.146 2.147 -# Clean 2.148 +# === Fetch archive file, if not existing === 2.149 +FILE="master.zip" 2.150 +WGET_URL="${WEB_SITE}/archive/$FILE" 2.151 + 2.152 +CUR_DIR=$(pwd) 2.153 +mkdir -p $TMP_DIR 2.154 +cd $TMP_DIR 2.155 +if [ -f $FILE ] 2.156 + then 2.157 + echo "Using existing archive file $FILE" 2.158 + else 2.159 + action "Fetching the archive" 2.160 + newline 2.161 + wget --no-check-certificate $WGET_URL 2.162 + if [ ! -f $FILE ] 2.163 + then 2.164 + cd $CUR_DIR 2.165 + rm -rf $TMP_DIR 2.166 + echo "Could not transfer $FILE from $WGET_URL. Exiting." 2.167 + exit 1 2.168 + fi 2.169 +fi 2.170 + 2.171 +# === Extract files from archive === 2.172 +action "Extracting the archive" 2.173 +newline 2.174 +busybox unzip -o $FILE 2.175 +status 2.176 + 2.177 +# Remove archive file 2.178 +rm -f $FILE 2.179 + 2.180 +# Building Base 2.181 +mkdir -p $PACKAGE-$VERSION/fs/usr/share/images 2.182 +mv hackdorte-artwork-master/images/* \ 2.183 + $PACKAGE-$VERSION/fs/usr/share/images 2.184 + 2.185 +action "Cleaning..." 2.186 +rm -rf $PACKAGE-$VERSION/fs/usr/share/images/README.md 2.187 +rm -rf hackdorte-artwork-master 2.188 +status 2.189 + 2.190 +# Create recipe for SliTaz package 2.191 +cat > $PACKAGE-$VERSION/receipt <<EOT 2.192 +# SliTaz package receipt. 2.193 + 2.194 +PACKED_SIZE="" 2.195 +UNPACKED_SIZE="" 2.196 +PACKAGE="$PACKAGE" 2.197 +VERSION="$VERSION" 2.198 +CATEGORY="$CATEGORY" 2.199 +TAGS="$TAGS" 2.200 +SHORT_DESC="$SHORT_DESC" 2.201 +MAINTAINER="$MAINTAINER" 2.202 +LICENSE="$LICENSE" 2.203 +WEB_SITE="$WEB_SITE" 2.204 + 2.205 +EOT 2.206 + 2.207 +action "Creating the package $PACKAGE..." 2.208 +tazpkg pack $PACKAGE-$VERSION 2.209 +# Remove package tree 2.210 +rm -rf $PACKAGE-$VERSION 2.211 + 2.212 +# === Install the SliTaz package === 2.213 +[ "$install" == "yes" ] && 2.214 +tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root" 2.215 + 2.216 +# === Cleanup === 2.217 +# Preserve package file, if requested 2.218 +[ "$keep" == "yes" ] && 2.219 +( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR; 2.220 + echo $PACKAGE-$VERSION.tazpkg saved to $CUR_DIR ) 2.221 + 2.222 +# Remove temporary build directory 2.223 cd $CUR_DIR 2.224 -rm -rf "$TMP_DIR" 2.225 +rm -rf $TMP_DIR