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