rev |
line source |
Hans-G?nter@22806
|
1 #!/bin/sh
|
Hans-G?nter@22806
|
2 #
|
Hans-G?nter@22806
|
3 # get-package - create and install SliTaz package algobox
|
Hans-G?nter@22806
|
4 #
|
Hans-G?nter@22806
|
5 # (C) 2020 SliTaz - GNU General Public License v3.
|
Hans-G?nter@22806
|
6 # Author : unknown
|
Hans-G?nter@22835
|
7 # modified by HGT on 2020-02-10
|
Hans-G?nter@22806
|
8 #
|
Hans-G?nter@22806
|
9 # === Initialisations ===
|
pascal@13707
|
10
|
Hans-G?nter@22806
|
11 PKGS_DB="/var/lib/tazpkg" # packages database directory
|
pascal@13707
|
12 PACKAGE="algobox"
|
Hans-G?nter@22806
|
13 WEB_SITE="https://www.xm1math.net/algobox/"
|
pascal@13707
|
14 CATEGORY="misc"
|
Hans-G?nter@22806
|
15 SHORT_DESC="Algorithm creation tool for education."
|
pascal@13707
|
16 DEPENDS="libQtWebkit libQtXml libQtGui libQtCore gcc-lib-base"
|
pascal@13707
|
17 URL="${WEB_SITE}download.html"
|
pascal@13707
|
18
|
Hans-G?nter@22806
|
19 # Declare functions check_root, status, ...
|
Hans-G?nter@22806
|
20 . /lib/libtaz.sh
|
Hans-G?nter@22806
|
21 # and make commandline options (if any) available as variables
|
pascal@13707
|
22
|
Hans-G?nter@22806
|
23 is_installed()
|
Hans-G?nter@22806
|
24 {
|
Hans-G?nter@22806
|
25 if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
|
Hans-G?nter@22806
|
26 then #package is deemed to be installed
|
Hans-G?nter@22806
|
27 return 0
|
Hans-G?nter@22806
|
28 else
|
Hans-G?nter@22806
|
29 return 1
|
Hans-G?nter@22806
|
30 fi
|
Hans-G?nter@22806
|
31 }
|
Hans-G?nter@22806
|
32
|
Hans-G?nter@22806
|
33 # Show commandline options, if requested by --help
|
Hans-G?nter@22806
|
34 if [ "$help" == "yes" ]
|
Hans-G?nter@22806
|
35 then
|
Hans-G?nter@22806
|
36 echo "Commandline options:
|
Hans-G?nter@22806
|
37 $0
|
Hans-G?nter@22806
|
38 --version=<version>
|
Hans-G?nter@22806
|
39 --root=<path-to-root>
|
Hans-G?nter@22806
|
40 --install=yes|no
|
Hans-G?nter@22806
|
41 --keep=no|yes
|
Hans-G?nter@22806
|
42 --tmpdir=<directory-to-build-package>"
|
Hans-G?nter@22806
|
43 exit
|
pascal@13707
|
44 fi
|
pascal@13707
|
45
|
Hans-G?nter@22806
|
46 # Check for system administrator privileges
|
Hans-G?nter@22806
|
47 check_root
|
Hans-G?nter@22806
|
48
|
Hans-G?nter@22806
|
49 title "Package $PACKAGE will be build as SliTaz package and installed"
|
Hans-G?nter@22806
|
50
|
Hans-G?nter@22806
|
51 # Fetch latest version, unless version is set by option --version
|
Hans-G?nter@22806
|
52 [ -z "$version" ] && version="latest"
|
Hans-G?nter@22806
|
53
|
Hans-G?nter@22806
|
54 # Install SliTaz package, unless inhibited by option --install=no
|
Hans-G?nter@22806
|
55 [ -z "$install" ] && install="yes"
|
Hans-G?nter@22806
|
56
|
Hans-G?nter@22806
|
57 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
|
Hans-G?nter@22806
|
58 # unless option --keep=yes is given
|
Hans-G?nter@22806
|
59 [ -z "$keep" ] && keep="no"
|
Hans-G?nter@22806
|
60
|
Hans-G?nter@22806
|
61 # Directory for temporary files
|
Hans-G?nter@22835
|
62 TMP_DIR="$tmpdir"
|
Hans-G?nter@22835
|
63 [ -z "$tmpdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
|
Hans-G?nter@22806
|
64
|
Hans-G?nter@22806
|
65 # Logging file (unused by now)
|
Hans-G?nter@22806
|
66 LOG=$TMP_DIR/get-$PACKAGE.log
|
Hans-G?nter@22806
|
67
|
Hans-G?nter@22806
|
68 cat <<EOT
|
Hans-G?nter@22806
|
69 Options in use:
|
Hans-G?nter@22806
|
70 root : $root/
|
Hans-G?nter@22806
|
71 version : $version
|
Hans-G?nter@22806
|
72 install package: $install
|
Hans-G?nter@22806
|
73 keep tazpkg : $keep
|
Hans-G?nter@22806
|
74 build directory: $TMP_DIR
|
Hans-G?nter@22806
|
75
|
Hans-G?nter@22806
|
76 EOT
|
Hans-G?nter@22806
|
77
|
Hans-G?nter@22806
|
78 separator; newline
|
Hans-G?nter@22806
|
79
|
Hans-G?nter@22806
|
80 # === Remove package, if installed ===
|
Hans-G?nter@22835
|
81 if is_installed
|
Hans-G?nter@22806
|
82 then
|
Hans-G?nter@22806
|
83 action "Removing installed version..."
|
Hans-G?nter@22806
|
84 tazpkg remove $PACKAGE --root="$root/"
|
Hans-G?nter@22806
|
85 [ ! is_installed ] &&
|
Hans-G?nter@22806
|
86 die "Can't remove installed version. Exiting."
|
pascal@13707
|
87 fi
|
pascal@13707
|
88
|
Hans-G?nter@22806
|
89 # === Fetch archive file, if not existing ===
|
pascal@13707
|
90
|
Hans-G?nter@22806
|
91 if [ "$version" == "latest" ]
|
Hans-G?nter@22806
|
92 then
|
Hans-G?nter@22806
|
93 FILE=$(wget -q -O - $URL | sed '/debian_10_amd64.deb/!d; s|.*href=.\([^"]*\).*|\1|')
|
Hans-G?nter@22806
|
94 WGET_URL="${WEB_SITE}$FILE"
|
Hans-G?nter@22806
|
95 FILE=$(basename $FILE)
|
Hans-G?nter@22806
|
96 else
|
Hans-G?nter@22806
|
97 die "Can fetch latest version only. Exiting."
|
pascal@13707
|
98 fi
|
pascal@13707
|
99
|
Hans-G?nter@22806
|
100 CUR_DIR=$(pwd)
|
Hans-G?nter@22806
|
101 mkdir -p $TMP_DIR
|
Hans-G?nter@22806
|
102 cd $TMP_DIR
|
Hans-G?nter@22806
|
103 if [ -f $FILE ]
|
Hans-G?nter@22806
|
104 then
|
Hans-G?nter@22806
|
105 echo "Using existing archive file $FILE"
|
Hans-G?nter@22806
|
106 else
|
Hans-G?nter@22806
|
107 action "Fetching the archive"
|
Hans-G?nter@22806
|
108 newline
|
Hans-G?nter@22806
|
109 wget --no-check-certificate $WGET_URL
|
Hans-G?nter@22806
|
110 if [ ! -f $FILE ]
|
Hans-G?nter@22806
|
111 then
|
Hans-G?nter@22806
|
112 cd $CUR_DIR
|
Hans-G?nter@22806
|
113 rm -rf $TMP_DIR
|
Hans-G?nter@22806
|
114 echo "Could not transfer $FILE from $URL. Exiting."
|
Hans-G?nter@22806
|
115 exit 1
|
Hans-G?nter@22806
|
116 fi
|
Hans-G?nter@22806
|
117 fi
|
Hans-G?nter@22806
|
118
|
Hans-G?nter@22806
|
119 # === Extract files from archive ===
|
Hans-G?nter@22806
|
120 action "Extracting the archive"
|
Hans-G?nter@22806
|
121
|
pascal@13707
|
122 mkdir $PACKAGE
|
Hans-G?nter@22806
|
123 # Extract metadata from Debian package
|
pascal@13707
|
124 dpkg-deb -e $FILE $PACKAGE/meta
|
Hans-G?nter@22806
|
125 # Extract files from Debian package
|
pascal@13707
|
126 dpkg-deb -x $FILE $PACKAGE/fs
|
Hans-G?nter@22806
|
127 status
|
Hans-G?nter@22806
|
128
|
Hans-G?nter@22806
|
129 # Remove archive file
|
pascal@13707
|
130 rm -f $FILE
|
Hans-G?nter@22806
|
131
|
Hans-G?nter@22806
|
132 # === Create SliTaz package ===
|
Hans-G?nter@22806
|
133
|
Hans-G?nter@22806
|
134 # Prepare metadata for SliTaz package
|
Hans-G?nter@22806
|
135
|
Hans-G?nter@22806
|
136 if ! grep -q "insert long description" $PACKAGE/meta/control
|
Hans-G?nter@22806
|
137 then
|
pascal@13707
|
138 sed '/^Description:/,$!d;s/^Description://' \
|
pascal@13707
|
139 < $PACKAGE/meta/control > $PACKAGE/description.txt
|
Hans-G?nter@22806
|
140 fi
|
Hans-G?nter@22806
|
141 SHORT_DESC="$(sed '/^Description:/!d; s/.*: //' $PACKAGE/meta/control)"
|
Hans-G?nter@22806
|
142 MAINTAINER="$(sed '/^Maintainer:/!d; s/.*: //' $PACKAGE/meta/control)"
|
Hans-G?nter@22806
|
143 VERSION="$( sed '/^Version:/!d; s/.*: //' $PACKAGE/meta/control)"
|
pascal@13707
|
144
|
Hans-G?nter@22806
|
145 # rename build directory
|
pascal@13707
|
146 mv $PACKAGE $PACKAGE-$VERSION
|
pascal@13707
|
147
|
Hans-G?nter@22806
|
148 cd $PACKAGE-$VERSION
|
Hans-G?nter@22806
|
149
|
Hans-G?nter@22806
|
150 # Create recipe for SliTaz package
|
Hans-G?nter@22806
|
151 cat > receipt <<EOT
|
Hans-G?nter@22806
|
152 # SliTaz package receipt.
|
Hans-G?nter@22806
|
153
|
Hans-G?nter@22806
|
154 PACKED_SIZE=""
|
Hans-G?nter@22806
|
155 UNPACKED_SIZE=""
|
pascal@13707
|
156 PACKAGE="$PACKAGE"
|
pascal@13707
|
157 VERSION="$VERSION"
|
pascal@13707
|
158 CATEGORY="$CATEGORY"
|
Hans-G?nter@22806
|
159 TAGS="$TAGS"
|
pascal@13707
|
160 SHORT_DESC="$SHORT_DESC"
|
pascal@13707
|
161 MAINTAINER="$MAINTAINER"
|
Hans-G?nter@22806
|
162 LICENSE="non-free"
|
Hans-G?nter@22806
|
163 WEB_SITE="$WEB_SITE"
|
Hans-G?nter@22806
|
164
|
pascal@13707
|
165 DEPENDS="$DEPENDS"
|
Hans-G?nter@22806
|
166
|
pascal@13707
|
167 EOT
|
pascal@13707
|
168
|
Hans-G?nter@22806
|
169 action "Creating the package $PACKAGE..."
|
pascal@13707
|
170 # Pack
|
Hans-G?nter@22806
|
171 cd ..
|
pascal@13707
|
172 tazpkg pack $PACKAGE-$VERSION
|
Hans-G?nter@22806
|
173 # Remove package tree
|
pascal@13707
|
174 rm -rf $PACKAGE-$VERSION
|
pascal@13707
|
175
|
Hans-G?nter@22806
|
176 # === Install the SliTaz package ===
|
Hans-G?nter@22806
|
177 [ "$install" == "yes" ] &&
|
Hans-G?nter@22806
|
178 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
|
pascal@13707
|
179
|
Hans-G?nter@22806
|
180 # === Cleanup ===
|
Hans-G?nter@22806
|
181 # Preserve package file, if requested
|
Hans-G?nter@22806
|
182 [ "$keep" == "yes" ] && mv $PACKAGE-$VERSION.tazpkg $CUR_DIR
|
Hans-G?nter@22806
|
183
|
Hans-G?nter@22806
|
184 # Remove temporary build directory
|
pascal@13707
|
185 cd $CUR_DIR
|
pascal@13707
|
186 rm -rf $TMP_DIR
|