rev |
line source |
pankso@7
|
1 #!/bin/sh
|
pankso@7
|
2 # Tazwok - SliTaz source compiler and binary packages generator/cooker.
|
pankso@7
|
3 #
|
pankso@7
|
4 # Tazwok can compile source package and creat binary packages suitable for
|
pankso@7
|
5 # Tazpkg (Tiny Autonomus zone package manager). You can build individuals
|
pankso@7
|
6 # package or a list a 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@22
|
11 VERSION=1.3.1
|
pankso@7
|
12
|
pankso@7
|
13 ####################
|
pankso@7
|
14 # Tazwok variables #
|
pankso@7
|
15 ####################
|
pankso@7
|
16
|
pankso@7
|
17 # Packages categories.
|
pankso@18
|
18 CATEGORIES="base-system base-apps x-window devel extra"
|
pankso@7
|
19
|
pankso@7
|
20 # Use words rater than numbers in the code.
|
pankso@7
|
21 COMMAND=$1
|
pankso@7
|
22 PACKAGE=$2
|
pankso@7
|
23 LIST=$2
|
pankso@7
|
24
|
pankso@7
|
25 # Include config file or exit if any file found.
|
pankso@7
|
26 if [ -f "/etc/tazwok.conf" ]; then
|
pankso@7
|
27 . /etc/tazwok.conf
|
pankso@7
|
28 else
|
pankso@7
|
29 echo -e "\nUnable to find the configuration file : /etc/tazwok.conf"
|
pankso@7
|
30 echo -e "Please read the Tazwok documentation.\n"
|
pankso@7
|
31 exit 0
|
pankso@7
|
32 fi
|
pankso@7
|
33
|
pankso@7
|
34 # Creat Taz wok needed directories if user is root.
|
pankso@7
|
35 if test $(id -u) = 0 ; then
|
pankso@7
|
36 # Check for the wok directory.
|
pankso@7
|
37 if [ ! -d "$WOK" ]; then
|
pankso@7
|
38 echo "Creating the wok directory..."
|
pankso@7
|
39 mkdir -p $WOK
|
pankso@7
|
40 chmod 777 $WOK
|
pankso@7
|
41 fi
|
pankso@7
|
42 # Check for the packages repository.
|
pankso@7
|
43 if [ ! -d "$PACKAGES_REPOSITORY" ]; then
|
pankso@7
|
44 echo "Creating the packages repository..."
|
pankso@7
|
45 mkdir -p $PACKAGES_REPOSITORY
|
pankso@7
|
46 fi
|
pankso@7
|
47 # Check for the sources repository.
|
pankso@7
|
48 if [ ! -d "$SOURCES_REPOSITORY" ]; then
|
pankso@7
|
49 echo "Creating the sources repository..."
|
pankso@17
|
50 mkdir -p $SOURCES_REPOSITORY
|
pankso@7
|
51 fi
|
pankso@7
|
52 fi
|
pankso@7
|
53
|
pankso@7
|
54 # The path to the most important file used by Tazwok.
|
pankso@7
|
55 # The receipt is used to compile the source code and
|
pankso@7
|
56 # gen suitables packages for Tazpkg.
|
pankso@7
|
57 RECEIPT="$WOK/$PACKAGE/receipt"
|
pankso@7
|
58
|
pankso@7
|
59 # The path to the process log file.
|
pankso@7
|
60 LOG="$WOK/$PACKAGE/process.log"
|
pankso@7
|
61
|
pankso@7
|
62 ####################
|
pankso@7
|
63 # Tazwok functions #
|
pankso@7
|
64 ####################
|
pankso@7
|
65
|
pankso@7
|
66 # Print the usage (English).
|
pankso@7
|
67 usage ()
|
pankso@7
|
68 {
|
pankso@7
|
69 echo -e "\nSliTaz sources compiler and packages generator - Version: $VERSION\n
|
pankso@7
|
70 \033[1mUsage: \033[0m `basename $0` [command] [package|list|category|dir] [--option]
|
pankso@7
|
71 \033[1mCommands: \033[0m\n
|
pankso@7
|
72 usage Print this short usage.
|
pankso@7
|
73 stats Print Tazwok statistics from the config file and the wok.
|
pankso@7
|
74 list List all packages in the wok tree or by category.
|
pankso@7
|
75 info Get informations about a package in the wok.
|
pankso@7
|
76 check-log Check the process log file of a package.
|
pankso@7
|
77 search Search for a package in the wok by pattern or name.
|
pankso@7
|
78 compile Configure and build the package using the receipt rules.
|
pankso@7
|
79 genpkg Generate a suitable package for Tazpkg with the rules.
|
pankso@7
|
80 cook Compile and generate a package directly.
|
pankso@7
|
81 cook-list Cook all packages specified in the list by order.
|
pankso@7
|
82 clean Clean all generated files in the package tree.
|
pankso@7
|
83 new-tree Prepare a new package tree and receipt (--interactive).
|
pankso@7
|
84 gen-list Generate a packages.list and md5sum for a repository.
|
pankso@7
|
85 gen-clean-wok Gen a clean wok in a dir ('clean-wok' cleans current wok).
|
pankso@7
|
86 remove Remove a package from the wok.\n"
|
pankso@7
|
87 }
|
pankso@7
|
88
|
pankso@7
|
89 # Status function.
|
pankso@7
|
90 status()
|
pankso@7
|
91 {
|
pankso@7
|
92 local CHECK=$?
|
pankso@7
|
93 echo -en "\\033[70G[ "
|
pankso@7
|
94 if [ $CHECK = 0 ]; then
|
pankso@7
|
95 echo -en "\\033[1;33mOK"
|
pankso@7
|
96 else
|
pankso@7
|
97 echo -en "\\033[1;31mFailed"
|
pankso@7
|
98 fi
|
pankso@7
|
99 echo -e "\\033[0;39m ]"
|
pankso@7
|
100 }
|
pankso@7
|
101
|
pankso@7
|
102 # Check if user is root.
|
pankso@7
|
103 check_root()
|
pankso@7
|
104 {
|
pankso@7
|
105 if test $(id -u) != 0 ; then
|
pankso@7
|
106 echo -e "\nYou must be root to run `basename $0` with this option."
|
pankso@7
|
107 echo -e "Please type 'su' and root password to become super-user.\n"
|
pankso@7
|
108 exit 0
|
pankso@7
|
109 fi
|
pankso@7
|
110 }
|
pankso@7
|
111
|
pankso@7
|
112 # Check for a package name on cmdline.
|
pankso@7
|
113 check_for_package_on_cmdline()
|
pankso@7
|
114 {
|
pankso@7
|
115 if [ -z "$PACKAGE" ]; then
|
pankso@7
|
116 echo -e "\nYou must specify a package name on the command line."
|
pankso@7
|
117 echo -e "Example : tazwok $COMMAND package\n"
|
pankso@7
|
118 exit 0
|
pankso@7
|
119 fi
|
pankso@7
|
120 }
|
pankso@7
|
121
|
pankso@7
|
122 # Check for the receipt of a package used to cook.
|
pankso@7
|
123 check_for_receipt()
|
pankso@7
|
124 {
|
pankso@7
|
125 if [ ! -f "$RECEIPT" ]; then
|
pankso@7
|
126 echo -e "\nUnable to find the receipt : $RECEIPT\n"
|
pankso@7
|
127 exit 0
|
pankso@7
|
128 fi
|
pankso@7
|
129 }
|
pankso@7
|
130
|
pankso@7
|
131 # Check for a specified file list on cmdline.
|
pankso@7
|
132 check_for_list()
|
pankso@7
|
133 {
|
pankso@7
|
134 if [ -z "$LIST" ]; then
|
pankso@7
|
135 echo -e "\nPlease specify the path to the list of packages to cook.\n"
|
pankso@7
|
136 exit 0
|
pankso@7
|
137 fi
|
pankso@7
|
138 # Check if the list of packages exist.
|
pankso@7
|
139 if [ -f "$LIST" ]; then
|
pankso@7
|
140 LIST=`cat $LIST`
|
pankso@7
|
141 else
|
pankso@7
|
142 echo -e "\nUnable to find $LIST packages list.\n"
|
pankso@7
|
143 exit 0
|
pankso@7
|
144 fi
|
pankso@7
|
145 }
|
pankso@7
|
146
|
pankso@7
|
147 # Check for the wanted package if specified in WANTED
|
pankso@7
|
148 # receipt variable. Set the $src/$_pkg variable to help compiling
|
pankso@7
|
149 # and generating packages.
|
pankso@7
|
150 check_for_wanted()
|
pankso@7
|
151 {
|
pankso@7
|
152 if [ ! "$WANTED" = "" ]; then
|
pankso@7
|
153 echo -n "Checking for the wanted package..."
|
pankso@7
|
154 if [ ! -d "$WOK/$WANTED" ]; then
|
pankso@7
|
155 echo -e "\nWanted package is missing in the work directory.\n"
|
pankso@7
|
156 exit 0
|
pankso@7
|
157 fi
|
pankso@7
|
158 status
|
pankso@7
|
159 # Set wanted src path.
|
pankso@7
|
160 src=$WOK/$WANTED/$WANTED-$VERSION
|
pankso@7
|
161 _pkg=$src/_pkg
|
pankso@7
|
162 fi
|
pankso@7
|
163 }
|
pankso@7
|
164
|
pankso@18
|
165 # Check for build dependencies and notify user.
|
pankso@18
|
166 check_for_build_depends()
|
pankso@18
|
167 {
|
pankso@18
|
168 echo "Checking for build dependencies..."
|
pankso@18
|
169 for pkg in $BUILD_DEPENDS
|
pankso@18
|
170 do
|
pankso@18
|
171 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
|
pankso@18
|
172 MISSING_PACKAGE=$pkg
|
pankso@18
|
173 fi
|
pankso@18
|
174 done
|
pankso@18
|
175 if [ ! "$MISSING_PACKAGE" = "" ]; then
|
pankso@18
|
176 echo "================================================================================"
|
pankso@18
|
177 for pkg in $BUILD_DEPENDS
|
pankso@18
|
178 do
|
pankso@18
|
179 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
|
pankso@18
|
180 MISSING_PACKAGE=$pkg
|
pankso@18
|
181 echo "Missing : $pkg"
|
pankso@18
|
182 fi
|
pankso@18
|
183 done
|
pankso@18
|
184 echo "================================================================================"
|
pankso@18
|
185 echo "You can continue or exit to install missing dependencies."
|
pankso@18
|
186 echo -n "Continue or exit (y/N) ? "; read anser
|
pankso@18
|
187 if [ "$anser" == "y" ]; then
|
pankso@18
|
188 continue
|
pankso@18
|
189 else
|
pankso@18
|
190 exit 0
|
pankso@18
|
191 fi
|
pankso@18
|
192 fi
|
pankso@18
|
193 }
|
pankso@18
|
194
|
pankso@7
|
195 # Configure and make a package with the receipt.
|
pankso@7
|
196 compile_package()
|
pankso@7
|
197 {
|
pankso@7
|
198 check_for_package_on_cmdline
|
pankso@7
|
199 # Include the receipt to get all needed variables and functions
|
pankso@7
|
200 # and cd into the work directory to start the work.
|
pankso@7
|
201 check_for_receipt
|
pankso@7
|
202 . $RECEIPT
|
pankso@7
|
203 # Log the package name and date.
|
pankso@7
|
204 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
|
pankso@7
|
205 echo "package $PACKAGE (compile)" >> $LOG
|
pankso@7
|
206 # Set wanted $src variable to help compiling.
|
pankso@7
|
207 if [ ! "$SOURCE" = "" ]; then
|
pankso@7
|
208 src=$WOK/$PACKAGE/$SOURCE-$VERSION
|
pankso@7
|
209 else
|
pankso@7
|
210 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
|
pankso@7
|
211 fi
|
pankso@18
|
212 check_for_build_depends
|
pankso@7
|
213 check_for_wanted
|
pankso@7
|
214 echo ""
|
pankso@7
|
215 echo "Starting to cook $PACKAGE..."
|
pankso@7
|
216 echo "================================================================================"
|
pankso@7
|
217 # Check for src tarball and wget if needed.
|
pankso@7
|
218 if [ ! "$TARBALL" = "" ]; then
|
pankso@7
|
219 echo "Checking for source tarball... "
|
pankso@7
|
220 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
|
pankso@7
|
221 cd $SOURCES_REPOSITORY
|
pankso@7
|
222 wget $WGET_URL
|
pankso@7
|
223 # Exit if download failed to avoid errors.
|
pankso@7
|
224 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
|
pankso@7
|
225 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n"
|
pankso@7
|
226 exit 1
|
pankso@7
|
227 fi
|
pankso@7
|
228 else
|
pankso@7
|
229 echo -n "Source tarball exit... "
|
pankso@7
|
230 status
|
pankso@7
|
231 fi
|
pankso@7
|
232 # Untaring source if necessary. We dont need to extract source if
|
pankso@7
|
233 # the package is build with a wanted source package.
|
pankso@7
|
234 if [ "$WANTED" = "" ]; then
|
pankso@7
|
235 if [ ! -d $src ]; then
|
pankso@7
|
236 # Log process.
|
pankso@7
|
237 echo "untaring $TARBALL" >> $LOG
|
pankso@7
|
238 echo -n "Untaring $TARBALL... "
|
pankso@7
|
239 if [ "`basename $TARBALL | grep tar.bz2`" ]; then
|
pankso@7
|
240 tar xjf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE
|
pankso@7
|
241 else
|
pankso@7
|
242 tar xzf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE
|
pankso@7
|
243 fi
|
pankso@7
|
244 status
|
pankso@7
|
245 else
|
pankso@7
|
246 echo -n "Source direcory exit... " && status
|
pankso@7
|
247 fi
|
pankso@7
|
248 fi
|
pankso@7
|
249 fi
|
pankso@7
|
250 cd $WOK/$PACKAGE
|
pankso@7
|
251 # Log and execute compile_rules function if it exist, to configure and
|
pankso@7
|
252 # make the package if it exist.
|
pankso@7
|
253 if [ `cat $RECEIPT | grep compile_rules` ]; then
|
pankso@7
|
254 echo "executing compile_rules" >> $LOG
|
pankso@7
|
255 compile_rules
|
pankso@7
|
256 # Exit if compilation failed so the binary package
|
pankso@7
|
257 # is not generated when using the cook comand.
|
pankso@7
|
258 local CHECK=$?
|
pankso@7
|
259 if [ $CHECK = 0 ]; then
|
pankso@7
|
260 echo "================================================================================"
|
pankso@7
|
261 echo "$PACKAGE compiled on : `date +%Y%m%d\ \%H:%M:%S`"
|
pankso@7
|
262 echo ""
|
pankso@7
|
263 echo "compilation done : `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
|
pankso@7
|
264 else
|
pankso@7
|
265 echo "================================================================================"
|
pankso@7
|
266 echo "Compilation failed. Please read the compilator output."
|
pankso@7
|
267 echo "" && exit 1
|
pankso@7
|
268 fi
|
pankso@7
|
269 else
|
pankso@7
|
270 echo "no compile_rules" >> $LOG
|
pankso@7
|
271 echo -e "No compile rules for $PACKAGE...\n"
|
pankso@7
|
272 fi
|
pankso@7
|
273 }
|
pankso@7
|
274
|
pankso@22
|
275 # Copy all generic files (locale, pixmaps, .desktop). We use standard path,
|
pankso@22
|
276 # so some packages need to copy these files with the receipt and genpkg_rules.
|
pankso@22
|
277 # This function is executed by gen_package when 'tazwok genpkg'.
|
pankso@22
|
278 copy_generic_files()
|
pankso@22
|
279 {
|
pankso@23
|
280 cd $WOK/$PACKAGE
|
pankso@22
|
281 # In most case locale are in $_pkg/usr/share/locale so we copy files
|
pankso@22
|
282 # using generic variables and $LOCALE from Tazwok config file.
|
pankso@22
|
283 if [ ! "$LOCALE" = "" ]; then
|
pankso@22
|
284 if [ -d "$_pkg/usr/share/locale" ]; then
|
pankso@22
|
285 mkdir -p $fs/usr/share/locale
|
pankso@22
|
286 for i in $LOCALE
|
pankso@22
|
287 do
|
pankso@22
|
288 cp -a $_pkg/usr/share/locale/$i \
|
pankso@22
|
289 $fs/usr/share/locale 2>/dev/null
|
pankso@22
|
290 done
|
pankso@22
|
291 fi
|
pankso@22
|
292 fi
|
pankso@22
|
293 # Pixmaps. Some icons/images can be add trough genpkg_rules and
|
pankso@22
|
294 # generic copy can be disable with GENERIC_PIXMAPS="no" in pkg receipt.
|
pankso@22
|
295 if [ ! "$GENERIC_PIXMAPS" = "no" ]; then
|
pankso@22
|
296 if [ -d "$_pkg/usr/share/pixmaps" ]; then
|
pankso@22
|
297 mkdir -p $fs/usr/share/pixmaps
|
pankso@22
|
298 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.* \
|
pankso@22
|
299 $fs/usr/share/pixmaps 2>/dev/null
|
pankso@23
|
300 fi
|
pankso@23
|
301 # Custom or home made PNG pixmap can be in stuff.
|
pankso@23
|
302 if [ -f "stuff/$PACKAGE.png" ]; then
|
pankso@23
|
303 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
|
pankso@22
|
304 fi
|
pankso@22
|
305 fi
|
pankso@22
|
306 # Desktop entry (.desktop).
|
pankso@22
|
307 if [ -d "$_pkg/usr/share/applications" ]; then
|
pankso@22
|
308 cp -a $_pkg/usr/share/applications $fs/usr/share
|
pankso@23
|
309 fi
|
pankso@23
|
310 # Home made desktop file can be in stuff.
|
pankso@23
|
311 if [ -f "stuff/$PACKAGE.desktop" ]; then
|
pankso@23
|
312 mkdir -p $fs/usr/share/applications
|
pankso@23
|
313 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
|
pankso@22
|
314 fi
|
pankso@22
|
315 }
|
pankso@22
|
316
|
pankso@7
|
317 # Creat a package tree and build the gziped cpio archive
|
pankso@7
|
318 # to make a SliTaz (.tazpkg) package.
|
pankso@7
|
319 gen_package()
|
pankso@7
|
320 {
|
pankso@7
|
321 check_root
|
pankso@7
|
322 check_for_package_on_cmdline
|
pankso@7
|
323 check_for_receipt
|
pankso@7
|
324 . $RECEIPT
|
pankso@7
|
325 check_for_wanted
|
pankso@7
|
326 cd $WOK/$PACKAGE
|
pankso@7
|
327 # Remove old Tazwok package files.
|
pankso@7
|
328 if [ -d "taz" ]; then
|
pankso@7
|
329 rm -rf taz
|
pankso@7
|
330 rm -f $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
|
pankso@7
|
331 fi
|
pankso@7
|
332 # Creat the package tree and set usful variables.
|
pankso@7
|
333 mkdir -p taz/$PACKAGE-$VERSION/fs
|
pankso@7
|
334 fs=taz/$PACKAGE-$VERSION/fs
|
pankso@7
|
335 # Set $src for standards package and $_pkg variables.
|
pankso@7
|
336 if [ "$WANTED" = "" ]; then
|
pankso@7
|
337 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
|
pankso@7
|
338 _pkg=$src/_pkg
|
pankso@7
|
339 fi
|
pankso@7
|
340 if [ ! "$SOURCE" = "" ]; then
|
pankso@7
|
341 src=$WOK/$PACKAGE/$SOURCE-$VERSION
|
pankso@7
|
342 _pkg=$src/_pkg
|
pankso@7
|
343 fi
|
pankso@7
|
344 cd $WOK/$PACKAGE
|
pankso@22
|
345 # Execute genpkg_rules and copy generic files to build the package.
|
pankso@7
|
346 echo ""
|
pankso@7
|
347 echo "Bulding $PACKAGE with the receipt..."
|
pankso@7
|
348 echo "================================================================================"
|
pankso@22
|
349 if [ `cat $RECEIPT | grep ^genpkg_rules` ]; then
|
pankso@7
|
350 # Log process.
|
pankso@7
|
351 echo "executing genpkg_rules" >> $LOG
|
pankso@7
|
352 genpkg_rules
|
pankso@22
|
353 copy_generic_files
|
pankso@7
|
354 else
|
pankso@7
|
355 echo "No package rules to gen $PACKAGE..."
|
pankso@22
|
356 exit 1
|
pankso@7
|
357 fi
|
pankso@22
|
358 # Copy the receipt and description (if exist) in the binary package tree.
|
pankso@7
|
359 cd $WOK/$PACKAGE
|
pankso@7
|
360 echo -n "Copying the receipt..."
|
pankso@7
|
361 cp receipt taz/$PACKAGE-$VERSION
|
pankso@7
|
362 status
|
pankso@7
|
363 if [ -f "description.txt" ]; then
|
pankso@7
|
364 echo -n "Copying the description file..."
|
pankso@7
|
365 cp description.txt taz/$PACKAGE-$VERSION
|
pankso@7
|
366 status
|
pankso@7
|
367 fi
|
pankso@7
|
368 # Creat the files.list by redirecting find outpout.
|
pankso@7
|
369 echo -n "Creating the list of files..."
|
pascal@15
|
370 cd taz/$PACKAGE-$VERSION
|
pascal@13
|
371 LAST_FILE=""
|
pascal@15
|
372 ( find fs -print; echo ) | while read file; do
|
pascal@13
|
373 if [ "$LAST_FILE" != "" ]; then
|
pascal@15
|
374 case "$file" in
|
pascal@13
|
375 $LAST_FILE/*)
|
pascal@15
|
376 case "$(ls -ld "$LAST_FILE")" in
|
pascal@15
|
377 drwxr-xr-x\ *\ root\ *\ root\ *);;
|
pascal@15
|
378 *) echo ${LAST_FILE#fs};;
|
pascal@13
|
379 esac;;
|
pascal@15
|
380 *) echo ${LAST_FILE#fs};;
|
pascal@13
|
381 esac
|
pascal@13
|
382 fi
|
pascal@15
|
383 LAST_FILE="$file"
|
pascal@15
|
384 done > files.list
|
pankso@7
|
385 status
|
pankso@7
|
386 # Build cpio archives. Find, cpio and gzip the fs, finish by
|
pankso@7
|
387 # removing the fs tree.
|
pankso@7
|
388 echo -n "Compressing the fs... "
|
pascal@13
|
389 find fs -print | cpio -o -H newc | gzip > fs.cpio.gz && rm -rf fs
|
pankso@7
|
390 echo -n "Creating full cpio archive... "
|
pankso@7
|
391 find . -print | cpio -o -H newc > $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
|
pankso@7
|
392 # Restore package tree in case we want to browse it.
|
pankso@7
|
393 echo -n "Restoring original package tree... "
|
pascal@14
|
394 zcat fs.cpio.gz | cpio -id
|
pascal@14
|
395 rm fs.cpio.gz && cd ..
|
pankso@7
|
396 # Log process.
|
pankso@7
|
397 echo "$PACKAGE-$VERSION.tazpkg (done)" >> $LOG
|
pankso@7
|
398 echo "================================================================================"
|
pankso@7
|
399 echo "Package $PACKAGE ($VERSION) generated."
|
pankso@7
|
400 echo "Size : `du -sh $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg`"
|
pankso@7
|
401 echo ""
|
pankso@7
|
402 }
|
pankso@7
|
403
|
pankso@7
|
404 ###################
|
pankso@7
|
405 # Tazwok commands #
|
pankso@7
|
406 ###################
|
pankso@7
|
407
|
pankso@7
|
408 case "$COMMAND" in
|
pankso@7
|
409 stats)
|
pankso@7
|
410 # Tazwok general statistics from the config file the wok.
|
pankso@7
|
411 #
|
pankso@7
|
412 echo ""
|
pankso@7
|
413 echo -e "\033[1mTazwok configuration statistics\033[0m
|
pankso@7
|
414 ================================================================================
|
pankso@7
|
415 Wok directory : $WOK
|
pankso@7
|
416 Packages repository : $PACKAGES_REPOSITORY
|
pankso@7
|
417 Sources repository : $SOURCES_REPOSITORY
|
pankso@7
|
418 Packages in the wok : `ls -1 $WOK | wc -l`
|
pankso@16
|
419 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
|
pankso@7
|
420 ================================================================================"
|
pankso@7
|
421 echo ""
|
pankso@7
|
422 ;;
|
pankso@7
|
423 list)
|
pankso@7
|
424 # List packages in wok directory. User can specifiy a category
|
pankso@7
|
425 #
|
pankso@7
|
426 if [ "$2" = "category" ]; then
|
pankso@7
|
427 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
|
pankso@7
|
428 exit 0
|
pankso@7
|
429 fi
|
pankso@7
|
430 # Check for an asked category.
|
pankso@7
|
431 if [ -n "$2" ]; then
|
pankso@7
|
432 ASKED_CATEGORY=$2
|
pankso@7
|
433 echo ""
|
pankso@7
|
434 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
|
pankso@7
|
435 echo "================================================================================"
|
pankso@7
|
436 for pkg in $WOK/*
|
pankso@7
|
437 do
|
pankso@7
|
438 . $pkg/receipt
|
pankso@7
|
439 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
|
pankso@7
|
440 echo -n "$PACKAGE"
|
pankso@7
|
441 echo -e "\033[24G $VERSION"
|
pankso@7
|
442 packages=$(($packages+1))
|
pankso@7
|
443 fi
|
pankso@7
|
444 done
|
pankso@7
|
445 echo "================================================================================"
|
pankso@7
|
446 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
|
pankso@7
|
447 else
|
pankso@7
|
448 # By default list all packages and version.
|
pankso@7
|
449 echo ""
|
pankso@7
|
450 echo -e "\033[1mList of packages in the wok\033[0m"
|
pankso@7
|
451 echo "================================================================================"
|
pankso@7
|
452 for pkg in $WOK/*
|
pankso@7
|
453 do
|
pankso@7
|
454 . $pkg/receipt
|
pankso@7
|
455 echo -n "$PACKAGE"
|
pankso@7
|
456 echo -en "\033[24G $VERSION"
|
pankso@7
|
457 echo -e "\033[42G $CATEGORY"
|
pankso@7
|
458 packages=$(($packages+1))
|
pankso@7
|
459 done
|
pankso@7
|
460 echo "================================================================================"
|
pankso@7
|
461 echo -e "$packages packages avalaible in the wok.\n"
|
pankso@7
|
462 fi
|
pankso@7
|
463 ;;
|
pankso@7
|
464 info)
|
pankso@7
|
465 # Informations about package.
|
pankso@7
|
466 #
|
pankso@7
|
467 check_for_package_on_cmdline
|
pankso@7
|
468 check_for_receipt
|
pankso@7
|
469 . $WOK/$PACKAGE/receipt
|
pankso@7
|
470 echo ""
|
pankso@7
|
471 echo -e "\033[1mTazwok package informations\033[0m
|
pankso@7
|
472 ================================================================================
|
pankso@7
|
473 Package : $PACKAGE
|
pankso@7
|
474 Version : $VERSION
|
pankso@7
|
475 Category : $CATEGORY
|
pankso@7
|
476 Short desc : $SHORT_DESC
|
pankso@7
|
477 Maintainer : $MAINTAINER"
|
pankso@7
|
478 if [ ! "$WEB_SITE" = "" ]; then
|
pankso@7
|
479 echo "Web site : $WEB_SITE"
|
pankso@7
|
480 fi
|
pankso@7
|
481 if [ ! "$DEPENDS" = "" ]; then
|
pankso@7
|
482 echo "Depends : $DEPENDS"
|
pankso@7
|
483 fi
|
pankso@7
|
484 if [ ! "$WANTED" = "" ]; then
|
pankso@7
|
485 echo "Wanted src : $WANTED"
|
pankso@7
|
486 fi
|
pankso@7
|
487 echo "================================================================================"
|
pankso@7
|
488 echo ""
|
pankso@7
|
489
|
pankso@7
|
490 ;;
|
pankso@7
|
491 check-log)
|
pankso@7
|
492 # We just cat the file log to view process info.
|
pankso@7
|
493 #
|
pankso@7
|
494 if [ ! -f "$LOG" ]; then
|
pankso@7
|
495 echo -e "\nNo process log found. The package is probably not cook.\n"
|
pankso@7
|
496 exit 0
|
pankso@7
|
497 else
|
pankso@7
|
498 echo ""
|
pankso@7
|
499 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
|
pankso@7
|
500 echo "================================================================================"
|
pankso@7
|
501 cat $LOG
|
pankso@7
|
502 echo "================================================================================"
|
pankso@7
|
503 echo ""
|
pankso@7
|
504 fi
|
pankso@7
|
505 ;;
|
pankso@7
|
506 search)
|
pankso@7
|
507 # Search for a package by pattern or name.
|
pankso@7
|
508 #
|
pankso@7
|
509 if [ -z "$2" ]; then
|
pankso@7
|
510 echo -e "\nPlease specify a pattern or a package name to search."
|
pankso@7
|
511 echo -e "Example : 'tazwok search gcc'.\n"
|
pankso@7
|
512 exit 0
|
pankso@7
|
513 fi
|
pankso@7
|
514 echo ""
|
pankso@7
|
515 echo -e "\033[1mSearch result for :\033[0m $2"
|
pankso@7
|
516 echo "================================================================================"
|
pankso@7
|
517 list=`ls -1 $WOK | grep $2`
|
pankso@7
|
518 for pkg in $list
|
pankso@7
|
519 do
|
pankso@7
|
520 . $WOK/$pkg/receipt
|
pankso@7
|
521 echo -n "$PACKAGE "
|
pankso@7
|
522 echo -en "\033[24G $VERSION"
|
pankso@7
|
523 echo -e "\033[42G $CATEGORY"
|
pankso@7
|
524 packages=$(($packages+1))
|
pankso@7
|
525 done
|
pankso@7
|
526 echo "================================================================================"
|
pankso@7
|
527 echo "$packages packages found for : $2"
|
pankso@7
|
528 echo ""
|
pankso@7
|
529 ;;
|
pankso@7
|
530 compile)
|
pankso@7
|
531 # Configure and make a package with the receipt.
|
pankso@7
|
532 #
|
pankso@7
|
533 compile_package
|
pankso@7
|
534 ;;
|
pankso@7
|
535 genpkg)
|
pankso@7
|
536 # Generate a package
|
pankso@7
|
537 #
|
pankso@7
|
538 gen_package
|
pankso@7
|
539 ;;
|
pankso@7
|
540 cook)
|
pankso@7
|
541 # Compile and generate a package. Just execute tazwok with
|
pankso@7
|
542 # the good commands.
|
pankso@7
|
543 #
|
pankso@7
|
544 check_root
|
pankso@7
|
545 compile_package
|
pankso@7
|
546 gen_package
|
pankso@7
|
547 ;;
|
pankso@7
|
548 cook-list)
|
pankso@7
|
549 # Cook all packages listed in a file. The path to the cooklist must
|
pankso@7
|
550 # be specified on the cmdline.
|
pankso@7
|
551 #
|
pankso@7
|
552 check_root
|
pankso@7
|
553 check_for_list
|
pankso@7
|
554 for pkg in $LIST
|
pankso@7
|
555 do
|
pankso@7
|
556 tazwok compile $pkg
|
pankso@7
|
557 tazwok genpkg $pkg
|
pankso@7
|
558 done
|
pankso@7
|
559 ;;
|
pankso@7
|
560 clean)
|
pankso@7
|
561 # Clean up a package work directory.
|
pankso@7
|
562 #
|
pankso@7
|
563 check_for_package_on_cmdline
|
pankso@7
|
564 check_for_receipt
|
pankso@7
|
565 . $RECEIPT
|
pankso@7
|
566 cd $WOK/$PACKAGE
|
pankso@7
|
567 echo ""
|
pankso@7
|
568 echo "Cleaning $PACKAGE..."
|
pankso@7
|
569 echo "================================================================================"
|
pankso@7
|
570 if [ -d "taz" ]; then
|
pankso@7
|
571 echo -n "Removing taz files..."
|
pankso@7
|
572 rm -rf taz && status
|
pankso@7
|
573 fi
|
pankso@7
|
574 # Remove source tree if exist.
|
pankso@7
|
575 if [ -d "$PACKAGE-$VERSION" ]; then
|
pankso@7
|
576 echo -n "Removing source files..."
|
pankso@7
|
577 rm -rf $PACKAGE-$VERSION && status
|
pankso@7
|
578 fi
|
pankso@7
|
579 if [ -d "$SOURCE-$VERSION" ]; then
|
pankso@7
|
580 echo -n "Removing source files..."
|
pankso@7
|
581 rm -rf $SOURCE-$VERSION && status
|
pankso@7
|
582 fi
|
pankso@7
|
583 # Remove an envental $PACKAGE-build directory.
|
pankso@7
|
584 if [ -d "$PACKAGE-build" ]; then
|
pankso@7
|
585 echo -n "Removing build tree..."
|
pankso@7
|
586 rm -rf $PACKAGE-build && status
|
pankso@7
|
587 fi
|
pankso@7
|
588 # Remove process log file.
|
pankso@7
|
589 if [ -f "process.log" ]; then
|
pankso@7
|
590 echo -n "Removing process log file..."
|
pankso@7
|
591 rm process.log && status
|
pankso@7
|
592 fi
|
pankso@7
|
593 echo "$PACKAGE is clean. You can cook it again..."
|
pankso@7
|
594 echo ""
|
pankso@7
|
595 ;;
|
pankso@7
|
596 gen-clean-wok)
|
pankso@7
|
597 # Generate a clean wok from the current wok by copying all receipt
|
pankso@7
|
598 # and stuff directory.
|
pankso@7
|
599 #
|
pankso@7
|
600 if [ -z "$2" ]; then
|
pankso@7
|
601 echo -e "\nPlease specify the destination for the new clean wok.\n"
|
pankso@7
|
602 exit 0
|
pankso@7
|
603 else
|
pankso@7
|
604 dest=$2
|
pankso@7
|
605 mkdir -p $dest
|
pankso@7
|
606 fi
|
pankso@7
|
607 echo "New wok is going to : $dest"
|
pankso@7
|
608 for pkg in `ls -1 $WOK`
|
pankso@7
|
609 do
|
pankso@7
|
610 echo "----"
|
pankso@7
|
611 echo -n "Preparing $pkg..."
|
pankso@7
|
612 mkdir -p $dest/$pkg
|
pankso@7
|
613 status
|
pankso@7
|
614 echo -n "Copying the receipt..."
|
pankso@7
|
615 cp -a $WOK/$pkg/receipt $dest/$pkg
|
pankso@7
|
616 status
|
pankso@7
|
617 if [ -d "$WOK/$pkg/stuff" ]; then
|
pankso@7
|
618 echo -n "Copying all the stuff directory..."
|
pankso@7
|
619 cp -a $WOK/$pkg/stuff $dest/$pkg
|
pankso@7
|
620 status
|
pankso@7
|
621 fi
|
pankso@7
|
622 done
|
pankso@7
|
623 echo "================================================================================"
|
pankso@7
|
624 echo "Clean wok generated in : $dest"
|
pankso@7
|
625 echo "Packages cleaned : `ls -1 $dest | wc -l`"
|
pankso@7
|
626 echo ""
|
pankso@7
|
627 ;;
|
pankso@7
|
628 clean-wok)
|
pankso@7
|
629 # Clean all packages in the work directory
|
pankso@7
|
630 #
|
pankso@7
|
631 for pkg in `ls -1 $WOK`
|
pankso@7
|
632 do
|
pankso@7
|
633 tazwok clean $pkg
|
pankso@7
|
634 done
|
pankso@7
|
635 echo "================================================================================"
|
pankso@7
|
636 echo "`ls -1 $WOK | wc -l` packages cleaned."
|
pankso@7
|
637 echo ""
|
pankso@7
|
638 ;;
|
pankso@7
|
639 gen-list)
|
pankso@7
|
640 # cd in the directory to creat a packages.list and the md5sum file.
|
pankso@7
|
641 # Sed is used to remove all the .tazpkg extensions from the
|
pankso@7
|
642 # packages.list. The directory to move in by default is the repository
|
pankso@7
|
643 # if $3 is not empty cd into $3.
|
pankso@7
|
644 #
|
pankso@7
|
645 if [ -z "$2" ]; then
|
pankso@7
|
646 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
|
pankso@7
|
647 else
|
pankso@7
|
648 if [ -d "$2" ]; then
|
pankso@7
|
649 PACKAGES_REPOSITORY=$2
|
pankso@7
|
650 else
|
pankso@7
|
651 echo -e "\nUnable to find directory : $2\n"
|
pankso@7
|
652 exit 0
|
pankso@7
|
653 fi
|
pankso@7
|
654 fi
|
pankso@7
|
655 cd $PACKAGES_REPOSITORY
|
pankso@7
|
656 # Remove old packages.list and md5sum, it well be soon rebuild.
|
pankso@7
|
657 rm -f packages.list packages.md5
|
pankso@7
|
658 echo ""
|
pankso@7
|
659 echo "Repository path : $PACKAGES_REPOSITORY"
|
pankso@7
|
660 echo -n "Creating the packages list... "
|
pankso@17
|
661 ls -1 *.tazpkg > /tmp/packages.list
|
pankso@7
|
662 sed -i s/'.tazpkg'/''/ /tmp/packages.list
|
pankso@7
|
663 status
|
pankso@7
|
664 echo -n "Building the md5sum for all packages... "
|
pankso@7
|
665 md5sum * > packages.md5
|
pankso@7
|
666 status
|
pankso@7
|
667 mv /tmp/packages.list $PACKAGES_REPOSITORY
|
pankso@7
|
668 echo "================================================================================"
|
pankso@7
|
669 pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
|
pankso@7
|
670 echo "$pkgs packages in the repository."
|
pankso@7
|
671 echo ""
|
pankso@7
|
672 ;;
|
pankso@7
|
673 new-tree)
|
pankso@7
|
674 # Just creat a few directories and gen a empty receipt to prepare
|
pankso@7
|
675 # the creation of a new package.
|
pankso@7
|
676 #
|
pankso@7
|
677 check_for_package_on_cmdline
|
pankso@7
|
678 if [ -d $WOK/$PACKAGE ]; then
|
pankso@7
|
679 echo -e "\n$PACKAGE package tree already exist.\n"
|
pankso@7
|
680 exit 0
|
pankso@7
|
681 fi
|
pankso@7
|
682 echo "Creating : $WOK/$PACKAGE"
|
pankso@7
|
683 mkdir $WOK/$PACKAGE
|
pankso@7
|
684 cd $WOK/$PACKAGE
|
pankso@7
|
685 echo -n "Preparing the receipt..."
|
pankso@7
|
686 #
|
pankso@7
|
687 # Default receipt begin.
|
pankso@7
|
688 #
|
pankso@7
|
689 echo "# SliTaz package receipt." > receipt
|
pankso@7
|
690 echo "" >> receipt
|
pankso@7
|
691 echo "PACKAGE=\"$PACKAGE\"" >> receipt
|
pankso@7
|
692 # Finish the empty receipt.
|
pankso@7
|
693 cat >> receipt << "EOF"
|
pankso@7
|
694 VERSION=""
|
pankso@7
|
695 CATEGORY=""
|
pankso@7
|
696 SHORT_DESC=""
|
pankso@7
|
697 MAINTAINER=""
|
pankso@7
|
698 DEPENDS=""
|
pankso@7
|
699 TARBALL="$PACKAGE-$VERSION.tar.gz"
|
pankso@7
|
700 WEB_SITE=""
|
pankso@7
|
701 WGET_URL=""
|
pankso@7
|
702
|
pankso@7
|
703 # Rules to configure and make the package.
|
pankso@7
|
704 compile_rules()
|
pankso@7
|
705 {
|
pankso@7
|
706 cd $src
|
pankso@7
|
707 ./configure --prefix=/usr --infodir=/usr/share/info \
|
pankso@7
|
708 --mandir=/usr/share/man $CONFIGURE_ARGS
|
pankso@7
|
709 make
|
pankso@7
|
710 make DESTDIR=$PWD/_pkg install
|
pankso@7
|
711 }
|
pankso@7
|
712
|
pankso@7
|
713 # Rules to gen a SliTaz package suitable for Tazpkg.
|
pankso@7
|
714 genpkg_rules()
|
pankso@7
|
715 {
|
pankso@7
|
716 mkdir -p $fs/usr
|
pankso@7
|
717 cp -a $_pkg/usr/bin $fs/usr
|
pankso@7
|
718 strip -s $fs/usr/bin/*
|
pankso@7
|
719 }
|
pankso@7
|
720
|
pankso@7
|
721 EOF
|
pankso@7
|
722 #
|
pankso@7
|
723 # Default receipt end.
|
pankso@7
|
724 #
|
pankso@7
|
725 status
|
pankso@7
|
726 # Interactive mode, asking and seding.
|
pankso@7
|
727 if [ "$3" = "--interactive" ]; then
|
pankso@7
|
728 echo "Entering in interactive mode..."
|
pankso@7
|
729 echo "================================================================================"
|
pankso@7
|
730 echo "Package : $PACKAGE"
|
pankso@7
|
731 # Version.
|
pankso@7
|
732 echo -n "Version : " ; read anser
|
pankso@7
|
733 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
|
pankso@7
|
734 # Category.
|
pankso@7
|
735 echo -n "Category : " ; read anser
|
pankso@7
|
736 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
|
pankso@7
|
737 # Short description.
|
pankso@7
|
738 echo -n "Short desc : " ; read anser
|
pankso@7
|
739 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
|
pankso@7
|
740 # Maintainer.
|
pankso@7
|
741 echo -n "Maintainer : " ; read anser
|
pankso@7
|
742 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
|
pankso@7
|
743 # Web site.
|
pankso@7
|
744 echo -n "Web site : " ; read anser
|
pankso@7
|
745 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
|
pankso@7
|
746 echo ""
|
pankso@7
|
747 # Wget URL.
|
pankso@7
|
748 echo "Wget URL to download source tarball."
|
pankso@7
|
749 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
|
pankso@7
|
750 echo -n "Wget url : " ; read anser
|
pankso@7
|
751 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
|
pankso@7
|
752 # Ask for a stuff dir.
|
pankso@7
|
753 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
|
pankso@7
|
754 if [ "$anser" = "y" ]; then
|
pankso@7
|
755 echo -n "Creating the stuff directory..."
|
pankso@7
|
756 mkdir stuff && status
|
pankso@7
|
757 fi
|
pankso@7
|
758 # Ask for a description file.
|
pankso@7
|
759 echo -n "Are you going to write a description ? (y/N) : " ; read anser
|
pankso@7
|
760 if [ "$anser" = "y" ]; then
|
pankso@7
|
761 echo -n "Creating the description.txt file..."
|
pankso@7
|
762 echo "" > description.txt && status
|
pankso@7
|
763 fi
|
pankso@7
|
764 echo "================================================================================"
|
pankso@7
|
765 echo ""
|
pankso@7
|
766 fi
|
pankso@7
|
767 ;;
|
pankso@7
|
768 remove)
|
pankso@7
|
769 # Remove a package from the wok.
|
pankso@7
|
770 #
|
pankso@7
|
771 check_for_package_on_cmdline
|
pankso@7
|
772 echo ""
|
pankso@7
|
773 echo -n "Removing $PACKAGE..."
|
pankso@7
|
774 rm -rf $WOK/$PACKAGE && status
|
pankso@7
|
775 echo ""
|
pankso@7
|
776 ;;
|
pankso@7
|
777 usage|*)
|
pankso@7
|
778 # Print usage also for all unknow commands.
|
pankso@7
|
779 #
|
pankso@7
|
780 usage
|
pankso@7
|
781 ;;
|
pankso@7
|
782 esac
|
pankso@7
|
783
|
pankso@7
|
784 exit 0
|