wok-current view get-algobox/stuff/get-algobox @ rev 25698

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