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