rev |
line source |
pankso@7
|
1 #!/bin/sh
|
pankso@7
|
2 # Tazwok - SliTaz source compiler and binary packages generator/cooker.
|
pankso@7
|
3 #
|
MikeDSmith25@82
|
4 # Tazwok can compile source packages and create binary packages suitable for
|
MikeDSmith25@82
|
5 # Tazpkg (Tiny Autonomous zone package manager). You can build individual
|
MikeDSmith25@82
|
6 # packages or a list of packages with one command, rebuild the full distro,
|
pankso@7
|
7 # generate a packages repository and also list and get info about packages.
|
pankso@7
|
8 #
|
pankso@19
|
9 # (C) 2007-2008 SliTaz - GNU General Public License.
|
pankso@7
|
10 #
|
pankso@80
|
11 VERSION=2.0
|
pankso@7
|
12
|
pankso@7
|
13 ####################
|
pankso@7
|
14 # Tazwok variables #
|
pankso@7
|
15 ####################
|
pankso@7
|
16
|
pankso@7
|
17 # Packages categories.
|
pankso@25
|
18 CATEGORIES="
|
pankso@25
|
19 base-system
|
pankso@25
|
20 utilities
|
pankso@25
|
21 network
|
pankso@25
|
22 graphics
|
pankso@25
|
23 multimedia
|
pankso@25
|
24 office
|
pankso@25
|
25 development
|
pankso@25
|
26 system-tools
|
pankso@25
|
27 security
|
pankso@26
|
28 games
|
pankso@26
|
29 misc
|
pankso@43
|
30 meta
|
pankso@43
|
31 non-free"
|
pankso@7
|
32
|
MikeDSmith25@82
|
33 # Use words rather than numbers in the code.
|
pankso@7
|
34 COMMAND=$1
|
pankso@7
|
35 PACKAGE=$2
|
pankso@7
|
36 LIST=$2
|
pankso@7
|
37
|
MikeDSmith25@82
|
38 # Include config file or exit if no file found.
|
erjo@38
|
39 if [ -f "./tazwok.conf" ]; then
|
erjo@38
|
40 . ./tazwok.conf
|
erjo@38
|
41 elif [ -f "/etc/tazwok.conf" ]; then
|
pankso@7
|
42 . /etc/tazwok.conf
|
pankso@7
|
43 else
|
pankso@7
|
44 echo -e "\nUnable to find the configuration file : /etc/tazwok.conf"
|
pankso@7
|
45 echo -e "Please read the Tazwok documentation.\n"
|
pankso@7
|
46 exit 0
|
pankso@7
|
47 fi
|
pankso@7
|
48
|
MikeDSmith25@82
|
49 # Create Taz wok needed directories if user is root.
|
pankso@7
|
50 if test $(id -u) = 0 ; then
|
pankso@7
|
51 # Check for the wok directory.
|
pankso@7
|
52 if [ ! -d "$WOK" ]; then
|
pankso@7
|
53 echo "Creating the wok directory..."
|
pankso@7
|
54 mkdir -p $WOK
|
pankso@7
|
55 chmod 777 $WOK
|
pankso@7
|
56 fi
|
pankso@7
|
57 # Check for the packages repository.
|
pankso@7
|
58 if [ ! -d "$PACKAGES_REPOSITORY" ]; then
|
pankso@7
|
59 echo "Creating the packages repository..."
|
pankso@7
|
60 mkdir -p $PACKAGES_REPOSITORY
|
pankso@7
|
61 fi
|
pankso@7
|
62 # Check for the sources repository.
|
pankso@7
|
63 if [ ! -d "$SOURCES_REPOSITORY" ]; then
|
pankso@7
|
64 echo "Creating the sources repository..."
|
pankso@17
|
65 mkdir -p $SOURCES_REPOSITORY
|
pankso@7
|
66 fi
|
pankso@7
|
67 fi
|
pankso@7
|
68
|
pankso@7
|
69 # The path to the most important file used by Tazwok.
|
pankso@7
|
70 # The receipt is used to compile the source code and
|
MikeDSmith25@82
|
71 # generate suitable packages for Tazpkg.
|
pankso@7
|
72 RECEIPT="$WOK/$PACKAGE/receipt"
|
pankso@7
|
73
|
pankso@7
|
74 # The path to the process log file.
|
pankso@7
|
75 LOG="$WOK/$PACKAGE/process.log"
|
pankso@7
|
76
|
pankso@7
|
77 ####################
|
pankso@7
|
78 # Tazwok functions #
|
pankso@7
|
79 ####################
|
pankso@7
|
80
|
pankso@7
|
81 # Print the usage (English).
|
pankso@7
|
82 usage ()
|
pankso@7
|
83 {
|
pankso@7
|
84 echo -e "\nSliTaz sources compiler and packages generator - Version: $VERSION\n
|
pankso@7
|
85 \033[1mUsage: \033[0m `basename $0` [command] [package|list|category|dir] [--option]
|
pankso@7
|
86 \033[1mCommands: \033[0m\n
|
pankso@7
|
87 usage Print this short usage.
|
pankso@7
|
88 stats Print Tazwok statistics from the config file and the wok.
|
pankso@66
|
89 cmp|compare Compare the wok and the cooked pkgs (--remove old pkgs).
|
pankso@7
|
90 list List all packages in the wok tree or by category.
|
MikeDSmith25@82
|
91 info Get information about a package in the wok.
|
pascal@92
|
92 check Check every receipt for common errors.
|
pankso@7
|
93 check-log Check the process log file of a package.
|
pankso@7
|
94 search Search for a package in the wok by pattern or name.
|
MikeDSmith25@82
|
95 compile Configure and build a package using the receipt rules.
|
pankso@7
|
96 genpkg Generate a suitable package for Tazpkg with the rules.
|
pankso@7
|
97 cook Compile and generate a package directly.
|
pankso@7
|
98 cook-list Cook all packages specified in the list by order.
|
pankso@7
|
99 clean Clean all generated files in the package tree.
|
pankso@7
|
100 new-tree Prepare a new package tree and receipt (--interactive).
|
MikeDSmith25@82
|
101 gen-list Generate a packages list for a repository (--text).
|
pankso@7
|
102 gen-clean-wok Gen a clean wok in a dir ('clean-wok' cleans current wok).
|
pankso@7
|
103 remove Remove a package from the wok.\n"
|
pankso@7
|
104 }
|
pankso@7
|
105
|
pankso@7
|
106 # Status function.
|
pankso@7
|
107 status()
|
pankso@7
|
108 {
|
pankso@7
|
109 local CHECK=$?
|
pankso@7
|
110 echo -en "\\033[70G[ "
|
pankso@7
|
111 if [ $CHECK = 0 ]; then
|
pankso@7
|
112 echo -en "\\033[1;33mOK"
|
pankso@7
|
113 else
|
pankso@7
|
114 echo -en "\\033[1;31mFailed"
|
pankso@7
|
115 fi
|
pankso@7
|
116 echo -e "\\033[0;39m ]"
|
pankso@7
|
117 }
|
pankso@7
|
118
|
pankso@7
|
119 # Check if user is root.
|
pankso@7
|
120 check_root()
|
pankso@7
|
121 {
|
pankso@7
|
122 if test $(id -u) != 0 ; then
|
pankso@7
|
123 echo -e "\nYou must be root to run `basename $0` with this option."
|
pankso@7
|
124 echo -e "Please type 'su' and root password to become super-user.\n"
|
pankso@7
|
125 exit 0
|
pankso@7
|
126 fi
|
pankso@7
|
127 }
|
pankso@7
|
128
|
pankso@7
|
129 # Check for a package name on cmdline.
|
pankso@7
|
130 check_for_package_on_cmdline()
|
pankso@7
|
131 {
|
pankso@7
|
132 if [ -z "$PACKAGE" ]; then
|
pankso@7
|
133 echo -e "\nYou must specify a package name on the command line."
|
pankso@7
|
134 echo -e "Example : tazwok $COMMAND package\n"
|
pankso@7
|
135 exit 0
|
pankso@7
|
136 fi
|
pankso@7
|
137 }
|
pankso@7
|
138
|
pankso@7
|
139 # Check for the receipt of a package used to cook.
|
pankso@7
|
140 check_for_receipt()
|
pankso@7
|
141 {
|
pankso@7
|
142 if [ ! -f "$RECEIPT" ]; then
|
pankso@7
|
143 echo -e "\nUnable to find the receipt : $RECEIPT\n"
|
pankso@7
|
144 exit 0
|
pankso@7
|
145 fi
|
pankso@7
|
146 }
|
pankso@7
|
147
|
pankso@7
|
148 # Check for a specified file list on cmdline.
|
pankso@7
|
149 check_for_list()
|
pankso@7
|
150 {
|
pankso@7
|
151 if [ -z "$LIST" ]; then
|
pankso@7
|
152 echo -e "\nPlease specify the path to the list of packages to cook.\n"
|
pankso@7
|
153 exit 0
|
pankso@7
|
154 fi
|
MikeDSmith25@82
|
155 # Check if the list of packages exists.
|
pankso@7
|
156 if [ -f "$LIST" ]; then
|
pankso@7
|
157 LIST=`cat $LIST`
|
pankso@7
|
158 else
|
pankso@7
|
159 echo -e "\nUnable to find $LIST packages list.\n"
|
pankso@7
|
160 exit 0
|
pankso@7
|
161 fi
|
pankso@7
|
162 }
|
pankso@7
|
163
|
pankso@7
|
164 # Check for the wanted package if specified in WANTED
|
pankso@7
|
165 # receipt variable. Set the $src/$_pkg variable to help compiling
|
pankso@7
|
166 # and generating packages.
|
pankso@7
|
167 check_for_wanted()
|
pankso@7
|
168 {
|
pankso@7
|
169 if [ ! "$WANTED" = "" ]; then
|
pankso@7
|
170 echo -n "Checking for the wanted package..."
|
pankso@7
|
171 if [ ! -d "$WOK/$WANTED" ]; then
|
pankso@7
|
172 echo -e "\nWanted package is missing in the work directory.\n"
|
pankso@7
|
173 exit 0
|
pankso@7
|
174 fi
|
erjo@38
|
175 # Checking for buildtree of Wanted package
|
pankso@39
|
176 if [ ! -d "$WOK/$WANTED/taz" ]; then
|
erjo@38
|
177 echo -e "\n\nSource files of wanted package is missing in the work directory."
|
erjo@38
|
178 echo -n "Would you like to build the missing package (y/N) ? " ; read anser
|
erjo@38
|
179 if [ "$anser" == "y" ]; then
|
erjo@38
|
180 tazwok cook $WANTED
|
erjo@38
|
181 else
|
erjo@38
|
182 echo -e "\nWanted package source tree is missing in the work directory.\n"
|
erjo@38
|
183 exit 0
|
erjo@38
|
184 fi
|
erjo@38
|
185 fi
|
pankso@7
|
186 status
|
pankso@7
|
187 # Set wanted src path.
|
pankso@7
|
188 src=$WOK/$WANTED/$WANTED-$VERSION
|
pankso@7
|
189 _pkg=$src/_pkg
|
pankso@7
|
190 fi
|
pankso@7
|
191 }
|
pankso@7
|
192
|
erjo@38
|
193
|
pankso@40
|
194 # Check for build dependencies, notify user and install if specified.
|
pankso@18
|
195 check_for_build_depends()
|
pankso@18
|
196 {
|
pankso@18
|
197 echo "Checking for build dependencies..."
|
pankso@18
|
198 for pkg in $BUILD_DEPENDS
|
pankso@18
|
199 do
|
pankso@18
|
200 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
|
pankso@18
|
201 MISSING_PACKAGE=$pkg
|
pankso@18
|
202 fi
|
pankso@18
|
203 done
|
pankso@18
|
204 if [ ! "$MISSING_PACKAGE" = "" ]; then
|
pankso@18
|
205 echo "================================================================================"
|
pankso@18
|
206 for pkg in $BUILD_DEPENDS
|
pankso@18
|
207 do
|
pankso@18
|
208 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
|
pankso@18
|
209 MISSING_PACKAGE=$pkg
|
pankso@18
|
210 echo "Missing : $pkg"
|
pankso@18
|
211 fi
|
pankso@18
|
212 done
|
pankso@18
|
213 echo "================================================================================"
|
pankso@40
|
214 echo "You can continue, exit or install missing dependencies."
|
pankso@40
|
215 echo -n "Install, continue or exit (install/y/N) ? "; read anser
|
pankso@40
|
216 case $anser in
|
pankso@40
|
217 install)
|
pankso@40
|
218 for pkg in $BUILD_DEPENDS
|
pankso@40
|
219 do
|
pankso@40
|
220 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
|
pankso@40
|
221 tazpkg get-install $pkg
|
pankso@40
|
222 fi
|
pankso@40
|
223 done ;;
|
pankso@40
|
224 y|yes)
|
pankso@40
|
225 continue ;;
|
pankso@40
|
226 *)
|
pankso@40
|
227 exit 0 ;;
|
pankso@40
|
228 esac
|
pankso@18
|
229 fi
|
pankso@18
|
230 }
|
pascal@76
|
231
|
pascal@76
|
232 # Check for loop in deps tree.
|
pascal@76
|
233 check_for_deps_loop()
|
pascal@76
|
234 {
|
pascal@76
|
235 local list
|
pascal@76
|
236 local pkg
|
pascal@76
|
237 local deps
|
pascal@76
|
238 pkg=$1
|
pascal@76
|
239 shift
|
pascal@76
|
240 [ -n "$1" ] || return
|
pascal@76
|
241 list=""
|
pascal@76
|
242 # Filter out already processed deps
|
pascal@76
|
243 for i in $@; do
|
pascal@76
|
244 case " $ALL_DEPS" in
|
pascal@76
|
245 *\ $i\ *);;
|
pascal@76
|
246 *) list="$list $i";;
|
pascal@76
|
247 esac
|
pascal@76
|
248 done
|
pascal@76
|
249 ALL_DEPS="$ALL_DEPS$list "
|
pascal@76
|
250 for i in $list; do
|
pascal@76
|
251 [ -f $i/receipt ] || continue
|
pascal@76
|
252 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
|
pascal@76
|
253 case " $deps " in
|
pascal@76
|
254 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
|
pascal@76
|
255 *) check_for_deps_loop $pkg $deps;;
|
pascal@76
|
256 esac
|
pascal@76
|
257 done
|
pascal@76
|
258 }
|
pascal@76
|
259
|
erjo@53
|
260 download()
|
erjo@53
|
261 {
|
erjo@53
|
262 for file in $@; do
|
erjo@53
|
263 wget $file && break
|
erjo@53
|
264 done
|
erjo@53
|
265 }
|
pankso@18
|
266
|
pankso@7
|
267 # Configure and make a package with the receipt.
|
pankso@7
|
268 compile_package()
|
pankso@7
|
269 {
|
pankso@7
|
270 check_for_package_on_cmdline
|
pankso@7
|
271 # Include the receipt to get all needed variables and functions
|
pankso@7
|
272 # and cd into the work directory to start the work.
|
pankso@7
|
273 check_for_receipt
|
pankso@7
|
274 . $RECEIPT
|
pankso@7
|
275 # Log the package name and date.
|
pankso@7
|
276 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
|
pankso@7
|
277 echo "package $PACKAGE (compile)" >> $LOG
|
pankso@7
|
278 # Set wanted $src variable to help compiling.
|
pankso@7
|
279 if [ ! "$SOURCE" = "" ]; then
|
pankso@7
|
280 src=$WOK/$PACKAGE/$SOURCE-$VERSION
|
pankso@7
|
281 else
|
pankso@7
|
282 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
|
pankso@7
|
283 fi
|
pankso@18
|
284 check_for_build_depends
|
pankso@7
|
285 check_for_wanted
|
pankso@7
|
286 echo ""
|
pankso@7
|
287 echo "Starting to cook $PACKAGE..."
|
pankso@7
|
288 echo "================================================================================"
|
pankso@7
|
289 # Check for src tarball and wget if needed.
|
pankso@28
|
290 if [ ! "$WGET_URL" = "" ]; then
|
pankso@7
|
291 echo "Checking for source tarball... "
|
pankso@7
|
292 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
|
pankso@7
|
293 cd $SOURCES_REPOSITORY
|
erjo@53
|
294 download $WGET_URL
|
erjo@53
|
295 #wget $WGET_URL
|
pankso@7
|
296 # Exit if download failed to avoid errors.
|
pankso@7
|
297 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
|
pankso@7
|
298 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n"
|
pankso@7
|
299 exit 1
|
pankso@7
|
300 fi
|
pankso@7
|
301 else
|
pankso@7
|
302 echo -n "Source tarball exit... "
|
pankso@7
|
303 status
|
pankso@7
|
304 fi
|
MikeDSmith25@82
|
305 # Untaring source if necessary. We don't need to extract source if
|
MikeDSmith25@82
|
306 # the package is built with a wanted source package.
|
pankso@7
|
307 if [ "$WANTED" = "" ]; then
|
pankso@7
|
308 if [ ! -d $src ]; then
|
pankso@7
|
309 # Log process.
|
pankso@7
|
310 echo "untaring $TARBALL" >> $LOG
|
pankso@7
|
311 echo -n "Untaring $TARBALL... "
|
pascal@48
|
312 case "$TARBALL" in
|
pascal@48
|
313 *zip) ( cd $WOK/$PACKAGE; unzip $SOURCES_REPOSITORY/$TARBALL );;
|
pascal@48
|
314 *bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
|
pascal@48
|
315 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
|
pascal@88
|
316 *Z) tar xZf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
|
pascal@48
|
317 *) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
|
pascal@48
|
318 esac
|
pankso@7
|
319 status
|
pankso@52
|
320 # Permissions settings
|
pankso@52
|
321 chown -R root.root $WOK/$PACKAGE/$PACKAGE-* 2>/dev/null
|
pankso@52
|
322 chown -R root.root $WOK/$PACKAGE/$SOURCE-* 2>/dev/null
|
pankso@7
|
323 else
|
pankso@7
|
324 echo -n "Source direcory exit... " && status
|
pankso@7
|
325 fi
|
pankso@7
|
326 fi
|
pankso@7
|
327 fi
|
pankso@7
|
328 cd $WOK/$PACKAGE
|
MikeDSmith25@82
|
329 # Log and execute compile_rules function if it exists, to configure and
|
MikeDSmith25@82
|
330 # make the package if it exists.
|
pankso@28
|
331 if grep -q ^compile_rules $RECEIPT; then
|
pankso@7
|
332 echo "executing compile_rules" >> $LOG
|
pankso@7
|
333 compile_rules
|
pankso@7
|
334 # Exit if compilation failed so the binary package
|
pankso@7
|
335 # is not generated when using the cook comand.
|
pankso@7
|
336 local CHECK=$?
|
pankso@7
|
337 if [ $CHECK = 0 ]; then
|
pankso@7
|
338 echo "================================================================================"
|
pankso@7
|
339 echo "$PACKAGE compiled on : `date +%Y%m%d\ \%H:%M:%S`"
|
pankso@7
|
340 echo ""
|
pankso@7
|
341 echo "compilation done : `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
|
pankso@7
|
342 else
|
pankso@7
|
343 echo "================================================================================"
|
pankso@7
|
344 echo "Compilation failed. Please read the compilator output."
|
pankso@7
|
345 echo "" && exit 1
|
pankso@7
|
346 fi
|
pankso@7
|
347 else
|
pankso@7
|
348 echo "no compile_rules" >> $LOG
|
pankso@7
|
349 echo -e "No compile rules for $PACKAGE...\n"
|
pankso@7
|
350 fi
|
pankso@7
|
351 }
|
pankso@7
|
352
|
MikeDSmith25@82
|
353 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
|
pankso@22
|
354 # so some packages need to copy these files with the receipt and genpkg_rules.
|
pankso@22
|
355 # This function is executed by gen_package when 'tazwok genpkg'.
|
pankso@22
|
356 copy_generic_files()
|
pankso@22
|
357 {
|
MikeDSmith25@82
|
358 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
|
pankso@22
|
359 # using generic variables and $LOCALE from Tazwok config file.
|
pankso@22
|
360 if [ ! "$LOCALE" = "" ]; then
|
pankso@22
|
361 if [ -d "$_pkg/usr/share/locale" ]; then
|
pankso@22
|
362 for i in $LOCALE
|
pankso@22
|
363 do
|
pankso@37
|
364 if [ -d "$_pkg/usr/share/locale/$i" ]; then
|
pankso@37
|
365 mkdir -p $fs/usr/share/locale
|
pankso@37
|
366 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
|
pankso@37
|
367 fi
|
pankso@22
|
368 done
|
pankso@22
|
369 fi
|
pankso@22
|
370 fi
|
MikeDSmith25@82
|
371 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
|
MikeDSmith25@82
|
372 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
|
pankso@31
|
373 # in pkg receipt.
|
pankso@22
|
374 if [ ! "$GENERIC_PIXMAPS" = "no" ]; then
|
pankso@22
|
375 if [ -d "$_pkg/usr/share/pixmaps" ]; then
|
pankso@27
|
376 mkdir -p $fs/usr/share/pixmaps
|
pankso@31
|
377 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
|
pankso@31
|
378 $fs/usr/share/pixmaps 2>/dev/null
|
pankso@31
|
379 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
|
pankso@22
|
380 $fs/usr/share/pixmaps 2>/dev/null
|
pankso@23
|
381 fi
|
MikeDSmith25@82
|
382 # Custom or homemade PNG pixmap can be in stuff.
|
pankso@23
|
383 if [ -f "stuff/$PACKAGE.png" ]; then
|
pankso@27
|
384 mkdir -p $fs/usr/share/pixmaps
|
pankso@23
|
385 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
|
pankso@22
|
386 fi
|
pankso@22
|
387 fi
|
pankso@22
|
388 # Desktop entry (.desktop).
|
pankso@22
|
389 if [ -d "$_pkg/usr/share/applications" ]; then
|
pankso@22
|
390 cp -a $_pkg/usr/share/applications $fs/usr/share
|
pankso@23
|
391 fi
|
MikeDSmith25@82
|
392 # Homemade desktop file(s) can be in stuff.
|
pankso@34
|
393 if [ -d "stuff/applications" ]; then
|
pankso@42
|
394 mkdir -p $fs/usr/share
|
pankso@42
|
395 cp -a stuff/applications $fs/usr/share
|
pankso@34
|
396 fi
|
pankso@34
|
397 if [ -f "stuff/$PACKAGE.desktop" ]; then
|
pankso@42
|
398 mkdir -p $fs/usr/share/applications
|
pankso@42
|
399 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
|
pankso@22
|
400 fi
|
pankso@22
|
401 }
|
pankso@22
|
402
|
pankso@25
|
403 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
|
pankso@25
|
404 strip_package()
|
pankso@25
|
405 {
|
pankso@25
|
406 echo -n "Executing strip on all files..."
|
pankso@25
|
407 # Binaries.
|
pankso@25
|
408 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
|
pankso@25
|
409 do
|
pankso@25
|
410 if [ -d "$dir" ]; then
|
pankso@25
|
411 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
|
pankso@25
|
412 fi
|
pankso@25
|
413 done
|
pankso@25
|
414 # Libraries.
|
pankso@25
|
415 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
|
pankso@25
|
416 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
|
pankso@25
|
417 status
|
pankso@25
|
418 }
|
pankso@25
|
419
|
MikeDSmith25@82
|
420 # Create a package tree and build the gziped cpio archive
|
pankso@7
|
421 # to make a SliTaz (.tazpkg) package.
|
pankso@7
|
422 gen_package()
|
pankso@7
|
423 {
|
pankso@7
|
424 check_root
|
pankso@7
|
425 check_for_package_on_cmdline
|
pankso@7
|
426 check_for_receipt
|
pascal@74
|
427 EXTRAVERSION=""
|
pankso@7
|
428 . $RECEIPT
|
pascal@86
|
429 # May compute VERSION
|
pascal@86
|
430 if grep -q ^get_version $RECEIPT; then
|
pascal@86
|
431 get_version
|
pascal@86
|
432 fi
|
pankso@7
|
433 check_for_wanted
|
pankso@7
|
434 cd $WOK/$PACKAGE
|
pankso@7
|
435 # Remove old Tazwok package files.
|
pankso@7
|
436 if [ -d "taz" ]; then
|
pankso@7
|
437 rm -rf taz
|
pankso@7
|
438 fi
|
MikeDSmith25@82
|
439 # Create the package tree and set useful variables.
|
pankso@7
|
440 mkdir -p taz/$PACKAGE-$VERSION/fs
|
pankso@7
|
441 fs=taz/$PACKAGE-$VERSION/fs
|
MikeDSmith25@82
|
442 # Set $src for standard package and $_pkg variables.
|
pankso@7
|
443 if [ "$WANTED" = "" ]; then
|
pankso@7
|
444 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
|
pankso@7
|
445 _pkg=$src/_pkg
|
pankso@7
|
446 fi
|
pankso@7
|
447 if [ ! "$SOURCE" = "" ]; then
|
pankso@7
|
448 src=$WOK/$PACKAGE/$SOURCE-$VERSION
|
pankso@7
|
449 _pkg=$src/_pkg
|
pankso@7
|
450 fi
|
pankso@7
|
451 cd $WOK/$PACKAGE
|
pankso@22
|
452 # Execute genpkg_rules and copy generic files to build the package.
|
pankso@7
|
453 echo ""
|
pascal@87
|
454 echo "Building $PACKAGE with the receipt..."
|
pankso@7
|
455 echo "================================================================================"
|
pankso@28
|
456 if grep -q ^genpkg_rules $RECEIPT; then
|
pankso@7
|
457 # Log process.
|
pankso@7
|
458 echo "executing genpkg_rules" >> $LOG
|
pankso@7
|
459 genpkg_rules
|
pankso@25
|
460 cd $WOK/$PACKAGE
|
pankso@24
|
461 # Skip generic files for packages with a WANTED variable
|
pankso@24
|
462 # (dev and splited pkgs).
|
pankso@24
|
463 if [ ! "$WANTED" = "" ]; then
|
pankso@24
|
464 continue
|
pankso@24
|
465 else
|
pankso@24
|
466 copy_generic_files
|
pankso@24
|
467 fi
|
pankso@25
|
468 strip_package
|
pankso@7
|
469 else
|
pankso@7
|
470 echo "No package rules to gen $PACKAGE..."
|
pankso@22
|
471 exit 1
|
pankso@7
|
472 fi
|
MikeDSmith25@82
|
473 # Copy the receipt and description (if exists) in the binary package tree.
|
pankso@7
|
474 cd $WOK/$PACKAGE
|
pankso@7
|
475 echo -n "Copying the receipt..."
|
pankso@7
|
476 cp receipt taz/$PACKAGE-$VERSION
|
pankso@7
|
477 status
|
pascal@89
|
478 if grep -q ^get_version $RECEIPT; then
|
pascal@89
|
479 echo -n "Update version in receipt..."
|
pascal@89
|
480 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
|
pascal@89
|
481 taz/$PACKAGE-$VERSION/receipt
|
pascal@89
|
482 status
|
pascal@89
|
483 fi
|
pankso@7
|
484 if [ -f "description.txt" ]; then
|
pankso@7
|
485 echo -n "Copying the description file..."
|
pankso@7
|
486 cp description.txt taz/$PACKAGE-$VERSION
|
pankso@7
|
487 status
|
pankso@7
|
488 fi
|
MikeDSmith25@82
|
489 # Create the files.list by redirecting find output.
|
pankso@7
|
490 echo -n "Creating the list of files..."
|
pascal@15
|
491 cd taz/$PACKAGE-$VERSION
|
pascal@13
|
492 LAST_FILE=""
|
pascal@15
|
493 ( find fs -print; echo ) | while read file; do
|
pascal@13
|
494 if [ "$LAST_FILE" != "" ]; then
|
pascal@15
|
495 case "$file" in
|
pascal@13
|
496 $LAST_FILE/*)
|
pascal@15
|
497 case "$(ls -ld "$LAST_FILE")" in
|
pascal@15
|
498 drwxr-xr-x\ *\ root\ *\ root\ *);;
|
pascal@15
|
499 *) echo ${LAST_FILE#fs};;
|
pascal@13
|
500 esac;;
|
pascal@15
|
501 *) echo ${LAST_FILE#fs};;
|
pascal@13
|
502 esac
|
pascal@13
|
503 fi
|
pascal@15
|
504 LAST_FILE="$file"
|
pascal@15
|
505 done > files.list
|
pankso@7
|
506 status
|
pascal@84
|
507 if [ -z "$EXTRAVERSION" ]; then
|
pascal@84
|
508 case "$PACKAGE" in
|
pascal@84
|
509 linux*);;
|
pascal@85
|
510 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
|
pascal@84
|
511 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
|
pascal@84
|
512 esac
|
pascal@84
|
513 fi
|
pascal@87
|
514 rm -f $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
|
pascal@70
|
515 echo -n "Creating md5sum of files..."
|
pascal@70
|
516 while read file; do
|
pascal@71
|
517 [ -L "fs$file" ] && continue
|
pascal@71
|
518 [ -f "fs$file" ] || continue
|
pascal@71
|
519 md5sum "fs$file" | sed 's/ fs/ /'
|
pascal@70
|
520 done < files.list > md5sum
|
pascal@70
|
521 status
|
pascal@70
|
522 [ -s md5sum ] || rm -f md5sum
|
pascal@84
|
523 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
|
pascal@84
|
524 2> /dev/null | awk '{ sz=$1 } END { print sz }')
|
pankso@7
|
525 # Build cpio archives. Find, cpio and gzip the fs, finish by
|
pankso@7
|
526 # removing the fs tree.
|
pankso@7
|
527 echo -n "Compressing the fs... "
|
pankso@56
|
528 find fs -print | cpio -o -H newc | gzip > fs.cpio.gz && rm -rf fs
|
pascal@84
|
529 PACKED_SIZE=$(du -chs fs.cpio.gz receipt files.list md5sum \
|
pascal@84
|
530 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
|
pascal@59
|
531 echo -n "Undating receipt sizes..."
|
pascal@59
|
532 sed -i s/^PACKED_SIZE.*$// receipt
|
pascal@59
|
533 sed -i s/^UNPACKED_SIZE.*$// receipt
|
pascal@59
|
534 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
|
pascal@86
|
535 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
|
pascal@59
|
536 status
|
pascal@72
|
537 if [ -n "$EXTRAVERSION" ]; then
|
pascal@72
|
538 echo -n "Undating receipt EXTRAVERSION..."
|
pascal@72
|
539 sed -i s/^EXTRAVERSION.*$// receipt
|
pascal@72
|
540 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
|
pascal@72
|
541 status
|
pascal@72
|
542 fi
|
pankso@7
|
543 echo -n "Creating full cpio archive... "
|
pascal@68
|
544 find . -print | cpio -o -H newc > $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
|
MikeDSmith25@82
|
545 # Restore package tree incase we want to browse it.
|
pankso@7
|
546 echo -n "Restoring original package tree... "
|
pascal@14
|
547 zcat fs.cpio.gz | cpio -id
|
pascal@14
|
548 rm fs.cpio.gz && cd ..
|
pankso@7
|
549 # Log process.
|
pascal@69
|
550 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
|
pankso@7
|
551 echo "================================================================================"
|
pascal@68
|
552 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
|
pascal@68
|
553 echo "Size : `du -sh $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
|
pankso@7
|
554 echo ""
|
pankso@7
|
555 }
|
pankso@7
|
556
|
pankso@28
|
557 # Optional text packages list for gen-list.
|
pankso@28
|
558 gen_textlist()
|
pankso@28
|
559 {
|
pankso@58
|
560 rm -f packages.desc
|
pankso@28
|
561 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
|
pankso@28
|
562 echo -n "Creating the text packages list... "
|
pankso@28
|
563 cat >> packages.txt << _EOT_
|
pankso@28
|
564 # SliTaz GNU/Linux - Packages list
|
pankso@28
|
565 #
|
pankso@28
|
566 # Packages : _packages_
|
pankso@28
|
567 # Date : $DATE
|
pankso@28
|
568 #
|
pankso@28
|
569 _EOT_
|
pankso@28
|
570 for pkg in $WOK/*
|
pankso@28
|
571 do
|
pankso@58
|
572 PACKAGE=""
|
pascal@60
|
573 PACKED_SIZE=""
|
pascal@60
|
574 if [ -f $pkg/taz/*/receipt ]; then
|
pascal@62
|
575 . $pkg/taz/*/receipt
|
pascal@62
|
576 else
|
pascal@60
|
577 . $pkg/receipt
|
pascal@60
|
578 fi
|
pankso@28
|
579 cat >> packages.txt << _EOT_
|
pankso@28
|
580
|
pankso@28
|
581 $PACKAGE
|
pankso@28
|
582 $VERSION
|
pankso@28
|
583 $SHORT_DESC
|
pankso@28
|
584 _EOT_
|
pascal@60
|
585 if [ -n "$PACKED_SIZE" ]; then
|
pascal@60
|
586 cat >> packages.txt << _EOT_
|
pascal@64
|
587 $PACKED_SIZE ($UNPACKED_SIZE installed)
|
pascal@60
|
588 _EOT_
|
pascal@60
|
589 fi
|
MikeDSmith25@82
|
590 # packages.desc is used by Tazpkgbox <tree>.
|
pankso@58
|
591 echo "$PACKAGE | $VERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> packages.desc
|
pankso@28
|
592 packages=$(($packages+1))
|
pankso@28
|
593 done && status
|
pascal@61
|
594 echo -n "Creating the text files list... "
|
pascal@61
|
595 for pkg in $WOK/*
|
pascal@61
|
596 do
|
pascal@63
|
597 if [ -f $pkg/taz/*/files.list ]; then
|
pascal@61
|
598 . $pkg/taz/*/receipt
|
pascal@61
|
599 ( echo "$PACKAGE"; cat $pkg/taz/*/files.list ) | awk '
|
pascal@61
|
600 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }'
|
pascal@61
|
601 else
|
pascal@61
|
602 echo "No files_list in $pkg" 1>&2
|
pascal@61
|
603 fi
|
pascal@61
|
604 done | lzma e files.list.lzma -si && status
|
pankso@28
|
605 sed -i s/"_packages_"/"$packages"/ packages.txt
|
pankso@28
|
606 }
|
pankso@28
|
607
|
pascal@91
|
608 # Return the date of the last commit in seconds since Jan 1 1970
|
pascal@91
|
609 hgdate()
|
pascal@91
|
610 {
|
pascal@91
|
611 local pkg
|
pascal@91
|
612 local date
|
pascal@91
|
613 local mon
|
pascal@91
|
614 # Default date is Jan 1 1970
|
pascal@91
|
615 [ -d $WOK/.hg ] || return 0
|
pascal@91
|
616 pkg=$(basename $1)
|
pascal@91
|
617 # Get date for last commit
|
pascal@91
|
618 date="$( cd $WOK; hg log $(find $pkg/receipt $pkg/stuff -type f \
|
pascal@91
|
619 2> /dev/null) | grep date: | head -1 | cut -c 6-)"
|
pascal@91
|
620 case "$(echo $date | awk '{ print $2 }')" in
|
pascal@91
|
621 Jan) mon="01";; Feb) mon="02";; Mar) mon="03";; Apr) mon="04";;
|
pascal@91
|
622 May) mon="05";; Jun) mon="06";; Jul) mon="07";; Aug) mon="08";;
|
pascal@91
|
623 Sep) mon="09";; Oct) mon="10";; Nov) mon="11";; Dec) mon="12";;
|
pascal@91
|
624 esac
|
pascal@91
|
625 # Reformat, don't mind about TZ: we look for days or months delta
|
pascal@91
|
626 echo $date | sed "s|[^ ]* [^ ]* \\(.*\\) \\(.*\\):\\(.*\\):\\(.*\\) \\(.*\\) .*|$mon\1\2\3\5|"
|
pascal@91
|
627 }
|
pascal@91
|
628
|
pankso@7
|
629 ###################
|
pankso@7
|
630 # Tazwok commands #
|
pankso@7
|
631 ###################
|
pankso@7
|
632
|
pankso@7
|
633 case "$COMMAND" in
|
pankso@7
|
634 stats)
|
pankso@7
|
635 # Tazwok general statistics from the config file the wok.
|
pankso@7
|
636 #
|
pankso@7
|
637 echo ""
|
pankso@7
|
638 echo -e "\033[1mTazwok configuration statistics\033[0m
|
pankso@7
|
639 ================================================================================
|
pankso@7
|
640 Wok directory : $WOK
|
pankso@7
|
641 Packages repository : $PACKAGES_REPOSITORY
|
pankso@7
|
642 Sources repository : $SOURCES_REPOSITORY
|
pankso@7
|
643 Packages in the wok : `ls -1 $WOK | wc -l`
|
pankso@16
|
644 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
|
pankso@7
|
645 ================================================================================"
|
pankso@7
|
646 echo ""
|
pankso@7
|
647 ;;
|
pascal@76
|
648 check)
|
pascal@76
|
649 # Check wok consistancy
|
pascal@76
|
650 echo ""
|
pascal@76
|
651 echo -e "\033[1mWok and packages checking\033[0m
|
pascal@76
|
652 ================================================================================"
|
pascal@77
|
653 cd $WOK
|
pascal@77
|
654 for pkg in $(ls)
|
pascal@76
|
655 do
|
pascal@76
|
656 [ -f $pkg/receipt ] || continue
|
pascal@76
|
657 PACKAGE=""
|
pascal@76
|
658 VERSION=""
|
pascal@76
|
659 CATEGORY=""
|
pascal@76
|
660 SHORT_DESC=""
|
pascal@76
|
661 MAINTAINER=""
|
pascal@76
|
662 WEB_SITE=""
|
pascal@79
|
663 DEPENDS=""
|
pascal@76
|
664 . $pkg/receipt
|
pascal@76
|
665 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg"
|
pascal@76
|
666 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION"
|
pascal@76
|
667 [ -n "$CATEGORY" ] || echo "Package $PACKAGE has no CATEGORY"
|
pascal@76
|
668 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC"
|
pascal@76
|
669 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER"
|
pascal@76
|
670 [ -n "$WEB_SITE" ] || echo "Package $PACKAGE has no WEB_SITE"
|
pascal@78
|
671 case "$MAINTAINER" in
|
pascal@78
|
672 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER";;
|
pascal@78
|
673 esac
|
pascal@78
|
674 case "$MAINTAINER" in
|
pascal@78
|
675 *@*);;
|
pascal@78
|
676 *) echo "Package $PACKAGE MAINTAINER is not an email address";;
|
pascal@78
|
677 esac
|
pascal@76
|
678 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
|
pascal@76
|
679 for i in $DEPENDS; do
|
pascal@76
|
680 [ -d $i ] && continue
|
pascal@76
|
681 echo -e "$MSG $i"
|
pascal@76
|
682 MSG=""
|
pascal@76
|
683 done
|
pascal@92
|
684 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
|
pascal@92
|
685 for i in $BUILD_DEPENDS; do
|
pascal@92
|
686 [ -d $i ] && continue
|
pascal@92
|
687 echo -e "$MSG $i"
|
pascal@92
|
688 MSG=""
|
pascal@92
|
689 done
|
pascal@76
|
690 MSG="Dependencies loop between $PACKAGE and :\n"
|
pascal@76
|
691 ALL_DEPS=""
|
pascal@76
|
692 check_for_deps_loop $PACKAGE $DEPENDS
|
pascal@76
|
693 done
|
pascal@76
|
694 ;;
|
pankso@66
|
695 cmp|compare)
|
MikeDSmith25@82
|
696 # Compare the wok and packages repository to help with maintaining
|
pankso@66
|
697 # a mirror.
|
pankso@65
|
698 echo ""
|
MikeDSmith25@82
|
699 echo -e "\033[1mWok and packages comparison\033[0m
|
pankso@65
|
700 ================================================================================"
|
pankso@65
|
701 for pkg in $WOK/*
|
pankso@65
|
702 do
|
pankso@65
|
703 . $pkg/receipt
|
pascal@74
|
704 echo "$PACKAGE-$VERSION.tazpkg" >> /tmp/wok.list
|
pascal@91
|
705 tpkg="$(ls $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg 2> /dev/null)"
|
pascal@91
|
706 if [ -z "$tpkg" ]; then
|
pascal@74
|
707 echo "Missing package: $PACKAGE ($VERSION)"
|
pankso@67
|
708 echo "$PACKAGE" >> /tmp/pkgs.missing
|
pascal@91
|
709 elif [ -f $pkg/taz/*/receipt -a ! -f $pkg/taz/*/md5sum ]; then
|
pascal@91
|
710 echo "Obsolete package: $PACKAGE ($VERSION)"
|
pascal@91
|
711 echo "$PACKAGE" >> /tmp/pkgs.missing
|
pascal@91
|
712 else
|
pascal@91
|
713 srcdate=$(hgdate $pkg)
|
pascal@91
|
714 pkgdate=$(date -u -r $tpkg '+%m%d%H%M%Y')
|
pascal@91
|
715 if [ $(date -d $pkgdate +%s) -lt $(date -d $srcdate +%s) ]; then
|
pascal@91
|
716 echo "Rebuild package: $PACKAGE ($VERSION) cooked $(date -d $pkgdate "+%x %X"), modified $(date -d $srcdate "+%x %X")"
|
pascal@91
|
717 echo "$PACKAGE" >> /tmp/pkgs.missing
|
pascal@91
|
718 fi
|
pankso@65
|
719 fi
|
pankso@65
|
720 done
|
pankso@66
|
721 for pkg in `cd $PACKAGES_REPOSITORY && ls *.tazpkg`
|
pankso@66
|
722 do
|
pascal@90
|
723 # grep $pkg in /tmp/wok.list
|
pascal@90
|
724 # may include EXTRAVERSION or computed VERSION
|
pascal@90
|
725 for i in $(grep ^${pkg%-*} /tmp/wok.list); do
|
pascal@74
|
726 case "$pkg" in
|
pascal@75
|
727 ${i%.tazpkg}*.tazpkg) continue 2;;
|
pascal@74
|
728 esac
|
pascal@74
|
729 done
|
MikeDSmith25@82
|
730 # Not found
|
pascal@74
|
731 echo $pkg >> /tmp/pkgs.old
|
pascal@74
|
732 if [ "$2" = "--remove" ]; then
|
pascal@74
|
733 echo "Removing package: $pkg"
|
pascal@74
|
734 rm $PACKAGES_REPOSITORY/$pkg
|
pascal@74
|
735 else
|
pascal@74
|
736 echo "Old package: $pkg"
|
pascal@74
|
737 fi
|
pankso@66
|
738 done
|
pankso@66
|
739 cd /tmp
|
pankso@65
|
740 echo "================================================================================"
|
pankso@66
|
741 echo "Wok: `cat wok.list | wc -l` - \
|
pankso@66
|
742 Cooked: `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l` - \
|
pankso@67
|
743 Missing: `cat pkgs.missing 2>/dev/null | wc -l` - \
|
pankso@67
|
744 Old: `cat pkgs.old 2>/dev/null | wc -l`"
|
pankso@65
|
745 echo ""
|
pankso@67
|
746 rm -f wok.list pkgs.old pkgs.missing
|
pankso@65
|
747 ;;
|
pankso@7
|
748 list)
|
pankso@7
|
749 # List packages in wok directory. User can specifiy a category
|
pankso@7
|
750 #
|
pankso@7
|
751 if [ "$2" = "category" ]; then
|
pankso@7
|
752 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
|
pankso@7
|
753 exit 0
|
pankso@7
|
754 fi
|
pankso@7
|
755 # Check for an asked category.
|
pankso@7
|
756 if [ -n "$2" ]; then
|
pankso@7
|
757 ASKED_CATEGORY=$2
|
pankso@7
|
758 echo ""
|
pankso@7
|
759 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
|
pankso@7
|
760 echo "================================================================================"
|
pankso@7
|
761 for pkg in $WOK/*
|
pankso@7
|
762 do
|
pankso@7
|
763 . $pkg/receipt
|
pankso@7
|
764 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
|
pankso@7
|
765 echo -n "$PACKAGE"
|
pankso@28
|
766 echo -e "\033[28G $VERSION"
|
pankso@7
|
767 packages=$(($packages+1))
|
pankso@7
|
768 fi
|
pankso@7
|
769 done
|
pankso@7
|
770 echo "================================================================================"
|
pankso@7
|
771 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
|
pankso@7
|
772 else
|
pankso@7
|
773 # By default list all packages and version.
|
pankso@7
|
774 echo ""
|
pankso@7
|
775 echo -e "\033[1mList of packages in the wok\033[0m"
|
pankso@7
|
776 echo "================================================================================"
|
pankso@7
|
777 for pkg in $WOK/*
|
pankso@7
|
778 do
|
pankso@7
|
779 . $pkg/receipt
|
pankso@7
|
780 echo -n "$PACKAGE"
|
pankso@28
|
781 echo -en "\033[28G $VERSION"
|
pankso@7
|
782 echo -e "\033[42G $CATEGORY"
|
pankso@7
|
783 packages=$(($packages+1))
|
pankso@7
|
784 done
|
pankso@7
|
785 echo "================================================================================"
|
MikeDSmith25@82
|
786 echo -e "$packages packages available in the wok.\n"
|
pankso@7
|
787 fi
|
pankso@7
|
788 ;;
|
pankso@7
|
789 info)
|
MikeDSmith25@82
|
790 # Information about a package.
|
pankso@7
|
791 #
|
pankso@7
|
792 check_for_package_on_cmdline
|
pankso@7
|
793 check_for_receipt
|
pankso@7
|
794 . $WOK/$PACKAGE/receipt
|
pankso@7
|
795 echo ""
|
MikeDSmith25@82
|
796 echo -e "\033[1mTazwok package information\033[0m
|
pankso@7
|
797 ================================================================================
|
pankso@7
|
798 Package : $PACKAGE
|
pankso@7
|
799 Version : $VERSION
|
pankso@7
|
800 Category : $CATEGORY
|
pankso@7
|
801 Short desc : $SHORT_DESC
|
pankso@7
|
802 Maintainer : $MAINTAINER"
|
pankso@7
|
803 if [ ! "$WEB_SITE" = "" ]; then
|
pankso@7
|
804 echo "Web site : $WEB_SITE"
|
pankso@7
|
805 fi
|
pankso@7
|
806 if [ ! "$DEPENDS" = "" ]; then
|
pankso@7
|
807 echo "Depends : $DEPENDS"
|
pankso@7
|
808 fi
|
pankso@7
|
809 if [ ! "$WANTED" = "" ]; then
|
pankso@7
|
810 echo "Wanted src : $WANTED"
|
pankso@7
|
811 fi
|
pankso@7
|
812 echo "================================================================================"
|
pankso@7
|
813 echo ""
|
pankso@7
|
814
|
pankso@7
|
815 ;;
|
pankso@7
|
816 check-log)
|
pankso@7
|
817 # We just cat the file log to view process info.
|
pankso@7
|
818 #
|
pankso@7
|
819 if [ ! -f "$LOG" ]; then
|
MikeDSmith25@82
|
820 echo -e "\nNo process log found. The package is probably not cooked.\n"
|
pankso@7
|
821 exit 0
|
pankso@7
|
822 else
|
pankso@7
|
823 echo ""
|
pankso@7
|
824 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
|
pankso@7
|
825 echo "================================================================================"
|
pankso@7
|
826 cat $LOG
|
pankso@7
|
827 echo "================================================================================"
|
pankso@7
|
828 echo ""
|
pankso@7
|
829 fi
|
pankso@7
|
830 ;;
|
pankso@7
|
831 search)
|
pankso@7
|
832 # Search for a package by pattern or name.
|
pankso@7
|
833 #
|
pankso@7
|
834 if [ -z "$2" ]; then
|
pankso@7
|
835 echo -e "\nPlease specify a pattern or a package name to search."
|
pankso@7
|
836 echo -e "Example : 'tazwok search gcc'.\n"
|
pankso@7
|
837 exit 0
|
pankso@7
|
838 fi
|
pankso@7
|
839 echo ""
|
pankso@7
|
840 echo -e "\033[1mSearch result for :\033[0m $2"
|
pankso@7
|
841 echo "================================================================================"
|
pankso@7
|
842 list=`ls -1 $WOK | grep $2`
|
pankso@7
|
843 for pkg in $list
|
pankso@7
|
844 do
|
pankso@7
|
845 . $WOK/$pkg/receipt
|
pankso@7
|
846 echo -n "$PACKAGE "
|
pankso@7
|
847 echo -en "\033[24G $VERSION"
|
pankso@7
|
848 echo -e "\033[42G $CATEGORY"
|
pankso@7
|
849 packages=$(($packages+1))
|
pankso@7
|
850 done
|
pankso@7
|
851 echo "================================================================================"
|
pankso@7
|
852 echo "$packages packages found for : $2"
|
pankso@7
|
853 echo ""
|
pankso@7
|
854 ;;
|
pankso@7
|
855 compile)
|
pankso@7
|
856 # Configure and make a package with the receipt.
|
pankso@7
|
857 #
|
pankso@7
|
858 compile_package
|
pankso@7
|
859 ;;
|
pankso@7
|
860 genpkg)
|
pankso@7
|
861 # Generate a package
|
pankso@7
|
862 #
|
pankso@7
|
863 gen_package
|
pankso@7
|
864 ;;
|
pankso@7
|
865 cook)
|
pankso@7
|
866 # Compile and generate a package. Just execute tazwok with
|
pankso@7
|
867 # the good commands.
|
pankso@7
|
868 #
|
pankso@7
|
869 check_root
|
pankso@7
|
870 compile_package
|
pankso@7
|
871 gen_package
|
pankso@7
|
872 ;;
|
pankso@7
|
873 cook-list)
|
pankso@7
|
874 # Cook all packages listed in a file. The path to the cooklist must
|
pankso@7
|
875 # be specified on the cmdline.
|
pankso@7
|
876 #
|
pankso@7
|
877 check_root
|
pankso@7
|
878 check_for_list
|
pankso@7
|
879 for pkg in $LIST
|
pankso@7
|
880 do
|
pankso@7
|
881 tazwok compile $pkg
|
pankso@7
|
882 tazwok genpkg $pkg
|
pankso@7
|
883 done
|
pankso@7
|
884 ;;
|
pankso@7
|
885 clean)
|
pankso@7
|
886 # Clean up a package work directory.
|
pankso@7
|
887 #
|
pankso@7
|
888 check_for_package_on_cmdline
|
pankso@7
|
889 check_for_receipt
|
pankso@7
|
890 . $RECEIPT
|
pankso@7
|
891 cd $WOK/$PACKAGE
|
pankso@7
|
892 echo ""
|
pankso@7
|
893 echo "Cleaning $PACKAGE..."
|
pankso@7
|
894 echo "================================================================================"
|
pankso@28
|
895 # Check for clean_wok function.
|
pankso@28
|
896 if grep -q ^clean_wok $RECEIPT; then
|
pankso@28
|
897 clean_wok
|
pankso@28
|
898 fi
|
MikeDSmith25@82
|
899 # Remove taz/ and source tree if exists.
|
pankso@7
|
900 if [ -d "taz" ]; then
|
pankso@7
|
901 echo -n "Removing taz files..."
|
pankso@7
|
902 rm -rf taz && status
|
pankso@7
|
903 fi
|
pankso@7
|
904 if [ -d "$PACKAGE-$VERSION" ]; then
|
pankso@7
|
905 echo -n "Removing source files..."
|
pankso@7
|
906 rm -rf $PACKAGE-$VERSION && status
|
pankso@7
|
907 fi
|
pankso@7
|
908 if [ -d "$SOURCE-$VERSION" ]; then
|
pankso@7
|
909 echo -n "Removing source files..."
|
pankso@7
|
910 rm -rf $SOURCE-$VERSION && status
|
pankso@7
|
911 fi
|
pankso@7
|
912 # Remove an envental $PACKAGE-build directory.
|
pankso@7
|
913 if [ -d "$PACKAGE-build" ]; then
|
pankso@7
|
914 echo -n "Removing build tree..."
|
pankso@7
|
915 rm -rf $PACKAGE-build && status
|
pankso@7
|
916 fi
|
pankso@7
|
917 # Remove process log file.
|
pankso@7
|
918 if [ -f "process.log" ]; then
|
pankso@7
|
919 echo -n "Removing process log file..."
|
pankso@7
|
920 rm process.log && status
|
pankso@28
|
921 echo "================================================================================"
|
pankso@7
|
922 fi
|
pankso@7
|
923 echo "$PACKAGE is clean. You can cook it again..."
|
pankso@7
|
924 echo ""
|
pankso@7
|
925 ;;
|
pankso@7
|
926 gen-clean-wok)
|
pankso@7
|
927 # Generate a clean wok from the current wok by copying all receipt
|
pankso@7
|
928 # and stuff directory.
|
pankso@7
|
929 #
|
pankso@7
|
930 if [ -z "$2" ]; then
|
pankso@7
|
931 echo -e "\nPlease specify the destination for the new clean wok.\n"
|
pankso@7
|
932 exit 0
|
pankso@7
|
933 else
|
pankso@7
|
934 dest=$2
|
pankso@7
|
935 mkdir -p $dest
|
pankso@7
|
936 fi
|
pankso@7
|
937 echo "New wok is going to : $dest"
|
pankso@7
|
938 for pkg in `ls -1 $WOK`
|
pankso@7
|
939 do
|
pankso@7
|
940 echo "----"
|
pankso@7
|
941 echo -n "Preparing $pkg..."
|
pankso@7
|
942 mkdir -p $dest/$pkg
|
pankso@7
|
943 status
|
pankso@7
|
944 echo -n "Copying the receipt..."
|
pankso@7
|
945 cp -a $WOK/$pkg/receipt $dest/$pkg
|
pankso@7
|
946 status
|
pankso@7
|
947 if [ -d "$WOK/$pkg/stuff" ]; then
|
pankso@7
|
948 echo -n "Copying all the stuff directory..."
|
pankso@7
|
949 cp -a $WOK/$pkg/stuff $dest/$pkg
|
pankso@7
|
950 status
|
pankso@7
|
951 fi
|
pankso@7
|
952 done
|
pankso@7
|
953 echo "================================================================================"
|
pankso@7
|
954 echo "Clean wok generated in : $dest"
|
pankso@7
|
955 echo "Packages cleaned : `ls -1 $dest | wc -l`"
|
pankso@7
|
956 echo ""
|
pankso@7
|
957 ;;
|
pankso@7
|
958 clean-wok)
|
pankso@7
|
959 # Clean all packages in the work directory
|
pankso@7
|
960 #
|
pankso@7
|
961 for pkg in `ls -1 $WOK`
|
pankso@7
|
962 do
|
pankso@7
|
963 tazwok clean $pkg
|
pankso@7
|
964 done
|
pankso@7
|
965 echo "================================================================================"
|
pankso@7
|
966 echo "`ls -1 $WOK | wc -l` packages cleaned."
|
pankso@7
|
967 echo ""
|
pankso@7
|
968 ;;
|
pankso@7
|
969 gen-list)
|
pankso@7
|
970 # Sed is used to remove all the .tazpkg extensions from the
|
pankso@7
|
971 # packages.list. The directory to move in by default is the repository
|
pankso@28
|
972 # if $2 is not empty cd into $2. A text packages list can also be gen
|
pankso@28
|
973 # with the option --text.
|
pankso@7
|
974 #
|
pankso@28
|
975 if [ "$2" == "--text" ]; then
|
pankso@28
|
976 textlist="yes"
|
pankso@28
|
977 elif [ -z "$2" ]; then
|
pankso@7
|
978 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
|
pankso@7
|
979 else
|
pankso@7
|
980 if [ -d "$2" ]; then
|
pankso@7
|
981 PACKAGES_REPOSITORY=$2
|
pankso@7
|
982 else
|
pankso@7
|
983 echo -e "\nUnable to find directory : $2\n"
|
pankso@7
|
984 exit 0
|
pankso@7
|
985 fi
|
pankso@7
|
986 fi
|
pankso@7
|
987 cd $PACKAGES_REPOSITORY
|
MikeDSmith25@82
|
988 # Remove old packages.list and md5sum, they will soon be rebuilt.
|
pankso@28
|
989 rm -f packages.list packages.md5 packages.txt
|
pankso@7
|
990 echo ""
|
pankso@28
|
991 echo -e "\033[1mGenerating packages lists\033[0m"
|
pankso@28
|
992 echo "================================================================================"
|
pankso@28
|
993 echo -n "Repository path : $PACKAGES_REPOSITORY" && status
|
MikeDSmith25@82
|
994 # Generate packages.txt
|
pankso@28
|
995 if [ "$textlist" == "yes" ]; then
|
pankso@28
|
996 gen_textlist
|
pankso@28
|
997 fi
|
pankso@28
|
998 echo -n "Creating the raw packages list... "
|
pankso@17
|
999 ls -1 *.tazpkg > /tmp/packages.list
|
pankso@7
|
1000 sed -i s/'.tazpkg'/''/ /tmp/packages.list
|
pankso@7
|
1001 status
|
pankso@7
|
1002 echo -n "Building the md5sum for all packages... "
|
pankso@7
|
1003 md5sum * > packages.md5
|
pankso@7
|
1004 status
|
pankso@7
|
1005 mv /tmp/packages.list $PACKAGES_REPOSITORY
|
pankso@7
|
1006 echo "================================================================================"
|
pankso@7
|
1007 pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
|
pankso@7
|
1008 echo "$pkgs packages in the repository."
|
pankso@7
|
1009 echo ""
|
pankso@7
|
1010 ;;
|
pankso@7
|
1011 new-tree)
|
MikeDSmith25@82
|
1012 # Just create a few directories and generate an empty receipt to prepare
|
pankso@7
|
1013 # the creation of a new package.
|
pankso@7
|
1014 #
|
pankso@7
|
1015 check_for_package_on_cmdline
|
pankso@7
|
1016 if [ -d $WOK/$PACKAGE ]; then
|
MikeDSmith25@82
|
1017 echo -e "\n$PACKAGE package tree already exists.\n"
|
pankso@7
|
1018 exit 0
|
pankso@7
|
1019 fi
|
pankso@7
|
1020 echo "Creating : $WOK/$PACKAGE"
|
pankso@7
|
1021 mkdir $WOK/$PACKAGE
|
pankso@7
|
1022 cd $WOK/$PACKAGE
|
pankso@7
|
1023 echo -n "Preparing the receipt..."
|
pankso@7
|
1024 #
|
pankso@7
|
1025 # Default receipt begin.
|
pankso@7
|
1026 #
|
pankso@7
|
1027 echo "# SliTaz package receipt." > receipt
|
pankso@7
|
1028 echo "" >> receipt
|
pankso@7
|
1029 echo "PACKAGE=\"$PACKAGE\"" >> receipt
|
pankso@7
|
1030 # Finish the empty receipt.
|
pankso@7
|
1031 cat >> receipt << "EOF"
|
pankso@7
|
1032 VERSION=""
|
pankso@7
|
1033 CATEGORY=""
|
pankso@7
|
1034 SHORT_DESC=""
|
pankso@7
|
1035 MAINTAINER=""
|
pankso@7
|
1036 DEPENDS=""
|
pankso@7
|
1037 TARBALL="$PACKAGE-$VERSION.tar.gz"
|
pankso@7
|
1038 WEB_SITE=""
|
pankso@7
|
1039 WGET_URL=""
|
pankso@7
|
1040
|
pankso@7
|
1041 # Rules to configure and make the package.
|
pankso@7
|
1042 compile_rules()
|
pankso@7
|
1043 {
|
pankso@7
|
1044 cd $src
|
pankso@7
|
1045 ./configure --prefix=/usr --infodir=/usr/share/info \
|
pascal@87
|
1046 --mandir=/usr/share/man $CONFIGURE_ARGS && \
|
pascal@87
|
1047 make && make DESTDIR=$PWD/_pkg install
|
pankso@7
|
1048 }
|
pankso@7
|
1049
|
pankso@7
|
1050 # Rules to gen a SliTaz package suitable for Tazpkg.
|
pankso@7
|
1051 genpkg_rules()
|
pankso@7
|
1052 {
|
pankso@7
|
1053 mkdir -p $fs/usr
|
pankso@7
|
1054 cp -a $_pkg/usr/bin $fs/usr
|
pankso@7
|
1055 }
|
pankso@7
|
1056
|
pankso@7
|
1057 EOF
|
pankso@7
|
1058 #
|
pankso@7
|
1059 # Default receipt end.
|
pankso@7
|
1060 #
|
pankso@7
|
1061 status
|
pankso@7
|
1062 # Interactive mode, asking and seding.
|
pankso@7
|
1063 if [ "$3" = "--interactive" ]; then
|
pankso@7
|
1064 echo "Entering in interactive mode..."
|
pankso@7
|
1065 echo "================================================================================"
|
pankso@7
|
1066 echo "Package : $PACKAGE"
|
pankso@7
|
1067 # Version.
|
pankso@7
|
1068 echo -n "Version : " ; read anser
|
pankso@7
|
1069 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
|
pankso@7
|
1070 # Category.
|
pankso@7
|
1071 echo -n "Category : " ; read anser
|
pankso@7
|
1072 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
|
pankso@7
|
1073 # Short description.
|
pankso@7
|
1074 echo -n "Short desc : " ; read anser
|
pankso@7
|
1075 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
|
pankso@7
|
1076 # Maintainer.
|
pankso@7
|
1077 echo -n "Maintainer : " ; read anser
|
pankso@7
|
1078 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
|
pankso@7
|
1079 # Web site.
|
pankso@7
|
1080 echo -n "Web site : " ; read anser
|
pankso@7
|
1081 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
|
pankso@7
|
1082 echo ""
|
pankso@7
|
1083 # Wget URL.
|
pankso@7
|
1084 echo "Wget URL to download source tarball."
|
pankso@7
|
1085 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
|
pankso@7
|
1086 echo -n "Wget url : " ; read anser
|
pankso@7
|
1087 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
|
pankso@7
|
1088 # Ask for a stuff dir.
|
pankso@7
|
1089 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
|
pankso@7
|
1090 if [ "$anser" = "y" ]; then
|
pankso@7
|
1091 echo -n "Creating the stuff directory..."
|
pankso@7
|
1092 mkdir stuff && status
|
pankso@7
|
1093 fi
|
pankso@7
|
1094 # Ask for a description file.
|
pankso@7
|
1095 echo -n "Are you going to write a description ? (y/N) : " ; read anser
|
pankso@7
|
1096 if [ "$anser" = "y" ]; then
|
pankso@7
|
1097 echo -n "Creating the description.txt file..."
|
pankso@7
|
1098 echo "" > description.txt && status
|
pankso@7
|
1099 fi
|
pankso@7
|
1100 echo "================================================================================"
|
pankso@7
|
1101 echo ""
|
pankso@7
|
1102 fi
|
pankso@7
|
1103 ;;
|
pankso@7
|
1104 remove)
|
pankso@7
|
1105 # Remove a package from the wok.
|
pankso@7
|
1106 #
|
pankso@7
|
1107 check_for_package_on_cmdline
|
pankso@7
|
1108 echo ""
|
pascal@83
|
1109 echo -n "Please confirm deletion (y/N) : "; read anser
|
pascal@83
|
1110 if [ "$anser" = "y" ]; then
|
pascal@83
|
1111 echo -n "Removing $PACKAGE..."
|
pascal@83
|
1112 rm -rf $WOK/$PACKAGE && status
|
pascal@83
|
1113 echo ""
|
pascal@83
|
1114 fi
|
pankso@7
|
1115 ;;
|
pankso@7
|
1116 usage|*)
|
MikeDSmith25@82
|
1117 # Print usage also for all unknown commands.
|
pankso@7
|
1118 #
|
pankso@7
|
1119 usage
|
pankso@7
|
1120 ;;
|
pankso@7
|
1121 esac
|
pankso@7
|
1122
|
pankso@7
|
1123 exit 0
|