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@106
|
9 # (C) 2007-2009 SliTaz - GNU General Public License.
|
pankso@7
|
10 #
|
pankso@7
|
11
|
gokhlayeh@186
|
12 VERSION=3.9.0
|
gokhlayeh@186
|
13 . /usr/lib/slitaz/libtaz
|
gokhlayeh@186
|
14 source_lib commons
|
pankso@7
|
15
|
gokhlayeh@186
|
16 # Use text instead of numbers, don't get $2 here if it's an option.
|
gokhlayeh@186
|
17 [ "$2" = "${2#--}" ] && PACKAGE=$2 && LIST=$2 && ARG=$2
|
gokhlayeh@186
|
18 COMMAND=$1
|
pankso@7
|
19
|
gokhlayeh@186
|
20 ########################################################################
|
gokhlayeh@186
|
21 # TAZWOK USAGE
|
gokhlayeh@186
|
22 ########################
|
gokhlayeh@186
|
23 # Print the usage (English).
|
pankso@7
|
24
|
gokhlayeh@237
|
25 usage()
|
pankso@7
|
26 {
|
pankso@7
|
27 echo -e "\nSliTaz sources compiler and packages generator - Version: $VERSION\n
|
pankso@107
|
28 \033[1mUsage: \033[0m `basename $0` [command] [package|list|category|dir|id] [--option]
|
pankso@7
|
29 \033[1mCommands: \033[0m\n
|
pankso@7
|
30 usage Print this short usage.
|
pankso@7
|
31 stats Print Tazwok statistics from the config file and the wok.
|
pankso@133
|
32 edit Edit a package receipt in the current wok.
|
paul@121
|
33 build-depends Generate a list of packages to build a wok.
|
pankso@7
|
34 list List all packages in the wok tree or by category.
|
MikeDSmith25@82
|
35 info Get information about a package in the wok.
|
pascal@92
|
36 check Check every receipt for common errors.
|
pankso@7
|
37 check-log Check the process log file of a package.
|
gokhlayeh@186
|
38 check-depends* Check every receipt for DEPENDS - doesn't scan ELF files.
|
erjo@159
|
39 check-src Check upstream tarball for package in the wok.
|
pankso@7
|
40 search Search for a package in the wok by pattern or name.
|
MikeDSmith25@82
|
41 compile Configure and build a package using the receipt rules.
|
pankso@7
|
42 genpkg Generate a suitable package for Tazpkg with the rules.
|
pankso@7
|
43 cook Compile and generate a package directly.
|
pankso@7
|
44 cook-list Cook all packages specified in the list by order.
|
gokhlayeh@186
|
45 cook-commit Cook all modified receipts.
|
gokhlayeh@186
|
46 cook-all Cook all packages excepted toolchain.
|
gokhlayeh@186
|
47 cook-toolchain Cook the toolchain packages.
|
gokhlayeh@240
|
48 gen-cooklist Generate a sorted cooklist using packages or list.
|
gokhlayeh@186
|
49 sort-cooklist Sort the cooklist given in argument.
|
gokhlayeh@186
|
50 get-src Download the tarball of the package given in argument.
|
pankso@7
|
51 clean Clean all generated files in the package tree.
|
pankso@7
|
52 new-tree Prepare a new package tree and receipt (--interactive).
|
gokhlayeh@186
|
53 gen-list (Re-)Generate a packages list for a repository.
|
gokhlayeh@240
|
54 check-list Update packages lists for a repository.
|
gokhlayeh@186
|
55 gen-wok-db (Re-)Generate wok lists with depends and wanted datas.
|
gokhlayeh@240
|
56 gen-clean-wok Generate a clean wok in a dir.
|
gokhlayeh@186
|
57 clean-wok Clean entirely the wok.
|
gokhlayeh@266
|
58 clean-src Remove old/unrelated-to-wok sources.
|
pankso@107
|
59 remove Remove a package from the wok.
|
gokhlayeh@240
|
60 webserver Enable/disable webserver on localhost.
|
pankso@108
|
61 hgup Pull and update a wok under Hg.
|
pankso@108
|
62 maintainers List all maintainers in the wok.
|
gokhlayeh@186
|
63 maintained-by List packages maintained by a contributor.\n
|
gokhlayeh@186
|
64
|
gokhlayeh@186
|
65 You can use `basename $0` command --help to list avaible options.
|
gokhlayeh@186
|
66 \033[1mImportant - *: \033[0m Commands which need a rewrite."
|
pankso@7
|
67 }
|
pankso@7
|
68
|
gokhlayeh@186
|
69 # This function display an error message without returning any error code.
|
gokhlayeh@186
|
70 # It also log the message in source package's warnings.txt; this file can be
|
gokhlayeh@186
|
71 # used on an eventual package page on website to display cooking warnings.
|
gokhlayeh@186
|
72 tazwok_warning()
|
pankso@7
|
73 {
|
gokhlayeh@186
|
74 echo -e "tazwok: $1" >&2
|
gokhlayeh@186
|
75 echo -e "$1" >> $WOK/${WANTED:-$PACKAGE}/warning.txt
|
gokhlayeh@186
|
76 return
|
pankso@7
|
77 }
|
pankso@7
|
78
|
gokhlayeh@186
|
79 ########################################################################
|
gokhlayeh@186
|
80 # TAZWOK VARIABLES & INITIAL CONFIGURATION
|
gokhlayeh@186
|
81 ########################
|
gokhlayeh@186
|
82
|
gokhlayeh@186
|
83 get_tazwok_config()
|
pankso@7
|
84 {
|
gokhlayeh@186
|
85 # Get configuration file.
|
gokhlayeh@186
|
86 get_config
|
gokhlayeh@186
|
87
|
gokhlayeh@186
|
88 # Define & get options.
|
gokhlayeh@186
|
89 get_options_list="$get_options_list SLITAZ_DIR SLITAZ_VERSION undigest"
|
gokhlayeh@186
|
90 get_options
|
gokhlayeh@186
|
91
|
gokhlayeh@186
|
92 if [ "$undigest" ]; then
|
gokhlayeh@186
|
93 LOCAL_REPOSITORY=$SLITAZ_DIR/$undigest
|
gokhlayeh@186
|
94 else
|
gokhlayeh@186
|
95 LOCAL_REPOSITORY=$SLITAZ_DIR/$SLITAZ_VERSION
|
pankso@7
|
96 fi
|
gokhlayeh@235
|
97
|
gokhlayeh@235
|
98 if ! [ "$save_dir" ]; then
|
gokhlayeh@235
|
99 if [ -f $LOCAL_REPOSITORY/tazwok.conf ] || [ -f $LOCAL_REPOSITORY/slitaz.conf ]; then
|
gokhlayeh@235
|
100 save_dir=$LOCAL_REPOSITORY
|
gokhlayeh@235
|
101 [ -f $LOCAL_REPOSITORY/slitaz.conf ] && source $LOCAL_REPOSITORY/slitaz.conf
|
gokhlayeh@235
|
102 cd $save_dir
|
gokhlayeh@235
|
103 get_tazwok_config
|
gokhlayeh@235
|
104 unset save_dir
|
gokhlayeh@235
|
105 return
|
gokhlayeh@235
|
106 fi
|
gokhlayeh@235
|
107 fi
|
gokhlayeh@235
|
108
|
gokhlayeh@186
|
109 # The path to the most important files/dir used by Tazwok.
|
gokhlayeh@186
|
110 PACKAGES_REPOSITORY=$LOCAL_REPOSITORY/packages
|
gokhlayeh@186
|
111 WOK=$LOCAL_REPOSITORY/wok
|
gokhlayeh@186
|
112 INCOMING_REPOSITORY=$LOCAL_REPOSITORY/packages-incoming
|
gokhlayeh@186
|
113 SOURCES_REPOSITORY=$LOCAL_REPOSITORY/src
|
gokhlayeh@186
|
114 set_common_path
|
gokhlayeh@186
|
115
|
gokhlayeh@186
|
116 # /!\ This part needs some changes.
|
gokhlayeh@186
|
117 # Basically, get theses files from the net if they are missing.
|
gokhlayeh@186
|
118 dep_db=$INCOMING_REPOSITORY/wok-depends.txt
|
gokhlayeh@186
|
119 wan_db=$INCOMING_REPOSITORY/wok-wanted.txt
|
gokhlayeh@215
|
120 [ -f $dep_db ] || touch $dep_db
|
gokhlayeh@215
|
121 [ -f $wan_db ] || touch $wan_db
|
gokhlayeh@215
|
122 [ -f $PACKAGES_REPOSITORY/cookorder.txt ] || touch $PACKAGES_REPOSITORY/cookorder.txt
|
gokhlayeh@186
|
123
|
gokhlayeh@186
|
124 # Check commons directories, create them if user is root.
|
gokhlayeh@186
|
125 if test $(id -u) = 0 ; then
|
gokhlayeh@186
|
126 check_dir $WOK || chmod 777 $WOK
|
gokhlayeh@186
|
127 check_dir $PACKAGES_REPOSITORY
|
gokhlayeh@186
|
128 check_dir $SOURCES_REPOSITORY
|
gokhlayeh@186
|
129 check_dir $INCOMING_REPOSITORY
|
gokhlayeh@186
|
130 check_dir $LOCAL_REPOSITORY/log
|
gokhlayeh@186
|
131 fi
|
gokhlayeh@235
|
132
|
gokhlayeh@186
|
133 # Some files are needed by tazwok in PACKAGES_REPOSITORY. Create
|
gokhlayeh@186
|
134 # them if they are missing.
|
gokhlayeh@204
|
135 for file in broken blocked commit incoming cooklist; do
|
gokhlayeh@186
|
136 [ ! -f $PACKAGES_REPOSITORY/$file ] && touch $PACKAGES_REPOSITORY/$file
|
gokhlayeh@186
|
137 done
|
gokhlayeh@266
|
138 touch $SOURCES_REPOSITORY/sources.list
|
gokhlayeh@186
|
139
|
gokhlayeh@186
|
140 # Limit memory usage.
|
gokhlayeh@186
|
141 ulimit -v $(awk '/MemTotal/ { print int(($2*80)/100) }' < /proc/meminfo)
|
pankso@7
|
142 }
|
pankso@7
|
143
|
gokhlayeh@186
|
144 # Used in several functions.
|
gokhlayeh@186
|
145 set_common_path()
|
gokhlayeh@186
|
146 {
|
gokhlayeh@186
|
147 # The receipt is used to compile the source code and
|
gokhlayeh@186
|
148 # generate suitable packages for Tazpkg.
|
gokhlayeh@186
|
149 RECEIPT="$WOK/$PACKAGE/receipt"
|
gokhlayeh@186
|
150
|
gokhlayeh@186
|
151 # The path to the process log file.
|
gokhlayeh@186
|
152 LOG="$WOK/$PACKAGE/process.log"
|
gokhlayeh@186
|
153 }
|
gokhlayeh@186
|
154
|
gokhlayeh@186
|
155 ########################################################################
|
gokhlayeh@186
|
156 # TAZWOK CHECK FUNCTIONS
|
gokhlayeh@186
|
157 ########################
|
gokhlayeh@186
|
158
|
pankso@7
|
159 # Check for a package name on cmdline.
|
pankso@7
|
160 check_for_package_on_cmdline()
|
pankso@7
|
161 {
|
gokhlayeh@186
|
162 if [ ! "$PACKAGE" ]; then
|
gokhlayeh@186
|
163 echo -e "\nYou must specify a package name on the command line." >&2
|
gokhlayeh@186
|
164 echo -e "Example : tazwok $COMMAND package\n" >&2
|
gokhlayeh@186
|
165 exit 1
|
pankso@7
|
166 fi
|
pankso@7
|
167 }
|
pankso@7
|
168
|
pankso@7
|
169 # Check for the receipt of a package used to cook.
|
pankso@7
|
170 check_for_receipt()
|
pankso@7
|
171 {
|
pankso@7
|
172 if [ ! -f "$RECEIPT" ]; then
|
gokhlayeh@186
|
173 echo -e "\nUnable to find the receipt : $RECEIPT\n" >&2
|
gokhlayeh@186
|
174 exit 1
|
pankso@7
|
175 fi
|
pankso@7
|
176 }
|
pankso@7
|
177
|
pankso@7
|
178 # Check for a specified file list on cmdline.
|
pankso@7
|
179 check_for_list()
|
pankso@7
|
180 {
|
gokhlayeh@186
|
181 if [ ! "$LIST" ]; then
|
gokhlayeh@186
|
182 echo -e "\nPlease specify the path to the list of packages to cook.\n" >&2
|
gokhlayeh@186
|
183 exit 1
|
pankso@7
|
184 fi
|
gokhlayeh@186
|
185
|
MikeDSmith25@82
|
186 # Check if the list of packages exists.
|
pankso@7
|
187 if [ -f "$LIST" ]; then
|
pankso@7
|
188 LIST=`cat $LIST`
|
pankso@7
|
189 else
|
gokhlayeh@186
|
190 echo -e "\nUnable to find $LIST packages list.\n" >&2
|
gokhlayeh@186
|
191 exit 1
|
pankso@7
|
192 fi
|
gokhlayeh@186
|
193
|
gokhlayeh@186
|
194 if [ ! "$LIST" ]; then
|
gokhlayeh@186
|
195 echo -e "\nList is empty.\n" >&2
|
gokhlayeh@186
|
196 exit 1
|
gokhlayeh@186
|
197 fi
|
gokhlayeh@186
|
198 }
|
gokhlayeh@186
|
199
|
gokhlayeh@204
|
200 check_for_pkg_in_wok()
|
gokhlayeh@204
|
201 {
|
gokhlayeh@204
|
202 [ -f $WOK/$PACKAGE/receipt ] && return
|
gokhlayeh@204
|
203 if [ "$undigest" ]; then
|
gokhlayeh@204
|
204 [ -f "$SLITAZ_VERSION/wok/$PACKAGE/receipt" ] && return 1
|
gokhlayeh@240
|
205 grep -q ^$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/packages.txt && return 1
|
gokhlayeh@204
|
206 fi
|
gokhlayeh@204
|
207 echo "Can't find $PACKAGE in wok or mirror" >&2
|
gokhlayeh@204
|
208 return 2
|
gokhlayeh@204
|
209 }
|
gokhlayeh@186
|
210
|
gokhlayeh@186
|
211 ########################################################################
|
gokhlayeh@186
|
212 # TAZWOK CORE FUNCTIONS
|
gokhlayeh@186
|
213 ########################
|
gokhlayeh@186
|
214
|
gokhlayeh@186
|
215 remove_src()
|
gokhlayeh@186
|
216 {
|
gokhlayeh@204
|
217 [ "$WANTED" ] && return
|
gokhlayeh@186
|
218 look_for_cookopt !remove_src && return
|
gokhlayeh@215
|
219 if [ ! -d $WOK/$PACKAGE/install ] && [ "$src" ] && [ -d "$src/_pkg" ]; then
|
gokhlayeh@186
|
220 check_for_var_modification _pkg src || return
|
gokhlayeh@215
|
221 mv "$src/_pkg" $WOK/$PACKAGE/install
|
gokhlayeh@186
|
222 fi
|
gokhlayeh@186
|
223
|
gokhlayeh@186
|
224 # Don't remove sources if a package use src variable in his
|
gokhlayeh@186
|
225 # genpkg_rules: it maybe need something inside.
|
gokhlayeh@186
|
226 for i in $PACKAGE $(look_for_rwanted); do
|
gokhlayeh@186
|
227 sed -n '/^genpkg_rules\(\)/','/}/'p $WOK/$i/receipt | \
|
gokhlayeh@195
|
228 fgrep -q '$src' && tazwok_warning "Sources will not be removed \
|
gokhlayeh@186
|
229 because $i use \$src in his receipt." && return
|
gokhlayeh@186
|
230 done
|
gokhlayeh@186
|
231
|
gokhlayeh@186
|
232 report step "Removing sources directory"
|
gokhlayeh@186
|
233 rm -fr "$src"
|
gokhlayeh@186
|
234 report end-step
|
gokhlayeh@186
|
235 }
|
gokhlayeh@186
|
236
|
gokhlayeh@186
|
237 # Check $COOK_OPT; usage : get_cookopt particular_opt
|
gokhlayeh@186
|
238 # Return error if not founded
|
gokhlayeh@186
|
239 # Return args if the opt is in the format opt=arg1:arg2:etc
|
gokhlayeh@186
|
240 look_for_cookopt()
|
gokhlayeh@186
|
241 {
|
gokhlayeh@186
|
242 for arg in $COOK_OPT; do
|
gokhlayeh@186
|
243 case $arg in
|
gokhlayeh@186
|
244 $1=*)
|
gokhlayeh@186
|
245 arg=${arg#$1=}
|
gokhlayeh@186
|
246 while [ "$arg" ]; do
|
gokhlayeh@186
|
247 echo "${arg%%:*}"
|
gokhlayeh@186
|
248 [ "${arg/:}" = "$arg" ] && return
|
gokhlayeh@186
|
249 arg=${arg#*:}
|
gokhlayeh@186
|
250 done
|
gokhlayeh@186
|
251 ;;
|
gokhlayeh@186
|
252 $1)
|
gokhlayeh@186
|
253 return
|
gokhlayeh@186
|
254 ;;
|
gokhlayeh@186
|
255 esac
|
gokhlayeh@186
|
256 done
|
gokhlayeh@186
|
257 return 1
|
pankso@7
|
258 }
|
pankso@7
|
259
|
pankso@7
|
260 # Check for the wanted package if specified in WANTED
|
paul@166
|
261 # receipt variable. Set the $src/$_pkg variable to help compile
|
paul@166
|
262 # and generate packages.
|
pankso@7
|
263 check_for_wanted()
|
pankso@7
|
264 {
|
gokhlayeh@186
|
265 if [ "$WANTED" ]; then
|
gokhlayeh@186
|
266 report "Checking for the wanted package"
|
pankso@7
|
267 if [ ! -d "$WOK/$WANTED" ]; then
|
gokhlayeh@186
|
268 report exit "\nWanted package is missing in the work directory.\n"
|
pankso@7
|
269 fi
|
gokhlayeh@186
|
270
|
erjo@38
|
271 # Checking for buildtree of Wanted package
|
pankso@39
|
272 if [ ! -d "$WOK/$WANTED/taz" ]; then
|
erjo@38
|
273 echo -e "\n\nSource files of wanted package is missing in the work directory."
|
erjo@38
|
274 echo -n "Would you like to build the missing package (y/N) ? " ; read anser
|
erjo@38
|
275 if [ "$anser" == "y" ]; then
|
erjo@38
|
276 tazwok cook $WANTED
|
erjo@38
|
277 else
|
gokhlayeh@186
|
278 report exit "\nWanted package source tree is missing in the work directory.\n"
|
erjo@38
|
279 fi
|
erjo@38
|
280 fi
|
gokhlayeh@186
|
281 report end-step
|
gokhlayeh@186
|
282
|
pankso@7
|
283 # Set wanted src path.
|
gokhlayeh@186
|
284 set_src_path && set_pkg_path
|
gokhlayeh@186
|
285
|
pankso@7
|
286 fi
|
pankso@7
|
287 }
|
pankso@7
|
288
|
pankso@40
|
289 # Check for build dependencies, notify user and install if specified.
|
pankso@18
|
290 check_for_build_depends()
|
pankso@18
|
291 {
|
gokhlayeh@204
|
292 [ "$WANTED" ] && return
|
gokhlayeh@213
|
293 [ "$CATEGORY" = meta ] && ! fgrep -q compile_rules $RECEIPT && return
|
gokhlayeh@186
|
294 report step "Looking for build dependencies"
|
gokhlayeh@186
|
295
|
gokhlayeh@186
|
296 # Keep the list of previously installed build_depends then compare
|
gokhlayeh@186
|
297 # it with new build_depends to know what to install and what to
|
gokhlayeh@186
|
298 # what to remove.
|
gokhlayeh@186
|
299 plan_remove=" $MISSING_PACKAGE $remove_later "
|
gokhlayeh@186
|
300 [ ! "${plan_remove// }" ] && unset plan_remove
|
gokhlayeh@186
|
301 unset MISSING_PACKAGE remove_later
|
gokhlayeh@186
|
302 rwanted=$(look_for_rwanted)
|
gokhlayeh@186
|
303
|
gokhlayeh@215
|
304 for pkg in $(scan $PACKAGE --look_for=bdep --with_dev | \
|
gokhlayeh@204
|
305 fgrep -v $(for i in $(look_for_rwanted) $PACKAGE; do echo " -e $i"; done))
|
pankso@18
|
306 do
|
gokhlayeh@186
|
307
|
gokhlayeh@186
|
308 # Delay the removing of previous cook depends if they are needed
|
gokhlayeh@186
|
309 # for next cook too.
|
gokhlayeh@186
|
310 if [ ! -d "$INSTALLED/$pkg" ] ; then
|
gokhlayeh@186
|
311 MISSING_PACKAGE="$MISSING_PACKAGE $pkg"
|
gokhlayeh@186
|
312 fi
|
gokhlayeh@186
|
313 if [ "$plan_remove" != "${plan_remove/ $pkg }" ]; then
|
gokhlayeh@186
|
314 plan_remove="${plan_remove/ $pkg / }"
|
gokhlayeh@186
|
315 remove_later="$remove_later $pkg"
|
gokhlayeh@186
|
316 fi
|
gokhlayeh@186
|
317 if grep -q ^$pkg$ $PACKAGES_REPOSITORY/broken; then
|
gokhlayeh@186
|
318 broken="$broken$pkg "
|
pankso@18
|
319 fi
|
pankso@18
|
320 done
|
gokhlayeh@186
|
321
|
gokhlayeh@186
|
322 # Don't cook if a depend is broken.
|
gokhlayeh@186
|
323 if [ "$broken" ]; then
|
gokhlayeh@186
|
324 MISSING_PACKAGE=$plan_remove
|
gokhlayeh@186
|
325 echo "Can't cook $PACKAGE because broken depend(s) : $broken" >&2
|
gokhlayeh@186
|
326 unset plan_remove broken
|
gokhlayeh@186
|
327
|
gokhlayeh@186
|
328 # Set report step to failed.
|
gokhlayeh@186
|
329 report_return_code=1
|
gokhlayeh@186
|
330 report end-step
|
gokhlayeh@186
|
331 return 1
|
gokhlayeh@186
|
332 fi
|
gokhlayeh@186
|
333 if [ "$MISSING_PACKAGE" ]; then
|
gokhlayeh@186
|
334 install_missing()
|
gokhlayeh@186
|
335 {
|
gokhlayeh@186
|
336 echo "Installing missing packages : $MISSING_PACKAGE"
|
gokhlayeh@186
|
337 for pkg in $MISSING_PACKAGE; do
|
gokhlayeh@186
|
338 [ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
|
gokhlayeh@186
|
339 done
|
gokhlayeh@186
|
340 }
|
gokhlayeh@186
|
341 if [ "$auto_install" = yes ]; then
|
gokhlayeh@186
|
342 install_missing
|
gokhlayeh@186
|
343 else
|
gokhlayeh@186
|
344 echo "================================================================================"
|
gokhlayeh@186
|
345 for pkg in $MISSING_PACKAGE
|
gokhlayeh@186
|
346 do
|
pankso@18
|
347 echo "Missing : $pkg"
|
gokhlayeh@186
|
348 done
|
gokhlayeh@186
|
349 echo "================================================================================"
|
gokhlayeh@186
|
350 echo "You can continue, exit or install missing dependencies."
|
gokhlayeh@186
|
351 echo -n "Install, continue or exit (install/y/N) ? "; read answer
|
gokhlayeh@186
|
352 case $answer in
|
gokhlayeh@186
|
353 install)
|
gokhlayeh@186
|
354 install_missing ;;
|
gokhlayeh@186
|
355 y|yes)
|
gokhlayeh@186
|
356 unset MISSING_PACKAGE;;
|
gokhlayeh@186
|
357 *)
|
gokhlayeh@186
|
358 report stop
|
gokhlayeh@186
|
359 exit 0 ;;
|
gokhlayeh@186
|
360 esac
|
gokhlayeh@186
|
361 fi
|
gokhlayeh@186
|
362 fi
|
gokhlayeh@186
|
363 report end-step
|
gokhlayeh@186
|
364 remove_build_depends $plan_remove
|
gokhlayeh@186
|
365 unset plan_remove
|
gokhlayeh@186
|
366 }
|
gokhlayeh@186
|
367
|
gokhlayeh@186
|
368 remove_build_depends()
|
gokhlayeh@186
|
369 {
|
gokhlayeh@186
|
370 [ "$1" ] || return
|
gokhlayeh@186
|
371 report step "Removing previous build dependencies"
|
gokhlayeh@186
|
372 echo "Removing theses packages : $@"
|
gokhlayeh@186
|
373 for pkg in $@; do
|
gokhlayeh@223
|
374 [ -d "$INSTALLED/$pkg" ] && tazpkg remove $pkg --auto
|
gokhlayeh@186
|
375 done
|
gokhlayeh@186
|
376 report end-step
|
gokhlayeh@186
|
377 }
|
gokhlayeh@186
|
378
|
gokhlayeh@186
|
379 # Check if we can use the new way to handle tarball
|
gokhlayeh@186
|
380 # or if we keep the previous method by check for
|
gokhlayeh@186
|
381 # _pkg=/src= in receipt and reverse-wanted.
|
gokhlayeh@186
|
382 check_for_var_modification()
|
gokhlayeh@186
|
383 {
|
gokhlayeh@186
|
384 for var in $@; do
|
gokhlayeh@186
|
385 for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do
|
gokhlayeh@186
|
386 [ -f $WOK/$pkg/receipt ] || continue
|
gokhlayeh@195
|
387 fgrep -q "$var=" $WOK/$pkg/receipt && return 1
|
pankso@18
|
388 done
|
gokhlayeh@186
|
389 done
|
gokhlayeh@186
|
390
|
gokhlayeh@186
|
391 # Tweak to make if; then...; fi function working with this one.
|
gokhlayeh@186
|
392 echo -n ""
|
gokhlayeh@186
|
393 }
|
gokhlayeh@186
|
394
|
gokhlayeh@186
|
395 set_src_path()
|
gokhlayeh@186
|
396 {
|
gokhlayeh@186
|
397 if check_for_var_modification src _pkg; then
|
gokhlayeh@186
|
398 src=$WOK/${WANTED:-$PACKAGE}/${WANTED:-$PACKAGE}-$VERSION
|
gokhlayeh@186
|
399 else
|
gokhlayeh@266
|
400 tazwok_warning "Use original name or tarball root directory because src/_pkg are defined into the receipt (this is no more needed!)."
|
gokhlayeh@186
|
401 src=$WOK/${WANTED:-$PACKAGE}/${SOURCE:-${WANTED:-$PACKAGE}}-$VERSION
|
pankso@18
|
402 fi
|
pankso@18
|
403 }
|
pascal@76
|
404
|
gokhlayeh@186
|
405 set_pkg_path()
|
gokhlayeh@186
|
406 {
|
gokhlayeh@186
|
407 if [ -d $WOK/${WANTED:-$PACKAGE}/install ] ; then
|
gokhlayeh@186
|
408 _pkg=$WOK/${WANTED:-$PACKAGE}/install
|
gokhlayeh@186
|
409 else
|
gokhlayeh@186
|
410 _pkg=$src/_pkg
|
gokhlayeh@186
|
411 fi
|
gokhlayeh@186
|
412 }
|
gokhlayeh@186
|
413
|
gokhlayeh@186
|
414 # Output $VERSION-$EXTRAVERSION using packages.txt
|
gokhlayeh@186
|
415 get_pkg_version()
|
gokhlayeh@186
|
416 {
|
gokhlayeh@186
|
417 [ "$PACKAGE" ] || return
|
gokhlayeh@204
|
418 grep -m1 -A1 -sh ^$PACKAGE$ $1/packages.txt | tail -1 | sed 's/ *//'
|
gokhlayeh@186
|
419 }
|
gokhlayeh@186
|
420
|
gokhlayeh@186
|
421 remove_previous_package()
|
gokhlayeh@186
|
422 {
|
gokhlayeh@186
|
423 [ "$prev_VERSION" ] || return
|
gokhlayeh@186
|
424 if [ "$VERSION$EXTRAVERSION" != "$prev_VERSION" ]; then
|
gokhlayeh@186
|
425 rm -f $1/$PACKAGE-$prev_VERSION.tazpkg
|
gokhlayeh@186
|
426 fi
|
gokhlayeh@204
|
427 return
|
gokhlayeh@186
|
428 }
|
gokhlayeh@186
|
429
|
gokhlayeh@186
|
430 # Check for src tarball and wget if needed.
|
gokhlayeh@186
|
431 check_for_tarball()
|
gokhlayeh@186
|
432 {
|
gokhlayeh@258
|
433 [ "$WGET_URL" ] || return 0
|
gokhlayeh@253
|
434 report step "Checking for source tarball"
|
gokhlayeh@266
|
435 local repack_src TARBALL
|
gokhlayeh@266
|
436 if [ "$repack_src" = yes ] && look_for_cookopt !repack_src; then
|
gokhlayeh@266
|
437 repack_src=no
|
gokhlayeh@266
|
438 fi
|
gokhlayeh@266
|
439 if [ "$target" ]; then
|
gokhlayeh@266
|
440 src="$target"
|
gokhlayeh@266
|
441 else
|
gokhlayeh@266
|
442 set_src_path
|
gokhlayeh@266
|
443 fi
|
gokhlayeh@266
|
444 tmp_src=$tmp/tarball-$$
|
gokhlayeh@253
|
445 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
|
gokhlayeh@253
|
446 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] ; then
|
gokhlayeh@253
|
447 cd $SOURCES_REPOSITORY
|
gokhlayeh@266
|
448 if [ "$SOURCE" ]; then
|
gokhlayeh@266
|
449 alt_url="http://mirror.slitaz.org/sources/packages/${SOURCE:0:1}/$SOURCE-$VERSION.tar.lzma"
|
gokhlayeh@266
|
450 else
|
gokhlayeh@266
|
451 alt_url="http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$PACKAGE-$VERSION.tar.lzma"
|
slaxemulator@232
|
452 fi
|
gokhlayeh@266
|
453 download $WGET_URL $alt_url http://mirror.slitaz.org/sources/packages/${file:0:1}/$file
|
gokhlayeh@266
|
454 unset alt_url
|
gokhlayeh@253
|
455 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
|
gokhlayeh@266
|
456 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && \
|
gokhlayeh@266
|
457 [ ! -d $tmp_src ]; then
|
gokhlayeh@253
|
458 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n" >&2
|
gokhlayeh@253
|
459 report end-step
|
gokhlayeh@253
|
460 return 1
|
gokhlayeh@253
|
461 fi
|
slaxemulator@232
|
462 fi
|
gokhlayeh@253
|
463 report end-step
|
gokhlayeh@234
|
464 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$nounpack" ]; then
|
gokhlayeh@266
|
465 [ -d "$tmp_src" ] && rm -r $tmp_src
|
slaxemulator@232
|
466 return
|
slaxemulator@232
|
467 fi
|
slaxemulator@232
|
468
|
slaxemulator@232
|
469 # Untaring source if necessary. We don't need to extract source if
|
slaxemulator@232
|
470 # the package is built with a wanted source package.
|
slaxemulator@232
|
471 if [ "$WANTED" ]; then
|
gokhlayeh@266
|
472 [ -d "$tmp_src" ] && rm -r $tmp_src
|
slaxemulator@232
|
473 return
|
slaxemulator@232
|
474 fi
|
slaxemulator@232
|
475
|
slaxemulator@232
|
476 report step "Untaring source tarball"
|
slaxemulator@232
|
477
|
slaxemulator@232
|
478 # Log process.
|
slaxemulator@232
|
479 echo "untaring source tarball" >> $LOG
|
gokhlayeh@266
|
480
|
gokhlayeh@266
|
481 # If $tmp_src exists, there's already the unpacked tarball into it.
|
gokhlayeh@266
|
482 if ! [ -d $tmp_src ]; then
|
gokhlayeh@266
|
483 mkdir $tmp_src
|
gokhlayeh@266
|
484 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$repack_src" = yes ]; then
|
gokhlayeh@266
|
485 lzma d $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -so | \
|
gokhlayeh@266
|
486 tar xf - -C $tmp_src
|
gokhlayeh@266
|
487 repack_src=no
|
gokhlayeh@266
|
488 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
|
gokhlayeh@266
|
489 elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
|
gokhlayeh@266
|
490 case "$TARBALL" in
|
gokhlayeh@266
|
491 *zip|*xpi) cd $tmp_src && unzip -o $SOURCES_REPOSITORY/$TARBALL ;;
|
gokhlayeh@266
|
492 *bz2|*tbz|*gem) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
|
gokhlayeh@266
|
493 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
|
gokhlayeh@266
|
494 *lzma|*lz) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
|
gokhlayeh@266
|
495 *xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
|
gokhlayeh@266
|
496 *Z|*taz) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
|
gokhlayeh@266
|
497 *gz) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
|
gokhlayeh@266
|
498 *rpm) cd $tmp_src && rpm2cpio $SOURCES_REPOSITORY/$TARBALL | cpio -idm --quiet;;
|
gokhlayeh@266
|
499
|
gokhlayeh@266
|
500 # It's a plain file or something receipt unpack itself.
|
gokhlayeh@266
|
501 *)
|
gokhlayeh@266
|
502 mkdir $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
|
gokhlayeh@266
|
503 cp $SOURCES_REPOSITORY/$TARBALL $tmp_src/${src##*/}
|
gokhlayeh@266
|
504 ;;
|
gokhlayeh@266
|
505
|
gokhlayeh@266
|
506 esac || { rm -f $SOURCES_REPOSITORY/$TARBALL; rm -r $tmp_src; return 1; }
|
gokhlayeh@266
|
507 fi
|
gokhlayeh@266
|
508
|
slaxemulator@232
|
509 # Check if uncompressed tarball is in a root dir or not.
|
gokhlayeh@266
|
510 if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ] || [ -f $(echo $tmp_src/*) ]; then
|
slaxemulator@232
|
511 if check_for_var_modification src _pkg; then
|
slaxemulator@232
|
512 mv $tmp_src $tmp_src-1
|
slaxemulator@232
|
513 mkdir $tmp_src
|
gokhlayeh@233
|
514 mv $tmp_src-1 $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
|
slaxemulator@232
|
515 else
|
slaxemulator@232
|
516 mv $tmp_src/* $WOK/$PACKAGE
|
slaxemulator@232
|
517 repack_src=no
|
slaxemulator@232
|
518 rm -r $tmp_src
|
gokhlayeh@266
|
519 tazwok_warning "Put all files into $WOK/$PACKAGE; not sure about how to handle this tarball (no root dir)... Please try to remove src/_pkg definition from receipt if you encounter a problem."
|
slaxemulator@232
|
520 fi
|
slaxemulator@232
|
521 fi
|
gokhlayeh@266
|
522 fi
|
gokhlayeh@266
|
523
|
gokhlayeh@266
|
524 if [ "$repack_src" = yes ]; then
|
slaxemulator@232
|
525 report step "Repacking sources in .tar.lzma format"
|
gokhlayeh@266
|
526 [ "$TARBALL" ] && rm -f $SOURCES_REPOSITORY/$TARBALL
|
gokhlayeh@266
|
527 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
|
slaxemulator@232
|
528 cd $tmp_src
|
gokhlayeh@266
|
529 tar -c * | lzma e $SOURCES_REPOSITORY/$TARBALL -si
|
gokhlayeh@266
|
530 fi
|
slaxemulator@232
|
531
|
gokhlayeh@266
|
532 # Remove previous tarball if no other package needs it. We take care to
|
gokhlayeh@266
|
533 # keep tarball if the same package use it into main repository.
|
gokhlayeh@266
|
534 if [ "$TARBALL" ]; then
|
gokhlayeh@266
|
535 previous_tarball=$(grep ^$PACKAGE:incoming $SOURCES_REPOSITORY/sources.list | cut -f2)
|
gokhlayeh@266
|
536 if [ "$previous_tarball" ]; then
|
gokhlayeh@266
|
537 sed "/^$PACKAGE:incoming/ s/.*/$PACKAGE:incoming\t$TARBALL/" \
|
gokhlayeh@266
|
538 -i $SOURCES_REPOSITORY/sources.list
|
gokhlayeh@266
|
539 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
|
gokhlayeh@266
|
540 rm -f $SOURCES_REPOSITORY/$previous_tarball
|
gokhlayeh@266
|
541 else
|
gokhlayeh@266
|
542 echo -e "$PACKAGE:incoming\t$TARBALL" >> $SOURCES_REPOSITORY/sources.list
|
slaxemulator@232
|
543 fi
|
slaxemulator@232
|
544 fi
|
gokhlayeh@266
|
545
|
slaxemulator@232
|
546 if [ "$nounpack" ]; then
|
slaxemulator@232
|
547 [ -d "$tmp_src" ] && rm -r $tmp_src
|
slaxemulator@232
|
548 return
|
slaxemulator@232
|
549 fi
|
gokhlayeh@266
|
550 if [ ! -d "$src" ]; then
|
gokhlayeh@266
|
551 if ! check_for_var_modification src _pkg; then
|
gokhlayeh@266
|
552 src="${src%/*}/$(ls $tmp_src)"
|
gokhlayeh@186
|
553 fi
|
gokhlayeh@266
|
554 mv $(echo $tmp_src/*) "$src"
|
gokhlayeh@266
|
555 rm -r $tmp_src
|
gokhlayeh@266
|
556
|
gokhlayeh@266
|
557 # Permissions settings.
|
gokhlayeh@266
|
558 chown -R root.root "$src"
|
gokhlayeh@266
|
559 else
|
gokhlayeh@266
|
560 [ -d "$tmp_src" ] && rm -r $tmp_src
|
gokhlayeh@266
|
561 echo "There's already something at $src. Abort." >&2
|
gokhlayeh@186
|
562 fi
|
gokhlayeh@186
|
563 }
|
gokhlayeh@186
|
564
|
gokhlayeh@186
|
565 # Log and execute compile_rules function if it exists, to configure and
|
gokhlayeh@186
|
566 # make the package if it exists.
|
gokhlayeh@186
|
567 check_for_compile_rules()
|
gokhlayeh@186
|
568 {
|
gokhlayeh@186
|
569 if grep -q ^compile_rules $RECEIPT; then
|
gokhlayeh@186
|
570 echo "executing compile_rules" >> $LOG
|
gokhlayeh@186
|
571 report step "Executing compile_rules"
|
gokhlayeh@186
|
572 cd $WOK/$PACKAGE
|
gokhlayeh@186
|
573 rm -f /tmp/config.site
|
gokhlayeh@186
|
574
|
gokhlayeh@186
|
575 # Free some RAM by cleaning cache if option is enabled.
|
slaxemulator@200
|
576 freeram=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
|
gokhlayeh@186
|
577
|
gokhlayeh@186
|
578 # Disable -pipe in CFLAGS/CXXFLAGS if less than 512Mb of free
|
gokhlayeh@186
|
579 # RAM are available.
|
gokhlayeh@195
|
580 if [ "$freeram" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" -o \
|
gokhlayeh@195
|
581 "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then
|
gokhlayeh@195
|
582 tazwok_warning "Disabling -pipe compile flag because only ${freeram}b of RAM are available."
|
gokhlayeh@186
|
583 CFLAGS="${CFLAGS/-pipe}"
|
gokhlayeh@186
|
584 CXXFLAGS="${CXXFLAGS/-pipe}"
|
gokhlayeh@186
|
585 fi
|
gokhlayeh@186
|
586 unset freeram
|
gokhlayeh@186
|
587
|
gokhlayeh@186
|
588 # Set cook environnement variables.
|
gokhlayeh@186
|
589 [ "$src" ] || set_src_path
|
gokhlayeh@186
|
590 [ "$DESTDIR" ] || DESTDIR="$WOK/$PACKAGE/install"
|
gokhlayeh@186
|
591 [ "$CONFIG_SITE" ] || CONFIG_SITE=/etc/config.site
|
gokhlayeh@186
|
592 export CFLAGS CXXFLAGS MAKEFLAGS DESTDIR BUILD_HOST \
|
gokhlayeh@186
|
593 CONFIG_SITE default_prefix \
|
gokhlayeh@186
|
594 default_datarootdir default_datadir default_localedir \
|
gokhlayeh@186
|
595 default_infodir default_mandir default_build default_host
|
gokhlayeh@186
|
596 local LC_ALL=POSIX LANG=POSIX
|
gokhlayeh@186
|
597 compile_rules
|
gokhlayeh@186
|
598
|
gokhlayeh@186
|
599 # Check if config.site has been used.
|
gokhlayeh@186
|
600 # /!\ disabled since it screw the return_code of the step.
|
gokhlayeh@186
|
601 #if [ -f /tmp/config.site ]; then
|
gokhlayeh@186
|
602 # rm /tmp/config.site
|
gokhlayeh@186
|
603 #else
|
gokhlayeh@186
|
604 # tazwok_warning "config.site hasn't been used during \
|
gokhlayeh@186
|
605 #configuration process."
|
gokhlayeh@186
|
606 #fi
|
gokhlayeh@186
|
607
|
gokhlayeh@186
|
608 report end-step
|
gokhlayeh@186
|
609 fi
|
gokhlayeh@186
|
610 }
|
gokhlayeh@186
|
611
|
gokhlayeh@186
|
612 # Check for loop in deps tree. /!\ can be removed
|
pascal@76
|
613 check_for_deps_loop()
|
pascal@76
|
614 {
|
pascal@76
|
615 local list
|
pascal@76
|
616 local pkg
|
pascal@76
|
617 local deps
|
pascal@76
|
618 pkg=$1
|
pascal@76
|
619 shift
|
pascal@76
|
620 [ -n "$1" ] || return
|
pascal@76
|
621 list=""
|
gokhlayeh@204
|
622
|
pascal@76
|
623 # Filter out already processed deps
|
pascal@76
|
624 for i in $@; do
|
pascal@76
|
625 case " $ALL_DEPS" in
|
pascal@76
|
626 *\ $i\ *);;
|
pascal@76
|
627 *) list="$list $i";;
|
pascal@76
|
628 esac
|
pascal@76
|
629 done
|
pascal@76
|
630 ALL_DEPS="$ALL_DEPS$list "
|
pascal@76
|
631 for i in $list; do
|
pascal@76
|
632 [ -f $i/receipt ] || continue
|
pascal@76
|
633 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
|
pascal@76
|
634 case " $deps " in
|
pascal@76
|
635 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
|
pascal@76
|
636 *) check_for_deps_loop $pkg $deps;;
|
pascal@76
|
637 esac
|
pascal@76
|
638 done
|
pascal@76
|
639 }
|
pascal@76
|
640
|
gokhlayeh@266
|
641 # Function used by download().
|
gokhlayeh@266
|
642 revert_vcs_failure()
|
gokhlayeh@266
|
643 {
|
gokhlayeh@266
|
644 cd $SOURCES_REPOSITORY
|
gokhlayeh@266
|
645 rm -r $tmp_src
|
gokhlayeh@266
|
646 }
|
gokhlayeh@266
|
647
|
erjo@53
|
648 download()
|
erjo@53
|
649 {
|
erjo@53
|
650 for file in $@; do
|
gokhlayeh@266
|
651 echo "Downloading from ${file#*|}..."
|
gokhlayeh@255
|
652 case "$file" in
|
gokhlayeh@266
|
653 git\|*)
|
gokhlayeh@266
|
654 file=${file#git|}
|
gokhlayeh@266
|
655 if [ -d $INSTALLED/git ]; then
|
gokhlayeh@266
|
656 mkdir $tmp_src
|
gokhlayeh@266
|
657 cd $tmp_src
|
gokhlayeh@266
|
658 if [ "$BRANCH" ]; then
|
gokhlayeh@266
|
659 git clone $file ${src##*/} && cd ${src##*/} && \
|
gokhlayeh@266
|
660 git checkout $BRANCH && rm -rf .git* && break
|
gokhlayeh@266
|
661 else
|
gokhlayeh@266
|
662 git clone $file ${src##*/} && rm -rf ${src##*/}/.git* && break
|
gokhlayeh@266
|
663 fi
|
gokhlayeh@266
|
664 revert_vcs_failure
|
gokhlayeh@266
|
665 else
|
gokhlayeh@266
|
666 tazwok_warning "Needs git to download the source tarball from $file, please add it as build-depend."
|
gokhlayeh@266
|
667 continue
|
gokhlayeh@266
|
668 fi
|
gokhlayeh@266
|
669 ;;
|
gokhlayeh@266
|
670 subversion\|*)
|
gokhlayeh@266
|
671 file=${file#subversion|}
|
gokhlayeh@266
|
672 if [ -d $INSTALLED/subversion ]; then
|
gokhlayeh@266
|
673 mkdir $tmp_src
|
gokhlayeh@266
|
674 cd $tmp_src
|
gokhlayeh@266
|
675 if [ "$BRANCH" ]; then
|
gokhlayeh@266
|
676 echo t | svn co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.svn* && break
|
gokhlayeh@266
|
677 else
|
gokhlayeh@266
|
678 echo t | svn co $file ${src##*/} && rm -rf ${src##*/}/.svn* && break
|
gokhlayeh@266
|
679 fi
|
gokhlayeh@266
|
680 revert_vcs_failure
|
gokhlayeh@266
|
681 else
|
gokhlayeh@266
|
682 tazwok_warning "Needs subversion to download the source tarball from $file, please add it as build-depend."
|
gokhlayeh@266
|
683 continue
|
gokhlayeh@266
|
684 fi
|
gokhlayeh@266
|
685 ;;
|
gokhlayeh@266
|
686 mercurial\|*)
|
gokhlayeh@266
|
687 file=${file#mercurial|}
|
gokhlayeh@266
|
688 if [ -d $INSTALLED/mercurial ]; then
|
gokhlayeh@266
|
689 mkdir $tmp_src
|
gokhlayeh@266
|
690 cd $tmp_src
|
gokhlayeh@266
|
691 if [ "$BRANCH" ]; then
|
gokhlayeh@266
|
692 hg clone $file --rev $BRANCH ${src##*/} && rm -rf ${src##*/}/.hg* && break
|
gokhlayeh@266
|
693 else
|
gokhlayeh@266
|
694 hg clone $file ${src##*/} && rm -rf ${src##*/}/.hg* && break
|
gokhlayeh@266
|
695 fi
|
gokhlayeh@266
|
696 revert_vcs_failure
|
gokhlayeh@266
|
697 else
|
gokhlayeh@266
|
698 tazwok_warning "Needs mercurial to download the source tarball from $file, please add it as build-depend."
|
gokhlayeh@266
|
699 continue
|
gokhlayeh@266
|
700 fi
|
gokhlayeh@266
|
701 ;;
|
gokhlayeh@266
|
702 https*)
|
gokhlayeh@255
|
703 if [ -d $INSTALLED/wget ]; then
|
gokhlayeh@266
|
704 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
|
gokhlayeh@266
|
705 wget -q --no-check-certificate -O $TARBALL $file && break
|
gokhlayeh@266
|
706 else
|
gokhlayeh@266
|
707 wget -q $file && break
|
gokhlayeh@266
|
708 fi
|
gokhlayeh@255
|
709 else
|
gokhlayeh@266
|
710 tazwok_warning "Needs wget to download the source tarball from $file, please add it as build-depend."
|
gokhlayeh@266
|
711 continue
|
gokhlayeh@255
|
712 fi
|
gokhlayeh@266
|
713 ;;
|
gokhlayeh@266
|
714 http*|ftp*)
|
gokhlayeh@266
|
715 # Handle crappy URL.
|
gokhlayeh@266
|
716 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
|
gokhlayeh@266
|
717 wget -q -O $TARBALL $file && break
|
gokhlayeh@266
|
718 else
|
gokhlayeh@266
|
719 wget -q $file && break
|
gokhlayeh@266
|
720 fi
|
gokhlayeh@266
|
721 ;;
|
gokhlayeh@255
|
722 esac
|
erjo@53
|
723 done
|
erjo@53
|
724 }
|
pankso@18
|
725
|
gokhlayeh@186
|
726 # Regenerate every package that wants a PACKAGE compiled
|
pascal@156
|
727 refresh_packages_from_compile()
|
pascal@156
|
728 {
|
pascal@156
|
729 # make tazwok genpkg happy
|
pascal@156
|
730 mkdir $WOK/$PACKAGE/taz
|
gokhlayeh@204
|
731
|
gokhlayeh@186
|
732 # Cook rwanted in default or specied order
|
gokhlayeh@186
|
733 genlist=" $(look_for_rwanted | tr '\n' ' ') "
|
gokhlayeh@186
|
734 for i in $(look_for_cookopt genpkg | tac); do
|
gokhlayeh@186
|
735 [ "${genlist/ $i }" = "$genlist" ] && continue
|
gokhlayeh@186
|
736 genlist=" $i${genlist/ $i / }"
|
pascal@156
|
737 done
|
gokhlayeh@215
|
738 if [ "$genlist" ]; then
|
gokhlayeh@215
|
739 local PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
|
gokhlayeh@215
|
740 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
|
gokhlayeh@215
|
741 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
|
gokhlayeh@215
|
742 src _pkg DESTDIR CONFIG_SITE RECEIPT LOG
|
gokhlayeh@215
|
743 for PACKAGE in $genlist; do
|
gokhlayeh@215
|
744 set_common_path
|
gokhlayeh@215
|
745 gen_package
|
gokhlayeh@215
|
746 done
|
gokhlayeh@215
|
747 fi
|
pascal@156
|
748 }
|
pascal@156
|
749
|
MikeDSmith25@82
|
750 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
|
pankso@22
|
751 # so some packages need to copy these files with the receipt and genpkg_rules.
|
pankso@22
|
752 # This function is executed by gen_package when 'tazwok genpkg'.
|
pankso@22
|
753 copy_generic_files()
|
pankso@22
|
754 {
|
MikeDSmith25@82
|
755 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
|
pankso@22
|
756 # using generic variables and $LOCALE from Tazwok config file.
|
gokhlayeh@186
|
757 if [ "$LOCALE" ]; then
|
pankso@22
|
758 if [ -d "$_pkg/usr/share/locale" ]; then
|
pankso@22
|
759 for i in $LOCALE
|
pankso@22
|
760 do
|
pankso@37
|
761 if [ -d "$_pkg/usr/share/locale/$i" ]; then
|
pankso@37
|
762 mkdir -p $fs/usr/share/locale
|
pankso@37
|
763 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
|
pankso@37
|
764 fi
|
pankso@22
|
765 done
|
pankso@22
|
766 fi
|
pankso@22
|
767 fi
|
gokhlayeh@186
|
768
|
pankso@133
|
769 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
|
MikeDSmith25@82
|
770 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
|
pankso@31
|
771 # in pkg receipt.
|
gokhlayeh@186
|
772 if [ "$GENERIC_PIXMAPS" != "no" ]; then
|
pankso@22
|
773 if [ -d "$_pkg/usr/share/pixmaps" ]; then
|
pankso@27
|
774 mkdir -p $fs/usr/share/pixmaps
|
pankso@31
|
775 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
|
pankso@31
|
776 $fs/usr/share/pixmaps 2>/dev/null
|
pankso@31
|
777 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
|
pankso@22
|
778 $fs/usr/share/pixmaps 2>/dev/null
|
pankso@23
|
779 fi
|
gokhlayeh@186
|
780
|
MikeDSmith25@82
|
781 # Custom or homemade PNG pixmap can be in stuff.
|
pankso@23
|
782 if [ -f "stuff/$PACKAGE.png" ]; then
|
pankso@27
|
783 mkdir -p $fs/usr/share/pixmaps
|
pankso@23
|
784 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
|
pankso@22
|
785 fi
|
pankso@22
|
786 fi
|
gokhlayeh@186
|
787
|
pankso@22
|
788 # Desktop entry (.desktop).
|
pankso@22
|
789 if [ -d "$_pkg/usr/share/applications" ]; then
|
pankso@22
|
790 cp -a $_pkg/usr/share/applications $fs/usr/share
|
pankso@23
|
791 fi
|
gokhlayeh@186
|
792
|
MikeDSmith25@82
|
793 # Homemade desktop file(s) can be in stuff.
|
pankso@34
|
794 if [ -d "stuff/applications" ]; then
|
pankso@42
|
795 mkdir -p $fs/usr/share
|
pankso@42
|
796 cp -a stuff/applications $fs/usr/share
|
pankso@34
|
797 fi
|
pankso@34
|
798 if [ -f "stuff/$PACKAGE.desktop" ]; then
|
pankso@42
|
799 mkdir -p $fs/usr/share/applications
|
pankso@42
|
800 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
|
pankso@22
|
801 fi
|
pankso@22
|
802 }
|
pankso@22
|
803
|
pankso@25
|
804 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
|
pankso@25
|
805 strip_package()
|
pankso@25
|
806 {
|
gokhlayeh@186
|
807 report step "Executing strip on all files"
|
gokhlayeh@186
|
808
|
pankso@25
|
809 # Binaries.
|
pankso@25
|
810 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
|
pankso@25
|
811 do
|
pankso@25
|
812 if [ -d "$dir" ]; then
|
pankso@25
|
813 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
|
pankso@25
|
814 fi
|
pankso@25
|
815 done
|
gokhlayeh@186
|
816
|
pankso@25
|
817 # Libraries.
|
pankso@25
|
818 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
|
pankso@25
|
819 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
|
gokhlayeh@186
|
820 report end-step
|
gokhlayeh@186
|
821 }
|
gokhlayeh@186
|
822
|
gokhlayeh@186
|
823 # Remove .pyc and .pyo files from packages
|
gokhlayeh@186
|
824 py_compiled_files_remove()
|
gokhlayeh@186
|
825 {
|
gokhlayeh@186
|
826 report step "Removing all .pyc and .pyo files from package ..."
|
gokhlayeh@186
|
827 find $fs -type f -name "*.pyc" -delete 2>/dev/null
|
gokhlayeh@186
|
828 find $fs -type f -name "*.pyo" -delete 2>/dev/null
|
gokhlayeh@186
|
829 report end-step
|
pankso@25
|
830 }
|
pankso@25
|
831
|
pankso@135
|
832 # Check FSH in a slitaz package (Path: /:/usr)
|
pankso@135
|
833 check_fsh()
|
pankso@135
|
834 {
|
pankso@135
|
835 cd $WOK/$PACKAGE/taz/*/fs
|
pascal@149
|
836 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
|
pascal@149
|
837 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
|
pascal@149
|
838 usr/local usr/sbin usr/share usr/src"
|
pankso@135
|
839 for i in `ls -d * usr/* 2>/dev/null`
|
pankso@135
|
840 do
|
gokhlayeh@195
|
841 if ! echo $FSH | fgrep -q $i; then
|
gokhlayeh@186
|
842 echo "Wrong path: /$i" >&2
|
pankso@135
|
843 error=1
|
pankso@135
|
844 fi
|
pankso@135
|
845 done
|
pankso@135
|
846 if [ "$error" = "1" ]; then
|
pankso@135
|
847 cat << _EOT_
|
pankso@135
|
848
|
paul@155
|
849 Package will install files in a non standard directory and won't be generated.
|
paul@154
|
850 You may have a wrong copy path in genpkg_rules or need to add some options to
|
pankso@135
|
851 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
|
pankso@135
|
852
|
pankso@135
|
853 --prefix=/usr
|
pankso@135
|
854 --sysconfdir=/etc
|
pankso@135
|
855 --libexecdir=/usr/lib/(pkgname)
|
pankso@135
|
856 --localstatedir=/var
|
pankso@135
|
857 --mandir=/usr/share/man
|
pankso@135
|
858 --infodir=/usr/share/info
|
pankso@135
|
859
|
paul@152
|
860 For more information please read SliTaz docs and run: ./configure --help
|
pankso@135
|
861 ================================================================================
|
pankso@135
|
862 $PACKAGE package generation aborted.
|
pankso@135
|
863
|
pankso@135
|
864 _EOT_
|
gokhlayeh@186
|
865
|
pankso@135
|
866 # Dont generate a corrupted package.
|
pankso@137
|
867 cd $WOK/$PACKAGE && rm -rf taz
|
gokhlayeh@186
|
868 report exit
|
pankso@135
|
869 fi
|
gokhlayeh@186
|
870 }
|
gokhlayeh@186
|
871
|
gokhlayeh@186
|
872 gen_cookmd5()
|
gokhlayeh@186
|
873 {
|
gokhlayeh@186
|
874 # md5sum of cooking stuff make tazwok able to check for changes
|
gokhlayeh@186
|
875 # without hg.
|
gokhlayeh@186
|
876 cd $WOK/$PACKAGE
|
gokhlayeh@186
|
877 md5sum receipt > md5
|
gokhlayeh@186
|
878 [ -f description.txt ] && md5sum description.txt >> md5
|
gokhlayeh@186
|
879 if [ -d stuff ]; then
|
gokhlayeh@186
|
880 find stuff | while read file; do
|
gokhlayeh@186
|
881 md5sum $file >> md5
|
gokhlayeh@186
|
882 done
|
gokhlayeh@186
|
883 fi
|
pankso@135
|
884 }
|
pankso@135
|
885
|
MikeDSmith25@82
|
886 # Create a package tree and build the gziped cpio archive
|
pankso@7
|
887 # to make a SliTaz (.tazpkg) package.
|
pankso@7
|
888 gen_package()
|
pankso@7
|
889 {
|
pankso@7
|
890 check_root
|
pankso@7
|
891 check_for_package_on_cmdline
|
pankso@7
|
892 check_for_receipt
|
pascal@74
|
893 EXTRAVERSION=""
|
pankso@7
|
894 . $RECEIPT
|
gokhlayeh@186
|
895
|
pascal@86
|
896 # May compute VERSION
|
pascal@86
|
897 if grep -q ^get_version $RECEIPT; then
|
pascal@86
|
898 get_version
|
pascal@86
|
899 fi
|
pankso@7
|
900 check_for_wanted
|
pankso@7
|
901 cd $WOK/$PACKAGE
|
gokhlayeh@186
|
902
|
pankso@7
|
903 # Remove old Tazwok package files.
|
gokhlayeh@186
|
904 [ -d "taz" ] && rm -rf taz
|
gokhlayeh@186
|
905
|
MikeDSmith25@82
|
906 # Create the package tree and set useful variables.
|
gokhlayeh@266
|
907 mkdir -p $WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
|
gokhlayeh@266
|
908 fs=$WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
|
gokhlayeh@186
|
909
|
MikeDSmith25@82
|
910 # Set $src for standard package and $_pkg variables.
|
gokhlayeh@186
|
911 set_src_path && set_pkg_path
|
gokhlayeh@186
|
912
|
pankso@135
|
913 # Execute genpkg_rules, check package and copy generic files to build
|
pankso@135
|
914 # the package.
|
gokhlayeh@186
|
915 report step "Building $PACKAGE with the receipt"
|
gokhlayeh@186
|
916 report open-bloc
|
pankso@28
|
917 if grep -q ^genpkg_rules $RECEIPT; then
|
gokhlayeh@186
|
918
|
pankso@7
|
919 # Log process.
|
pankso@7
|
920 echo "executing genpkg_rules" >> $LOG
|
gokhlayeh@186
|
921 report step "Executing genpkg_rules"
|
pascal@126
|
922 genpkg_rules
|
gokhlayeh@186
|
923 report end-step
|
pankso@135
|
924 check_fsh
|
pankso@25
|
925 cd $WOK/$PACKAGE
|
gokhlayeh@186
|
926
|
pankso@133
|
927 # Skip generic files for packages with a WANTED variable
|
pankso@24
|
928 # (dev and splited pkgs).
|
gokhlayeh@186
|
929 if [ ! "$WANTED" ]; then
|
pankso@24
|
930 copy_generic_files
|
pankso@24
|
931 fi
|
gokhlayeh@204
|
932 look_for_cookopt !strip || strip_package
|
gokhlayeh@186
|
933 py_compiled_files_remove
|
pankso@7
|
934 else
|
gokhlayeh@186
|
935 echo "No package rules to gen $PACKAGE..." >&2
|
gokhlayeh@186
|
936 report exit
|
pankso@7
|
937 fi
|
gokhlayeh@186
|
938
|
paul@154
|
939 # Copy the receipt and description (if exists) into the binary package tree.
|
pankso@7
|
940 cd $WOK/$PACKAGE
|
gokhlayeh@186
|
941 report step "Copying the receipt"
|
pankso@7
|
942 cp receipt taz/$PACKAGE-$VERSION
|
gokhlayeh@186
|
943 report end-step
|
pascal@89
|
944 if grep -q ^get_version $RECEIPT; then
|
gokhlayeh@186
|
945 report step "Updating version in receipt"
|
pascal@89
|
946 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
|
pascal@89
|
947 taz/$PACKAGE-$VERSION/receipt
|
gokhlayeh@186
|
948 report end-step
|
pascal@89
|
949 fi
|
pankso@7
|
950 if [ -f "description.txt" ]; then
|
gokhlayeh@186
|
951 report step "Copying the description file"
|
pankso@7
|
952 cp description.txt taz/$PACKAGE-$VERSION
|
gokhlayeh@186
|
953 report end-step
|
pankso@7
|
954 fi
|
gokhlayeh@186
|
955
|
gokhlayeh@186
|
956 # Generate md5 of cooking stuff to look for commit later.
|
gokhlayeh@186
|
957 gen_cookmd5
|
gokhlayeh@186
|
958 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
|
gokhlayeh@186
|
959 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
|
gokhlayeh@186
|
960
|
MikeDSmith25@82
|
961 # Create the files.list by redirecting find output.
|
gokhlayeh@186
|
962 report step "Creating the list of files"
|
pascal@15
|
963 cd taz/$PACKAGE-$VERSION
|
pascal@13
|
964 LAST_FILE=""
|
gokhlayeh@195
|
965 { find fs -print; echo; } | while read file; do
|
gokhlayeh@186
|
966 if [ "$LAST_FILE" ]; then
|
pascal@15
|
967 case "$file" in
|
pascal@13
|
968 $LAST_FILE/*)
|
pankso@133
|
969 case "$(ls -ld "$LAST_FILE")" in
|
pascal@15
|
970 drwxr-xr-x\ *\ root\ *\ root\ *);;
|
pascal@15
|
971 *) echo ${LAST_FILE#fs};;
|
pascal@13
|
972 esac;;
|
pascal@15
|
973 *) echo ${LAST_FILE#fs};;
|
pascal@13
|
974 esac
|
pascal@13
|
975 fi
|
pascal@15
|
976 LAST_FILE="$file"
|
pascal@15
|
977 done > files.list
|
gokhlayeh@186
|
978
|
gokhlayeh@186
|
979 # Next, check if something has changed in lib files.
|
gokhlayeh@215
|
980 if fgrep -q '.so' files.list; then
|
gokhlayeh@215
|
981 report step "Look for major/minor update in libraries"
|
gokhlayeh@215
|
982 for rep in $INCOMING_REPOSITORY $PACKAGES_REPOSITORY \
|
gokhlayeh@215
|
983 $([ "$undigest" ] && echo SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming && \
|
gokhlayeh@215
|
984 echo $SLITAZ_DIR/$SLITAZ_VERSION/packages); do
|
gokhlayeh@215
|
985 prev_VERSION=$(get_pkg_version $rep)
|
gokhlayeh@215
|
986 [ "$prev_VERSION" ] && pkg_file=$rep/$PACKAGE-$prev_VERSION.tazpkg && break
|
gokhlayeh@215
|
987 done
|
gokhlayeh@215
|
988 if [ "$pkg_file" ]; then
|
gokhlayeh@215
|
989 get_pkg_files $pkg_file
|
gokhlayeh@215
|
990 cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
|
gokhlayeh@215
|
991 fgrep ".so" files.list | egrep -v "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*" | \
|
gokhlayeh@215
|
992 while read lib; do
|
gokhlayeh@215
|
993 fgrep -q "$lib" $pkg_files_dir/files.list && continue
|
gokhlayeh@215
|
994 echo "A minor/major update in libraries is detected, planning re-cook of reverse-depends of $PACKAGE."
|
gokhlayeh@215
|
995 for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do
|
gokhlayeh@215
|
996 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
|
gokhlayeh@215
|
997 grep -q ^$rdep$ $PACKAGES_REPOSITORY/blocked \
|
gokhlayeh@215
|
998 $PACKAGES_REPOSITORY/cooklist && continue
|
gokhlayeh@215
|
999 echo $rdep >> $PACKAGES_REPOSITORY/cooklist
|
gokhlayeh@215
|
1000 done
|
gokhlayeh@215
|
1001 regen_cooklist=yes
|
gokhlayeh@215
|
1002 break
|
gokhlayeh@215
|
1003 done
|
gokhlayeh@215
|
1004 rm -r $pkg_files_dir
|
gokhlayeh@186
|
1005 fi
|
gokhlayeh@186
|
1006 report end-step
|
gokhlayeh@186
|
1007 fi
|
gokhlayeh@186
|
1008 if [ ! "$EXTRAVERSION" ]; then
|
pascal@84
|
1009 case "$PACKAGE" in
|
pascal@84
|
1010 linux*);;
|
pascal@85
|
1011 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
|
pascal@84
|
1012 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
|
pascal@84
|
1013 esac
|
pascal@84
|
1014 fi
|
gokhlayeh@186
|
1015 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
|
gokhlayeh@186
|
1016 report step "Creating md5sum of files"
|
pascal@70
|
1017 while read file; do
|
pascal@71
|
1018 [ -L "fs$file" ] && continue
|
pascal@71
|
1019 [ -f "fs$file" ] || continue
|
pascal@71
|
1020 md5sum "fs$file" | sed 's/ fs/ /'
|
pascal@70
|
1021 done < files.list > md5sum
|
gokhlayeh@204
|
1022 report end-step
|
pascal@84
|
1023 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
|
pascal@84
|
1024 2> /dev/null | awk '{ sz=$1 } END { print sz }')
|
gokhlayeh@186
|
1025
|
pankso@7
|
1026 # Build cpio archives. Find, cpio and gzip the fs, finish by
|
pankso@7
|
1027 # removing the fs tree.
|
gokhlayeh@186
|
1028 # Don't log this because compression always output error messages.
|
pascal@150
|
1029 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
|
pascal@150
|
1030 tazpkg-lzma) gzip > fs.cpio.gz;;
|
pascal@150
|
1031 *-lzma) lzma e fs.cpio.lzma -si;;
|
pascal@150
|
1032 *) gzip > fs.cpio.gz;;
|
pascal@150
|
1033 esac && rm -rf fs
|
pascal@150
|
1034 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
|
pascal@84
|
1035 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
|
gokhlayeh@186
|
1036 report step "Updating receipt sizes"
|
pascal@138
|
1037 sed -i '/^PACKED_SIZE/d' receipt
|
pascal@138
|
1038 sed -i '/^UNPACKED_SIZE/d' receipt
|
pascal@59
|
1039 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
|
pascal@86
|
1040 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
|
gokhlayeh@212
|
1041 report end-step
|
gokhlayeh@212
|
1042 if [ "$EXTRAVERSION" ]; then
|
gokhlayeh@186
|
1043 report step "Updating receipt EXTRAVERSION"
|
pascal@72
|
1044 sed -i s/^EXTRAVERSION.*$// receipt
|
pascal@72
|
1045 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
|
pascal@72
|
1046 fi
|
gokhlayeh@186
|
1047 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
|
gokhlayeh@186
|
1048 remove_previous_package $INCOMING_REPOSITORY
|
gokhlayeh@186
|
1049 report step "Creating full cpio archive"
|
gokhlayeh@186
|
1050 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
|
gokhlayeh@186
|
1051
|
paul@154
|
1052 # Restore package tree in case we want to browse it.
|
gokhlayeh@186
|
1053 report step "Restoring original package tree"
|
gokhlayeh@195
|
1054 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
|
pascal@150
|
1055 rm fs.cpio.* && cd ..
|
gokhlayeh@186
|
1056
|
pankso@7
|
1057 # Log process.
|
pascal@69
|
1058 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
|
gokhlayeh@186
|
1059 report close-bloc
|
pascal@68
|
1060 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
|
gokhlayeh@186
|
1061 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
|
pankso@7
|
1062 echo ""
|
gokhlayeh@186
|
1063
|
gokhlayeh@204
|
1064 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken
|
gokhlayeh@204
|
1065 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
|
gokhlayeh@204
|
1066 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
|
pankso@7
|
1067 }
|
pankso@7
|
1068
|
gokhlayeh@186
|
1069 ########################################################################
|
gokhlayeh@186
|
1070 # This section contains functions used by several other functions
|
gokhlayeh@186
|
1071 # bellow.
|
gokhlayeh@186
|
1072 ########################
|
gokhlayeh@186
|
1073
|
gokhlayeh@186
|
1074 # Look for receipt/files.list in wok. If they can't be found, get them
|
gokhlayeh@186
|
1075 # from package. Accept one argument : absolute path to package.
|
gokhlayeh@186
|
1076 get_pkg_files()
|
pankso@28
|
1077 {
|
gokhlayeh@186
|
1078 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
|
gokhlayeh@186
|
1079 mkdir -p $pkg_files_dir && \
|
gokhlayeh@186
|
1080 cd $pkg_files_dir && \
|
gokhlayeh@186
|
1081 cpio --quiet -idm receipt < $1 && \
|
gokhlayeh@186
|
1082 cpio --quiet -idm files.list < $1
|
gokhlayeh@186
|
1083 }
|
gokhlayeh@170
|
1084
|
gokhlayeh@186
|
1085 ########################################################################
|
gokhlayeh@204
|
1086 # This section contains functions to generate packages databases.
|
gokhlayeh@186
|
1087 ########################
|
gokhlayeh@186
|
1088
|
gokhlayeh@186
|
1089
|
gokhlayeh@186
|
1090 gen_packages_db()
|
gokhlayeh@186
|
1091 {
|
gokhlayeh@186
|
1092 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
|
gokhlayeh@204
|
1093 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
|
gokhlayeh@186
|
1094 cd $pkg_repository
|
gokhlayeh@204
|
1095 report step "Generating packages lists: $pkg_repository"
|
gokhlayeh@204
|
1096 report open-bloc
|
gokhlayeh@204
|
1097 report step "Removing old files"
|
gokhlayeh@204
|
1098 for file in files.list.lzma packages.list packages.txt \
|
gokhlayeh@204
|
1099 packages.desc packages.equiv packages.md5; do
|
gokhlayeh@204
|
1100 [ -f $file ] && rm $file
|
gokhlayeh@204
|
1101 done
|
gokhlayeh@204
|
1102 touch files.list
|
gokhlayeh@204
|
1103
|
gokhlayeh@186
|
1104 packages_db_start
|
gokhlayeh@186
|
1105 unset RECEIPT
|
gokhlayeh@186
|
1106 report step "Reading datas from all packages"
|
gokhlayeh@195
|
1107 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
|
gokhlayeh@186
|
1108 get_packages_info
|
gokhlayeh@186
|
1109 done
|
gokhlayeh@186
|
1110 report end-step
|
gokhlayeh@186
|
1111 packages_db_end
|
gokhlayeh@204
|
1112 report close-bloc
|
gokhlayeh@186
|
1113 }
|
gokhlayeh@186
|
1114
|
gokhlayeh@186
|
1115 update_packages_db()
|
gokhlayeh@186
|
1116 {
|
gokhlayeh@204
|
1117 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
|
gokhlayeh@186
|
1118 cd $pkg_repository
|
gokhlayeh@204
|
1119 for file in packages.list packages.equiv packages.md5 packages.desc \
|
gokhlayeh@204
|
1120 packages.txt; do
|
gokhlayeh@186
|
1121 if [ ! -f "$file" ]; then
|
gokhlayeh@204
|
1122 gen_packages_db
|
gokhlayeh@186
|
1123 return
|
gokhlayeh@186
|
1124 fi
|
gokhlayeh@186
|
1125 done
|
gokhlayeh@186
|
1126 if [ -f files.list.lzma ]; then
|
gokhlayeh@186
|
1127 lzma d files.list.lzma files.list
|
gokhlayeh@186
|
1128 else
|
gokhlayeh@204
|
1129 gen_packages_db
|
gokhlayeh@186
|
1130 fi
|
gokhlayeh@204
|
1131 report step "Updating packages lists: $pkg_repository"
|
gokhlayeh@186
|
1132 packages_db_start
|
gokhlayeh@186
|
1133
|
gokhlayeh@186
|
1134 # Look for removed/update packages.
|
gokhlayeh@186
|
1135 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
|
gokhlayeh@202
|
1136 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
|
gokhlayeh@195
|
1137 if ! [ -f "$pkg" ]; then
|
gokhlayeh@186
|
1138 erase_package_info
|
gokhlayeh@186
|
1139 else
|
gokhlayeh@186
|
1140 if [ "$pkg" -nt "packages.list" ]; then
|
gokhlayeh@215
|
1141 updated_pkg="$updated_pkg
|
gokhlayeh@215
|
1142 $PACKAGE $pkg"
|
gokhlayeh@266
|
1143 elif [ ! -f $WOK/$PACKAGE/receipt ] && \
|
gokhlayeh@266
|
1144 [ "$COMMAND" = check-incoming -o "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
|
gokhlayeh@266
|
1145 erase_package_info
|
gokhlayeh@266
|
1146 echo "Removing $PACKAGE from $pkg_repository."
|
gokhlayeh@266
|
1147 rm $pkg
|
gokhlayeh@266
|
1148 [ -d $WOK/$PACKAGE ] && rm -r $WOK/$PACKAGE
|
gokhlayeh@266
|
1149 if [ "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
|
gokhlayeh@266
|
1150 sed "/^$PACKAGE\t/d" -i $wan_db $dep_db
|
gokhlayeh@266
|
1151 for i in cookorder.txt cooklist commit blocked broken; do
|
gokhlayeh@266
|
1152 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/$i
|
gokhlayeh@266
|
1153 done
|
gokhlayeh@266
|
1154 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
|
gokhlayeh@266
|
1155 regen_cooklist=yes
|
gokhlayeh@266
|
1156 else
|
gokhlayeh@266
|
1157 echo "$PACKAGE" >> $PACKAGES_REPOSITORY/removed
|
gokhlayeh@266
|
1158 sed -n '1,10p' -i $PACKAGES_REPOSITORY/removed
|
gokhlayeh@266
|
1159 fi
|
gokhlayeh@186
|
1160 fi
|
gokhlayeh@170
|
1161 fi
|
gokhlayeh@170
|
1162 done
|
gokhlayeh@215
|
1163 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
|
gokhlayeh@202
|
1164 erase_package_info
|
gokhlayeh@202
|
1165 get_packages_info
|
gokhlayeh@202
|
1166 done
|
gokhlayeh@204
|
1167 unset updated_pkg
|
gokhlayeh@202
|
1168
|
gokhlayeh@186
|
1169 # Look for new packages.
|
gokhlayeh@195
|
1170 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
|
gokhlayeh@199
|
1171 if ! fgrep -q " ${pkg##*/}" $pkg_repository/packages.md5; then
|
gokhlayeh@186
|
1172 get_packages_info
|
gokhlayeh@186
|
1173 fi
|
gokhlayeh@186
|
1174 done
|
gokhlayeh@186
|
1175 report end-step
|
gokhlayeh@186
|
1176 packages_db_end
|
gokhlayeh@186
|
1177 }
|
gokhlayeh@186
|
1178
|
gokhlayeh@186
|
1179 packages_db_start()
|
gokhlayeh@186
|
1180 {
|
gokhlayeh@186
|
1181 if [ ! -s packages.txt ]; then
|
gokhlayeh@186
|
1182 echo "# SliTaz GNU/Linux - Packages list
|
gokhlayeh@186
|
1183 #
|
gokhlayeh@186
|
1184 # Packages : unknow
|
gokhlayeh@186
|
1185 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
|
gokhlayeh@215
|
1186 #
|
gokhlayeh@215
|
1187 " > packages.txt
|
pascal@62
|
1188 else
|
gokhlayeh@186
|
1189 sed -e 's/^# Packages :.*/# Packages : unknow/' \
|
gokhlayeh@186
|
1190 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
|
gokhlayeh@186
|
1191 -i packages.txt
|
pascal@60
|
1192 fi
|
gokhlayeh@186
|
1193
|
gokhlayeh@186
|
1194 # Needed in some case as tazwok define RECEIPT at configuration time
|
gokhlayeh@186
|
1195 # in this particular case it can broke the script.
|
gokhlayeh@186
|
1196 unset RECEIPT
|
gokhlayeh@186
|
1197 }
|
gokhlayeh@186
|
1198
|
gokhlayeh@186
|
1199 erase_package_info()
|
gokhlayeh@186
|
1200 {
|
gokhlayeh@186
|
1201 cd $pkg_repository
|
gokhlayeh@186
|
1202 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
|
gokhlayeh@186
|
1203 sed "/^$PACKAGE /d" -i packages.desc
|
gokhlayeh@186
|
1204 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
|
gokhlayeh@186
|
1205 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
|
gokhlayeh@186
|
1206 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
|
gokhlayeh@186
|
1207 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
|
gokhlayeh@186
|
1208 -i packages.equiv
|
gokhlayeh@186
|
1209 sed "/^$PACKAGE:/d" -i files.list
|
gokhlayeh@186
|
1210 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
|
gokhlayeh@186
|
1211 sed "/ $(basename $pkg)$/d" -i packages.md5
|
gokhlayeh@186
|
1212 }
|
gokhlayeh@186
|
1213
|
gokhlayeh@186
|
1214 get_packages_info()
|
gokhlayeh@186
|
1215 {
|
gokhlayeh@186
|
1216 # If there's no taz folder in the wok, extract infos from the
|
gokhlayeh@186
|
1217 # package.
|
gokhlayeh@186
|
1218 get_pkg_files $pkg
|
gokhlayeh@186
|
1219 source_receipt
|
gokhlayeh@186
|
1220 echo "Getting datas from $PACKAGE"
|
gokhlayeh@186
|
1221
|
gokhlayeh@186
|
1222 cat >> $pkg_repository/packages.txt << _EOT_
|
pankso@28
|
1223 $PACKAGE
|
gokhlayeh@186
|
1224 $VERSION$EXTRAVERSION
|
pankso@28
|
1225 $SHORT_DESC
|
pankso@28
|
1226 _EOT_
|
gokhlayeh@215
|
1227 if [ "$PACKED_SIZE" ]; then
|
gokhlayeh@215
|
1228 cat >> $pkg_repository/packages.txt << _EOT_
|
pankso@133
|
1229 $PACKED_SIZE ($UNPACKED_SIZE installed)
|
gokhlayeh@215
|
1230
|
pascal@60
|
1231 _EOT_
|
gokhlayeh@215
|
1232 else
|
gokhlayeh@215
|
1233 echo "" >> $pkg_repository/packages.txt
|
gokhlayeh@215
|
1234 fi
|
gokhlayeh@186
|
1235
|
paul@121
|
1236 # Packages.desc is used by Tazpkgbox <tree>.
|
gokhlayeh@186
|
1237 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
|
gokhlayeh@186
|
1238
|
paul@121
|
1239 # Packages.equiv is used by tazpkg install to check depends
|
pascal@99
|
1240 for i in $PROVIDE; do
|
pascal@99
|
1241 DEST=""
|
gokhlayeh@195
|
1242 echo $i | fgrep -q : && DEST="${i#*:}:"
|
gokhlayeh@186
|
1243 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
|
gokhlayeh@186
|
1244 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
|
pascal@99
|
1245 else
|
gokhlayeh@186
|
1246 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
|
gokhlayeh@186
|
1247 fi
|
gokhlayeh@186
|
1248 done
|
gokhlayeh@186
|
1249
|
gokhlayeh@186
|
1250 if [ -f files.list ]; then
|
gokhlayeh@186
|
1251 { echo "$PACKAGE"; cat files.list; } | awk '
|
gokhlayeh@186
|
1252 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
|
gokhlayeh@186
|
1253 fi
|
gokhlayeh@186
|
1254
|
gokhlayeh@186
|
1255 cd .. && rm -r "$pkg_files_dir"
|
gokhlayeh@186
|
1256
|
gokhlayeh@186
|
1257 cd $pkg_repository
|
gokhlayeh@186
|
1258 echo $(basename ${pkg%.tazpkg}) >> packages.list
|
gokhlayeh@186
|
1259 [ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
|
gokhlayeh@186
|
1260 echo "$package_md5" >> packages.md5
|
gokhlayeh@186
|
1261 unset package_md5
|
gokhlayeh@186
|
1262 }
|
gokhlayeh@186
|
1263
|
gokhlayeh@186
|
1264 source_receipt()
|
gokhlayeh@186
|
1265 {
|
gokhlayeh@186
|
1266 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
|
gokhlayeh@186
|
1267 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
|
gokhlayeh@186
|
1268 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
|
gokhlayeh@266
|
1269 src _pkg DESTDIR CONFIG_SITE BRANCH TARBALL
|
gokhlayeh@186
|
1270 . ${RECEIPT:-$PWD/receipt}
|
gokhlayeh@186
|
1271 }
|
gokhlayeh@186
|
1272
|
gokhlayeh@186
|
1273 packages_db_end()
|
gokhlayeh@186
|
1274 {
|
gokhlayeh@186
|
1275 cd $pkg_repository
|
gokhlayeh@186
|
1276 pkgs=$(wc -l packages.list | sed 's/ .*//')
|
gokhlayeh@186
|
1277 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
|
gokhlayeh@186
|
1278
|
gokhlayeh@186
|
1279 # If lists was updated it's generally needed to sort them well.
|
gokhlayeh@186
|
1280 if ! sort -c packages.list 2> /dev/null; then
|
gokhlayeh@186
|
1281 report step "Sorting packages lists"
|
gokhlayeh@186
|
1282 for file in packages.list packages.desc packages.equiv; do
|
gokhlayeh@186
|
1283 [ -f $file ] || continue
|
gokhlayeh@186
|
1284 sort -o $file $file
|
gokhlayeh@186
|
1285 done
|
gokhlayeh@186
|
1286 report end-step
|
gokhlayeh@186
|
1287 fi
|
gokhlayeh@186
|
1288
|
gokhlayeh@186
|
1289 # Dont log this because lzma always output error.
|
gokhlayeh@186
|
1290 lzma e files.list files.list.lzma
|
gokhlayeh@204
|
1291 rm -f files.list
|
gokhlayeh@204
|
1292 [ -f packages.equiv ] || touch packages.equiv
|
gokhlayeh@186
|
1293 }
|
gokhlayeh@186
|
1294
|
gokhlayeh@186
|
1295 ########################################################################
|
gokhlayeh@186
|
1296 # This section contains functions to generate wok database.
|
gokhlayeh@186
|
1297 ########################
|
gokhlayeh@186
|
1298
|
gokhlayeh@186
|
1299 gen_wok_db()
|
gokhlayeh@186
|
1300 {
|
gokhlayeh@204
|
1301 report step "Generating wok database"
|
gokhlayeh@186
|
1302 report open-bloc
|
gokhlayeh@204
|
1303 report step "Removing old files"
|
gokhlayeh@204
|
1304 for file in $wan_db $dep_db $PACKAGES_REPOSITORY/cookorder.txt; do
|
gokhlayeh@204
|
1305 [ -f $file ] && rm $file
|
gokhlayeh@204
|
1306 done
|
gokhlayeh@186
|
1307 report step "Generating wok-wanted.txt"
|
gokhlayeh@204
|
1308 gen_wan_db
|
gokhlayeh@186
|
1309 report step "Generating wok-depends.txt"
|
gokhlayeh@204
|
1310 for PACKAGE in $(cut -f1 -d '|' $PACKAGES_REPOSITORY/packages.desc \
|
gokhlayeh@204
|
1311 $INCOMING_REPOSITORY/packages.desc | sort -u); do
|
gokhlayeh@186
|
1312 RECEIPT=$WOK/$PACKAGE/receipt
|
gokhlayeh@186
|
1313 if [ -s $RECEIPT ]; then
|
gokhlayeh@186
|
1314 source_receipt
|
gokhlayeh@186
|
1315 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
|
pankso@133
|
1316 fi
|
pascal@99
|
1317 done
|
gokhlayeh@215
|
1318 sort_db
|
gokhlayeh@204
|
1319 report close-bloc
|
gokhlayeh@204
|
1320 }
|
gokhlayeh@204
|
1321
|
gokhlayeh@204
|
1322 gen_wan_db()
|
gokhlayeh@204
|
1323 {
|
gokhlayeh@204
|
1324 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
|
gokhlayeh@204
|
1325 WANTED=
|
gokhlayeh@204
|
1326 source $RECEIPT
|
gokhlayeh@204
|
1327 [ "$WANTED" ] || continue
|
gokhlayeh@204
|
1328 echo -e $PACKAGE"\t"$WANTED >> $tmp/wan_db
|
gokhlayeh@204
|
1329 done
|
gokhlayeh@215
|
1330 if ! [ -f $wan_db ] || [ "$(diff -q $tmp/wan_db $wan_db)" ]; then
|
gokhlayeh@204
|
1331 mv -f $tmp/wan_db $wan_db
|
gokhlayeh@204
|
1332 plan_regen_cookorder=yes
|
gokhlayeh@204
|
1333 else
|
gokhlayeh@204
|
1334 rm $tmp/wan_db
|
gokhlayeh@204
|
1335 fi
|
gokhlayeh@204
|
1336 }
|
gokhlayeh@204
|
1337
|
gokhlayeh@215
|
1338 update_wan_db()
|
gokhlayeh@215
|
1339 {
|
gokhlayeh@215
|
1340 local PACKAGE
|
gokhlayeh@215
|
1341 for RECEIPT in $(fgrep WANTED $WOK/*/receipt | \
|
gokhlayeh@215
|
1342 fgrep $PACKAGE | cut -f1 -d ':'); do
|
gokhlayeh@215
|
1343 WANTED=
|
gokhlayeh@215
|
1344 source $RECEIPT
|
gokhlayeh@215
|
1345 [ "$WANTED" ] || continue
|
gokhlayeh@219
|
1346 wan_info=$(echo -e $PACKAGE"\t"$WANTED)
|
gokhlayeh@215
|
1347 [ "$wan_info" = "$(grep -m1 ^$PACKAGE$'\t' $wan_db 2>/dev/null)" ] && return
|
gokhlayeh@215
|
1348 sed "/^$PACKAGE\t/d" -i $wan_db
|
gokhlayeh@220
|
1349 echo "$wan_info" >> $wan_db
|
gokhlayeh@215
|
1350 plan_regen_cookorder=yes
|
gokhlayeh@215
|
1351 plan_sort_wandb=yes
|
gokhlayeh@215
|
1352 done
|
gokhlayeh@215
|
1353 }
|
gokhlayeh@215
|
1354
|
gokhlayeh@204
|
1355 update_dep_db()
|
gokhlayeh@204
|
1356 {
|
gokhlayeh@204
|
1357 dep_info=$(echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ')
|
gokhlayeh@215
|
1358 [ "$dep_info" = "$(grep -m1 ^$PACKAGE$'\t' $dep_db 2>/dev/null)" ] && return
|
gokhlayeh@204
|
1359 sed "/^$PACKAGE\t/d" -i $dep_db
|
gokhlayeh@204
|
1360 echo "$dep_info" >> $dep_db
|
gokhlayeh@204
|
1361 plan_regen_cookorder=yes
|
gokhlayeh@204
|
1362 plan_sort_depdb=yes
|
pankso@28
|
1363 }
|
pankso@28
|
1364
|
gokhlayeh@186
|
1365 sort_db()
|
pascal@91
|
1366 {
|
gokhlayeh@186
|
1367 report step "Generating cookorder.txt"
|
gokhlayeh@186
|
1368 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
|
gokhlayeh@186
|
1369 grep -q ^$PACKAGE$'\t' $wan_db && continue
|
gokhlayeh@186
|
1370
|
gokhlayeh@186
|
1371 # Replace each BUILD_DEPENDS with a WANTED package by it's
|
gokhlayeh@186
|
1372 # WANTED package.
|
gokhlayeh@186
|
1373 replace_by_wanted()
|
gokhlayeh@186
|
1374 {
|
gokhlayeh@186
|
1375 for p in $BUILD_DEPENDS; do
|
gokhlayeh@186
|
1376 if grep -q ^$p$'\t' $wan_db; then
|
gokhlayeh@186
|
1377 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
|
gokhlayeh@186
|
1378 else
|
gokhlayeh@186
|
1379 echo -n $p' '
|
gokhlayeh@186
|
1380 fi
|
gokhlayeh@186
|
1381 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
|
gokhlayeh@186
|
1382 }
|
gokhlayeh@186
|
1383 echo -e $PACKAGE"\t $(replace_by_wanted) "
|
gokhlayeh@186
|
1384 done > $tmp/db
|
gokhlayeh@186
|
1385 while [ -s "$tmp/db" ]; do
|
gokhlayeh@186
|
1386 status=start
|
gokhlayeh@186
|
1387 for pkg in $(cut -f 1 $tmp/db); do
|
gokhlayeh@195
|
1388 if ! fgrep -q ' '$pkg' ' $tmp/db; then
|
gokhlayeh@186
|
1389 echo $pkg >> $tmp/cookorder
|
gokhlayeh@186
|
1390 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
|
gokhlayeh@186
|
1391 status=proceed
|
gokhlayeh@186
|
1392 fi
|
gokhlayeh@186
|
1393 done
|
gokhlayeh@186
|
1394 if [ "$status" = start ]; then
|
gokhlayeh@186
|
1395 cp -f $tmp/db /tmp/remain-depends.txt
|
gokhlayeh@186
|
1396 echo "Can't go further because there's depency(ies) loop(s). The remaining packages will be commentend in the cookorder and will be unbuild in case of major update until the problem is solved." >&2
|
gokhlayeh@186
|
1397 for blocked in $(cut -f 1 $tmp/db); do
|
gokhlayeh@186
|
1398 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
|
gokhlayeh@186
|
1399 done
|
gokhlayeh@186
|
1400 break
|
gokhlayeh@186
|
1401 fi
|
gokhlayeh@186
|
1402 done
|
gokhlayeh@186
|
1403 [ -s $tmp/cookorder ] || touch $tmp/cookorder
|
gokhlayeh@186
|
1404
|
gokhlayeh@186
|
1405 # The toolchain packages are moved in first position.
|
gokhlayeh@186
|
1406 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
|
gokhlayeh@186
|
1407 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
|
gokhlayeh@186
|
1408 $tmp/cookorder | tac > $PACKAGES_REPOSITORY/cookorder.txt
|
gokhlayeh@186
|
1409 for pkg in $(cat $PACKAGES_REPOSITORY/cookorder.txt); do
|
gokhlayeh@186
|
1410 sed "/^$pkg$/d" -i $tmp/cookorder
|
gokhlayeh@186
|
1411 done
|
gokhlayeh@186
|
1412
|
gokhlayeh@186
|
1413 tac $tmp/cookorder >> $PACKAGES_REPOSITORY/cookorder.txt
|
gokhlayeh@204
|
1414 unset plan_regen_cookorder
|
gokhlayeh@186
|
1415 report end-step
|
pascal@91
|
1416 }
|
pascal@91
|
1417
|
gokhlayeh@186
|
1418 ########################################################################
|
gokhlayeh@186
|
1419 # SCAN CORE
|
gokhlayeh@186
|
1420 ########################
|
gokhlayeh@186
|
1421 # Include various scan core-functions. It's not intended to be used
|
gokhlayeh@186
|
1422 # directly : prefer scan wrappers in next section.
|
gokhlayeh@186
|
1423
|
gokhlayeh@186
|
1424 look_for_dep()
|
gokhlayeh@186
|
1425 {
|
gokhlayeh@186
|
1426 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
|
gokhlayeh@240
|
1427 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
|
gokhlayeh@186
|
1428 | cut -f 2
|
gokhlayeh@186
|
1429 else
|
gokhlayeh@186
|
1430 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
|
gokhlayeh@186
|
1431 cut -f 2
|
gokhlayeh@186
|
1432 fi
|
gokhlayeh@186
|
1433 }
|
gokhlayeh@186
|
1434
|
gokhlayeh@186
|
1435 look_for_bdep()
|
gokhlayeh@186
|
1436 {
|
gokhlayeh@186
|
1437 look_for_all
|
gokhlayeh@186
|
1438 }
|
gokhlayeh@186
|
1439
|
gokhlayeh@186
|
1440 look_for_all()
|
gokhlayeh@186
|
1441 {
|
gokhlayeh@186
|
1442 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
|
gokhlayeh@240
|
1443 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
|
gokhlayeh@186
|
1444 | cut -f 2,3 | sed 's/ / /'
|
gokhlayeh@186
|
1445 else
|
gokhlayeh@186
|
1446 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
|
gokhlayeh@186
|
1447 cut -f 2,3 | sed 's/ / /'
|
gokhlayeh@186
|
1448 fi
|
gokhlayeh@186
|
1449 }
|
gokhlayeh@186
|
1450
|
gokhlayeh@186
|
1451 look_for_rdep()
|
gokhlayeh@186
|
1452 {
|
gokhlayeh@195
|
1453 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
|
gokhlayeh@186
|
1454 if [ "$undigest" ]; then
|
gokhlayeh@240
|
1455 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt | cut -f 1); do
|
gokhlayeh@186
|
1456 if [ ! -f "WOK$/$rdep/receipt" ]; then
|
gokhlayeh@186
|
1457 echo "$rdep"
|
gokhlayeh@186
|
1458 fi
|
gokhlayeh@186
|
1459 done
|
gokhlayeh@186
|
1460 fi
|
gokhlayeh@186
|
1461 }
|
gokhlayeh@186
|
1462
|
gokhlayeh@186
|
1463 look_for_rbdep()
|
gokhlayeh@186
|
1464 {
|
gokhlayeh@195
|
1465 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
|
gokhlayeh@195
|
1466 cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
|
gokhlayeh@186
|
1467 if [ "$undigest" ]; then
|
gokhlayeh@240
|
1468 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
|
gokhlayeh@195
|
1469 | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
|
gokhlayeh@186
|
1470 if [ ! -f "WOK$/$rdep/receipt" ]; then
|
gokhlayeh@186
|
1471 echo "$rdep"
|
gokhlayeh@186
|
1472 fi
|
gokhlayeh@186
|
1473 done
|
gokhlayeh@186
|
1474 fi
|
gokhlayeh@186
|
1475 }
|
gokhlayeh@186
|
1476
|
gokhlayeh@186
|
1477 # Return WANTED if it exists.
|
gokhlayeh@186
|
1478 look_for_wanted()
|
gokhlayeh@186
|
1479 {
|
gokhlayeh@186
|
1480 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
|
gokhlayeh@240
|
1481 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-wanted.txt | cut -f 2
|
gokhlayeh@186
|
1482 else
|
gokhlayeh@186
|
1483 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 2
|
gokhlayeh@186
|
1484 fi
|
gokhlayeh@186
|
1485 }
|
gokhlayeh@186
|
1486
|
gokhlayeh@186
|
1487 # Return packages which wants PACKAGE.
|
gokhlayeh@186
|
1488 look_for_rwanted()
|
gokhlayeh@186
|
1489 {
|
gokhlayeh@186
|
1490 grep $'\t'$PACKAGE$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1
|
gokhlayeh@186
|
1491 if [ "$undigest" ]; then
|
gokhlayeh@240
|
1492 for rwanted in $(grep $'\t'$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-wanted.txt | cut -f 1); do
|
gokhlayeh@186
|
1493 if [ ! -f "$WOK/$rwanted/receipt" ]; then
|
gokhlayeh@186
|
1494 echo "$rwanted"
|
gokhlayeh@186
|
1495 fi
|
gokhlayeh@186
|
1496 done
|
gokhlayeh@186
|
1497 fi
|
gokhlayeh@186
|
1498 }
|
gokhlayeh@186
|
1499
|
gokhlayeh@186
|
1500 look_for_dev()
|
gokhlayeh@186
|
1501 {
|
gokhlayeh@223
|
1502 WANTED=$(look_for_wanted)
|
gokhlayeh@223
|
1503 if [ "$WANTED" ]; then
|
gokhlayeh@223
|
1504 if [ "$undigest" ] && [ ! -f "$WOK/$WANTED/receipt" ]; then
|
gokhlayeh@223
|
1505 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$WANTED-dev/receipt" ] && echo $WANTED-dev
|
gokhlayeh@223
|
1506 else
|
gokhlayeh@223
|
1507 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
|
gokhlayeh@223
|
1508 fi
|
gokhlayeh@223
|
1509 fi
|
gokhlayeh@223
|
1510 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
|
gokhlayeh@223
|
1511 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
|
gokhlayeh@223
|
1512 else
|
gokhlayeh@223
|
1513 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
|
gokhlayeh@223
|
1514 fi
|
gokhlayeh@186
|
1515 }
|
gokhlayeh@186
|
1516
|
gokhlayeh@215
|
1517 with_dev()
|
gokhlayeh@215
|
1518 {
|
gokhlayeh@215
|
1519 for PACKAGE in $(cat); do
|
gokhlayeh@215
|
1520 echo $PACKAGE
|
gokhlayeh@215
|
1521 look_for_dev
|
gokhlayeh@215
|
1522 done
|
gokhlayeh@215
|
1523 }
|
gokhlayeh@215
|
1524
|
gokhlayeh@215
|
1525 with_wanted()
|
gokhlayeh@215
|
1526 {
|
gokhlayeh@215
|
1527 for PACKAGE in $(cat); do
|
gokhlayeh@215
|
1528 echo $PACKAGE
|
gokhlayeh@215
|
1529 look_for_wanted
|
gokhlayeh@215
|
1530 done
|
gokhlayeh@215
|
1531 }
|
gokhlayeh@215
|
1532
|
gokhlayeh@215
|
1533 use_wanted()
|
gokhlayeh@215
|
1534 {
|
gokhlayeh@215
|
1535 for input in $(cat); do
|
gokhlayeh@215
|
1536 { grep ^$input$'\t' $wan_db || echo $input
|
gokhlayeh@215
|
1537 } | sed 's/.*\t//'
|
gokhlayeh@215
|
1538 done
|
gokhlayeh@215
|
1539 }
|
gokhlayeh@215
|
1540
|
gokhlayeh@186
|
1541 ########################################################################
|
gokhlayeh@186
|
1542 # SCAN
|
gokhlayeh@186
|
1543 ########################
|
gokhlayeh@186
|
1544 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
|
gokhlayeh@186
|
1545 # Option in command line (must be first arg) :
|
gokhlayeh@186
|
1546 # --look_for=bdep/rbdep - Look for depends or reverse depends.
|
gokhlayeh@186
|
1547 # --with_dev - Add development packages (*-dev) in the result.
|
gokhlayeh@186
|
1548 # --with_wanted - Add package+reverse wanted in the result.
|
gokhlayeh@186
|
1549 # --with_args - Include packages in argument in the result.
|
gokhlayeh@186
|
1550
|
gokhlayeh@186
|
1551 scan()
|
gokhlayeh@186
|
1552 {
|
gokhlayeh@186
|
1553 # Get packages in argument.
|
gokhlayeh@223
|
1554 local PACKAGE WANTED pkg_list=
|
gokhlayeh@186
|
1555 for arg in $@; do
|
gokhlayeh@186
|
1556 [ "$arg" = "${arg#--}" ] || continue
|
gokhlayeh@186
|
1557 pkg_list="$pkg_list $arg"
|
gokhlayeh@186
|
1558 done
|
gokhlayeh@204
|
1559
|
gokhlayeh@186
|
1560 # Get options.
|
gokhlayeh@186
|
1561 [ "$pkg_list" ] || return
|
gokhlayeh@186
|
1562 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
|
gokhlayeh@215
|
1563 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
|
gokhlayeh@186
|
1564 get_options
|
gokhlayeh@186
|
1565
|
gokhlayeh@186
|
1566 # Cooklist is a special case where we need to modify a little
|
gokhlayeh@186
|
1567 # scan behavior
|
gokhlayeh@186
|
1568 if [ "$cooklist" ]; then
|
gokhlayeh@204
|
1569 gen_wan_db
|
gokhlayeh@204
|
1570 look_for=all && with_args=yes && with_dev= && with_wanted=
|
gokhlayeh@204
|
1571 filter=use_wanted
|
gokhlayeh@241
|
1572 if [ "$COMMAND" = gen-cooklist ]; then
|
gokhlayeh@241
|
1573 for PACKAGE in $pkg_list; do
|
gokhlayeh@241
|
1574 grep -q ^$PACKAGE$'\t' $dep_db && continue
|
gokhlayeh@241
|
1575 [ -d "$WOK/$p" ] || continue
|
gokhlayeh@241
|
1576 check_for_missing
|
gokhlayeh@241
|
1577 done
|
gokhlayeh@241
|
1578 append_to_dep()
|
gokhlayeh@241
|
1579 {
|
gokhlayeh@241
|
1580 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
|
gokhlayeh@241
|
1581 check_for_missing && echo $PACKAGE >> $tmp/dep
|
gokhlayeh@241
|
1582 else
|
gokhlayeh@241
|
1583 echo $PACKAGE >> $tmp/dep
|
gokhlayeh@241
|
1584 fi
|
gokhlayeh@241
|
1585 }
|
gokhlayeh@241
|
1586 else
|
gokhlayeh@241
|
1587 append_to_dep()
|
gokhlayeh@241
|
1588 {
|
gokhlayeh@241
|
1589 check_for_commit && echo $PACKAGE >> $tmp/dep
|
gokhlayeh@241
|
1590 }
|
gokhlayeh@241
|
1591 fi
|
gokhlayeh@204
|
1592 else
|
gokhlayeh@204
|
1593 append_to_dep()
|
gokhlayeh@204
|
1594 {
|
gokhlayeh@204
|
1595 echo $PACKAGE >> $tmp/dep
|
gokhlayeh@204
|
1596 }
|
gokhlayeh@240
|
1597 # If requested packages are not in dep_db, partial generation of this db is needed.
|
gokhlayeh@241
|
1598 for PACKAGE in $pkg_list; do
|
gokhlayeh@241
|
1599 grep -q ^$PACKAGE$'\t' $dep_db && continue
|
gokhlayeh@240
|
1600 [ -d "$WOK/$p" ] || continue
|
gokhlayeh@240
|
1601 plan_check_for_missing=yes
|
gokhlayeh@240
|
1602 check_for_missing
|
gokhlayeh@240
|
1603 done
|
gokhlayeh@240
|
1604 if [ "$plan_check_for_missing" ]; then
|
gokhlayeh@240
|
1605 append_to_dep()
|
gokhlayeh@240
|
1606 {
|
gokhlayeh@240
|
1607 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
|
gokhlayeh@240
|
1608 check_for_missing && echo $PACKAGE >> $tmp/dep
|
gokhlayeh@240
|
1609 else
|
gokhlayeh@240
|
1610 echo $PACKAGE >> $tmp/dep
|
gokhlayeh@240
|
1611 fi
|
gokhlayeh@240
|
1612 }
|
gokhlayeh@240
|
1613 check_db_status=yes
|
gokhlayeh@240
|
1614 unset plan_check_for_missing
|
gokhlayeh@240
|
1615 fi
|
gokhlayeh@186
|
1616 fi
|
gokhlayeh@215
|
1617
|
gokhlayeh@204
|
1618 [ "$with_dev" ] && filter=with_dev
|
gokhlayeh@204
|
1619 [ "$with_wanted" ] && filter=with_wanted
|
gokhlayeh@204
|
1620 if [ "$filter" ]; then
|
gokhlayeh@204
|
1621 pkg_list=$(echo $pkg_list | $filter)
|
gokhlayeh@204
|
1622 scan_pkg()
|
gokhlayeh@204
|
1623 {
|
gokhlayeh@204
|
1624 look_for_$look_for | $filter
|
gokhlayeh@204
|
1625 }
|
gokhlayeh@204
|
1626 else
|
gokhlayeh@204
|
1627 scan_pkg()
|
gokhlayeh@204
|
1628 {
|
gokhlayeh@204
|
1629 look_for_$look_for
|
gokhlayeh@204
|
1630 }
|
gokhlayeh@204
|
1631 fi
|
gokhlayeh@215
|
1632 touch $tmp/dep
|
gokhlayeh@204
|
1633 for PACKAGE in $pkg_list; do
|
gokhlayeh@204
|
1634 [ "$with_args" ] && append_to_dep
|
gokhlayeh@204
|
1635 scan_pkg
|
gokhlayeh@186
|
1636 done | tr ' ' '\n' | sort -u > $tmp/list
|
gokhlayeh@186
|
1637 [ "$look_for" = bdep ] && look_for=dep
|
gokhlayeh@186
|
1638 while [ -s $tmp/list ]; do
|
gokhlayeh@186
|
1639 PACKAGE=$(sed 1!d $tmp/list)
|
gokhlayeh@186
|
1640 sed 1d -i $tmp/list
|
gokhlayeh@204
|
1641 append_to_dep
|
gokhlayeh@204
|
1642 for pkg in $(scan_pkg); do
|
gokhlayeh@204
|
1643 if ! grep -q ^$pkg$ $tmp/list $tmp/dep; then
|
gokhlayeh@204
|
1644 echo $pkg >> $tmp/list
|
gokhlayeh@186
|
1645 fi
|
gokhlayeh@186
|
1646 done
|
gokhlayeh@186
|
1647 done
|
gokhlayeh@204
|
1648 if [ "$cooklist" ]; then
|
gokhlayeh@204
|
1649 mv $tmp/dep $tmp/cooklist
|
gokhlayeh@215
|
1650 else
|
gokhlayeh@204
|
1651 cat $tmp/dep | sort -u
|
gokhlayeh@186
|
1652 fi
|
gokhlayeh@204
|
1653 rm -f $tmp/dep $tmp/list
|
gokhlayeh@240
|
1654 if [ "$check_db_status" ]; then
|
gokhlayeh@240
|
1655 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
|
gokhlayeh@240
|
1656 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
|
gokhlayeh@240
|
1657 if [ "$plan_regen_cookorder" ]; then
|
gokhlayeh@240
|
1658 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
|
gokhlayeh@240
|
1659 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
|
gokhlayeh@240
|
1660 fi
|
gokhlayeh@240
|
1661 fi
|
gokhlayeh@186
|
1662 }
|
gokhlayeh@186
|
1663
|
gokhlayeh@186
|
1664 ########################################################################
|
gokhlayeh@186
|
1665 # This section contains functions to check package repository and
|
gokhlayeh@186
|
1666 # find which packages to cook.
|
gokhlayeh@186
|
1667 ########################
|
gokhlayeh@186
|
1668
|
gokhlayeh@240
|
1669 check_for_missing()
|
gokhlayeh@240
|
1670 {
|
gokhlayeh@240
|
1671 local PACKAGE
|
gokhlayeh@240
|
1672 if ! check_for_pkg_in_wok; then
|
gokhlayeh@240
|
1673 [ "$?" = 2 ] && return 1
|
gokhlayeh@240
|
1674 return
|
gokhlayeh@240
|
1675 fi
|
gokhlayeh@241
|
1676 RECEIPT=$WOK/$PACKAGE/receipt
|
gokhlayeh@240
|
1677 source_receipt
|
gokhlayeh@240
|
1678 PACKAGE=${WANTED:-$PACKAGE}
|
gokhlayeh@240
|
1679 update_wan_db
|
gokhlayeh@240
|
1680 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
|
gokhlayeh@240
|
1681 RECEIPT=$WOK/$PACKAGE/receipt
|
gokhlayeh@240
|
1682 source_receipt
|
gokhlayeh@240
|
1683 update_dep_db
|
gokhlayeh@240
|
1684 done
|
gokhlayeh@240
|
1685 }
|
gokhlayeh@240
|
1686
|
gokhlayeh@186
|
1687 check_for_commit()
|
gokhlayeh@186
|
1688 {
|
gokhlayeh@204
|
1689 if ! check_for_pkg_in_wok; then
|
gokhlayeh@204
|
1690 [ "$?" = 2 ] && return 1
|
gokhlayeh@204
|
1691 return
|
gokhlayeh@204
|
1692 fi
|
gokhlayeh@204
|
1693 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
|
gokhlayeh@204
|
1694 RECEIPT=$WOK/$PACKAGE/receipt
|
gokhlayeh@186
|
1695 source_receipt
|
gokhlayeh@204
|
1696
|
gokhlayeh@186
|
1697 # We use md5 of cooking stuff in the packaged receipt to check
|
gokhlayeh@186
|
1698 # commit. We look consecutively in 3 different locations :
|
gokhlayeh@204
|
1699 # - in the wok/PACKAGE/taz/* folder
|
gokhlayeh@186
|
1700 # - in the receipt in the package in incoming repository
|
gokhlayeh@186
|
1701 # - in the receipt in the package in packages repository
|
gokhlayeh@186
|
1702 # If md5sum match, there's no commit.
|
gokhlayeh@186
|
1703 check_for_commit_using_md5sum()
|
gokhlayeh@186
|
1704 {
|
gokhlayeh@186
|
1705 if [ ! -f $WOK/$PACKAGE/md5 ]; then
|
gokhlayeh@186
|
1706 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
|
gokhlayeh@186
|
1707 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
|
gokhlayeh@186
|
1708 cd $WOK/$PACKAGE
|
gokhlayeh@186
|
1709 fi
|
gokhlayeh@204
|
1710
|
gokhlayeh@186
|
1711 if [ -s md5 ]; then
|
gokhlayeh@186
|
1712 if md5sum -cs md5; then
|
gokhlayeh@204
|
1713
|
gokhlayeh@204
|
1714 # If md5sum check if ok, check for new/missing files in
|
gokhlayeh@204
|
1715 # cooking stuff.
|
gokhlayeh@204
|
1716 for file in $([ -f receipt ] && echo receipt; \
|
gokhlayeh@204
|
1717 [ -f description.txt ] && echo description.txt; \
|
gokhlayeh@204
|
1718 [ -d stuff ] && find stuff); do
|
gokhlayeh@204
|
1719 if ! fgrep -q " $file" md5; then
|
gokhlayeh@186
|
1720 set_commited
|
gokhlayeh@186
|
1721 fi
|
gokhlayeh@186
|
1722 done
|
gokhlayeh@186
|
1723 else
|
gokhlayeh@186
|
1724 set_commited
|
gokhlayeh@186
|
1725 fi
|
gokhlayeh@186
|
1726 else
|
gokhlayeh@204
|
1727 set_commited
|
gokhlayeh@186
|
1728 fi
|
gokhlayeh@186
|
1729 }
|
gokhlayeh@186
|
1730 set_commited()
|
gokhlayeh@186
|
1731 {
|
gokhlayeh@204
|
1732 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
|
gokhlayeh@204
|
1733 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
|
gokhlayeh@186
|
1734 gen_cookmd5
|
gokhlayeh@204
|
1735 update_dep_db
|
gokhlayeh@186
|
1736 }
|
gokhlayeh@195
|
1737 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
|
gokhlayeh@186
|
1738 if [ -f $WOK/$PACKAGE/md5 ]; then
|
gokhlayeh@186
|
1739 cd $WOK/$PACKAGE
|
gokhlayeh@186
|
1740 check_for_commit_using_md5sum
|
gokhlayeh@186
|
1741 elif [ "$taz_dir" ]; then
|
gokhlayeh@186
|
1742 cd $taz_dir
|
gokhlayeh@186
|
1743 check_for_commit_using_md5sum
|
gokhlayeh@186
|
1744 else
|
gokhlayeh@195
|
1745 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
|
gokhlayeh@195
|
1746 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
|
gokhlayeh@186
|
1747 if [ "$pkg" ]; then
|
gokhlayeh@186
|
1748 get_pkg_files $pkg
|
gokhlayeh@186
|
1749 check_for_commit_using_md5sum
|
gokhlayeh@186
|
1750 rm -r $pkg_files_dir
|
gokhlayeh@204
|
1751 else
|
gokhlayeh@204
|
1752 set_commited
|
gokhlayeh@186
|
1753 fi
|
gokhlayeh@186
|
1754 fi
|
gokhlayeh@204
|
1755 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
|
gokhlayeh@186
|
1756 done
|
gokhlayeh@204
|
1757 return
|
gokhlayeh@186
|
1758 }
|
gokhlayeh@186
|
1759
|
gokhlayeh@186
|
1760 gen_cook_list()
|
gokhlayeh@186
|
1761 {
|
gokhlayeh@204
|
1762 report step "Scanning wok"
|
gokhlayeh@204
|
1763 if [ "$pkg" ]; then
|
gokhlayeh@204
|
1764 scan $pkg --cooklist
|
gokhlayeh@204
|
1765 else
|
gokhlayeh@204
|
1766 scan `cat $cooklist` --cooklist
|
gokhlayeh@204
|
1767 fi
|
gokhlayeh@204
|
1768 report end-step
|
gokhlayeh@209
|
1769
|
gokhlayeh@209
|
1770 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
|
gokhlayeh@209
|
1771
|
gokhlayeh@209
|
1772 # Core toolchain should not be cooked unless cook-toolchain is used.
|
gokhlayeh@209
|
1773 if ! [ -f /etc/config.site.tmptoolchain ] ; then
|
gokhlayeh@209
|
1774 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
|
gokhlayeh@209
|
1775 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \
|
gokhlayeh@209
|
1776 echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked
|
gokhlayeh@209
|
1777 done
|
gokhlayeh@209
|
1778 fi
|
gokhlayeh@209
|
1779
|
gokhlayeh@241
|
1780 if [ -s $PACKAGES_REPOSITORY/commit ] && [ "$COMMAND" != gen-cooklist ]; then
|
gokhlayeh@186
|
1781 cd $PACKAGES_REPOSITORY
|
gokhlayeh@186
|
1782 for PACKAGE in $(cat commit); do
|
gokhlayeh@186
|
1783 WANTED="$(look_for_wanted)"
|
gokhlayeh@186
|
1784 if [ "$WANTED" ]; then
|
gokhlayeh@204
|
1785 grep -q ^$WANTED$ broken cooklist blocked commit && continue
|
gokhlayeh@186
|
1786 fi
|
gokhlayeh@204
|
1787 grep -q ^$PACKAGE$ blocked cooklist && continue
|
gokhlayeh@204
|
1788 echo $PACKAGE >> cooklist
|
gokhlayeh@186
|
1789 done
|
gokhlayeh@186
|
1790 fi
|
gokhlayeh@186
|
1791 sort_cooklist
|
gokhlayeh@186
|
1792 }
|
gokhlayeh@186
|
1793
|
gokhlayeh@186
|
1794 sort_cooklist()
|
gokhlayeh@186
|
1795 {
|
gokhlayeh@266
|
1796 if [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" = "#PlanSort" ]; then
|
gokhlayeh@266
|
1797 sed 1d -i $PACKAGES_REPOSITORY/cookorder.txt
|
gokhlayeh@266
|
1798 plan_regen_cookorder=yes
|
gokhlayeh@266
|
1799 fi
|
gokhlayeh@266
|
1800 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
|
gokhlayeh@266
|
1801 [ "$plan_regen_cookorder" ] && sort_db
|
gokhlayeh@215
|
1802 report step "Sorting cooklist"
|
gokhlayeh@204
|
1803 if [ -f "$tmp/checked" ]; then
|
gokhlayeh@204
|
1804 rm -f $tmp/cooklist
|
gokhlayeh@204
|
1805 cat $tmp/checked | while read PACKAGE; do
|
gokhlayeh@204
|
1806 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/cooklist && \
|
gokhlayeh@204
|
1807 echo $PACKAGE >> $tmp/cooklist
|
gokhlayeh@204
|
1808 done
|
gokhlayeh@209
|
1809 elif ! [ "$COMMAND" = gen-cooklist ]; then
|
gokhlayeh@209
|
1810 cat $PACKAGES_REPOSITORY/blocked | while read PACKAGE; do
|
gokhlayeh@209
|
1811 sed "/^$PACKAGE/d" -i $tmp/cooklist
|
gokhlayeh@209
|
1812 done
|
gokhlayeh@204
|
1813 fi
|
gokhlayeh@215
|
1814
|
gokhlayeh@204
|
1815 for PACKAGE in $(cat $tmp/cooklist); do
|
gokhlayeh@204
|
1816 WANTED="$(look_for_wanted)"
|
gokhlayeh@204
|
1817 [ "$WANTED" ] || continue
|
gokhlayeh@215
|
1818 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist; then
|
gokhlayeh@186
|
1819 sed "/^$PACKAGE$/d" -i $tmp/cooklist
|
gokhlayeh@204
|
1820 elif [ ! -d $WOK/$WANTED/install ]; then
|
gokhlayeh@204
|
1821 sed "/^$PACKAGE$/d" -i $tmp/cooklist
|
gokhlayeh@204
|
1822 echo $WANTED >> $tmp/cooklist
|
gokhlayeh@186
|
1823 fi
|
gokhlayeh@186
|
1824 done
|
gokhlayeh@186
|
1825
|
gokhlayeh@204
|
1826 # Use cookorder.txt to sort cooklist.
|
gokhlayeh@204
|
1827 if [ -s $tmp/cooklist ]; then
|
gokhlayeh@204
|
1828 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
|
gokhlayeh@204
|
1829 if grep -q ^$PACKAGE$ $tmp/cooklist; then
|
gokhlayeh@204
|
1830 sed "/^$PACKAGE$/d" -i $tmp/cooklist
|
gokhlayeh@204
|
1831 echo $PACKAGE >> $tmp/cooklist.tmp
|
gokhlayeh@204
|
1832 fi
|
gokhlayeh@204
|
1833 done
|
gokhlayeh@204
|
1834
|
gokhlayeh@204
|
1835 # Remaining packages in cooklist are thoses without compile_rules.
|
gokhlayeh@204
|
1836 # They can be cooked first in any order.
|
gokhlayeh@204
|
1837 if [ -f $tmp/cooklist.tmp ]; then
|
gokhlayeh@204
|
1838 cat $tmp/cooklist.tmp >> $tmp/cooklist
|
gokhlayeh@204
|
1839 rm $tmp/cooklist.tmp
|
gokhlayeh@204
|
1840 fi
|
gokhlayeh@204
|
1841
|
gokhlayeh@204
|
1842 cat $tmp/cooklist
|
gokhlayeh@204
|
1843 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
|
gokhlayeh@204
|
1844 cat $tmp/cooklist > $cooklist
|
gokhlayeh@204
|
1845 fi
|
gokhlayeh@204
|
1846
|
gokhlayeh@186
|
1847 report end-step
|
gokhlayeh@186
|
1848 }
|
gokhlayeh@186
|
1849
|
gokhlayeh@186
|
1850 check_for_incoming()
|
gokhlayeh@186
|
1851 {
|
gokhlayeh@204
|
1852 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
|
gokhlayeh@204
|
1853 echo "No packages in $INCOMING_REPOSITORY."
|
gokhlayeh@204
|
1854 return; }
|
gokhlayeh@204
|
1855 if [ -s $PACKAGES_REPOSITORY/broken ]; then
|
gokhlayeh@204
|
1856 echo "Don't move incoming packages to main repository because theses ones are broken:
|
gokhlayeh@204
|
1857 $(cat $PACKAGES_REPOSITORY/broken)" >&2
|
gokhlayeh@204
|
1858 return
|
gokhlayeh@186
|
1859 fi
|
gokhlayeh@204
|
1860 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
|
gokhlayeh@204
|
1861 echo "Don't move incoming packages to main repository because some of them need to be cooked:
|
gokhlayeh@204
|
1862 $(cat $PACKAGES_REPOSITORY/cooklist)" >&2
|
gokhlayeh@204
|
1863 return
|
gokhlayeh@204
|
1864 fi
|
gokhlayeh@215
|
1865 pkg="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
|
gokhlayeh@214
|
1866 if ! [ "$forced" ]; then
|
gokhlayeh@214
|
1867 cooklist=$PACKAGES_REPOSITORY/cooklist
|
gokhlayeh@214
|
1868 gen_cook_list
|
gokhlayeh@214
|
1869 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
|
gokhlayeh@214
|
1870 echo "Don't move incoming packages to main repository because some of them need to be cooked." >&2
|
gokhlayeh@214
|
1871 return
|
gokhlayeh@214
|
1872 fi
|
gokhlayeh@204
|
1873 fi
|
gokhlayeh@204
|
1874 report step "Moving incoming packages to main repository"
|
gokhlayeh@204
|
1875 unset EXTRAVERSION
|
gokhlayeh@215
|
1876 for PACKAGE in $pkg; do
|
gokhlayeh@186
|
1877 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
|
gokhlayeh@204
|
1878 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
|
gokhlayeh@186
|
1879 remove_previous_package $PACKAGES_REPOSITORY
|
gokhlayeh@204
|
1880 echo "Moving $PACKAGE..."
|
gokhlayeh@204
|
1881 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
|
gokhlayeh@204
|
1882 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
|
gokhlayeh@266
|
1883 previous_tarball=$(grep ^$PACKAGE:main $SOURCES_REPOSITORY/sources.list | cut -f2)
|
gokhlayeh@266
|
1884 sed -e "/^$PACKAGE:main/d" \
|
gokhlayeh@266
|
1885 -e "s/^$PACKAGE:incoming/$PACKAGE:main/"
|
gokhlayeh@266
|
1886 -i $SOURCES_REPOSITORY/sources.list
|
gokhlayeh@266
|
1887 if [ "$previous_tarball" ]; then
|
gokhlayeh@266
|
1888 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
|
gokhlayeh@266
|
1889 rm -f $SOURCES_REPOSITORY/$previous_tarball
|
gokhlayeh@266
|
1890 fi
|
gokhlayeh@204
|
1891 done
|
gokhlayeh@204
|
1892 report end-step
|
gokhlayeh@204
|
1893 for file in packages.list packages.equiv packages.md5 packages.desc \
|
gokhlayeh@204
|
1894 packages.txt; do
|
gokhlayeh@204
|
1895 echo -n "" > $INCOMING_REPOSITORY/$file
|
gokhlayeh@204
|
1896 done
|
gokhlayeh@204
|
1897 rm -r $INCOMING_REPOSITORY/files.list.lzma
|
gokhlayeh@186
|
1898 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
|
gokhlayeh@186
|
1899 }
|
gokhlayeh@186
|
1900
|
gokhlayeh@186
|
1901 ########################################################################
|
gokhlayeh@186
|
1902 # TAZWOK MAIN FUNCTIONS
|
gokhlayeh@186
|
1903 ########################
|
gokhlayeh@186
|
1904
|
gokhlayeh@186
|
1905 clean()
|
gokhlayeh@186
|
1906 {
|
gokhlayeh@186
|
1907 cd $WOK/$PACKAGE
|
gokhlayeh@186
|
1908 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
|
gokhlayeh@186
|
1909 -e ^stuff$ || return
|
gokhlayeh@186
|
1910
|
gokhlayeh@249
|
1911 [ "$COMMAND" = clean-wok ] || report step "Cleaning $PACKAGE"
|
gokhlayeh@186
|
1912 # Check for clean_wok function.
|
gokhlayeh@186
|
1913 if grep -q ^clean_wok $RECEIPT; then
|
gokhlayeh@186
|
1914 clean_wok
|
gokhlayeh@186
|
1915 fi
|
gokhlayeh@186
|
1916 # Clean should only have a receipt, stuff and optional desc.
|
gokhlayeh@186
|
1917 for f in `ls .`
|
gokhlayeh@186
|
1918 do
|
gokhlayeh@186
|
1919 case $f in
|
gokhlayeh@250
|
1920 receipt|stuff|description.txt|md5)
|
gokhlayeh@186
|
1921 continue ;;
|
gokhlayeh@186
|
1922 *)
|
gokhlayeh@263
|
1923 rm -rf $f ;;
|
gokhlayeh@186
|
1924 esac
|
gokhlayeh@186
|
1925 done
|
gokhlayeh@262
|
1926 [ "$COMMAND" != clean-wok ] && report end-step
|
gokhlayeh@186
|
1927 }
|
gokhlayeh@186
|
1928
|
gokhlayeh@186
|
1929 # Configure and make a package with the receipt.
|
gokhlayeh@186
|
1930 compile_package()
|
gokhlayeh@186
|
1931 {
|
gokhlayeh@186
|
1932 check_for_package_on_cmdline
|
gokhlayeh@186
|
1933
|
gokhlayeh@186
|
1934 # Include the receipt to get all needed variables and functions
|
gokhlayeh@186
|
1935 # and cd into the work directory to start the work.
|
gokhlayeh@186
|
1936 check_for_receipt
|
gokhlayeh@186
|
1937 source_receipt
|
gokhlayeh@186
|
1938
|
gokhlayeh@186
|
1939 # Log the package name and date.
|
gokhlayeh@186
|
1940 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
|
gokhlayeh@186
|
1941 echo "package $PACKAGE (compile)" >> $LOG
|
gokhlayeh@186
|
1942
|
gokhlayeh@186
|
1943 # Set wanted $src variable to help compiling.
|
gokhlayeh@186
|
1944 [ ! "$src" ] && set_src_path
|
gokhlayeh@186
|
1945 check_for_build_depends || return 1
|
gokhlayeh@186
|
1946 check_for_wanted
|
gokhlayeh@186
|
1947 unset target
|
gokhlayeh@186
|
1948 check_for_tarball && check_for_compile_rules
|
gokhlayeh@186
|
1949 }
|
gokhlayeh@186
|
1950
|
gokhlayeh@186
|
1951 # Cook command also include all features to manage lists which keep
|
gokhlayeh@186
|
1952 # track of wok/packages state.
|
gokhlayeh@186
|
1953 cook()
|
gokhlayeh@186
|
1954 {
|
gokhlayeh@186
|
1955 cook_code=
|
gokhlayeh@186
|
1956 set_common_path
|
gokhlayeh@186
|
1957 check_for_receipt
|
gokhlayeh@186
|
1958 source_receipt
|
gokhlayeh@186
|
1959
|
gokhlayeh@186
|
1960 # Define log path and start report.
|
gokhlayeh@186
|
1961 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
|
gokhlayeh@186
|
1962 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
|
gokhlayeh@186
|
1963 report step "Cooking $PACKAGE"
|
gokhlayeh@186
|
1964 report open-bloc
|
gokhlayeh@186
|
1965
|
gokhlayeh@186
|
1966 clean $PACKAGE
|
gokhlayeh@186
|
1967 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
|
gokhlayeh@186
|
1968
|
gokhlayeh@186
|
1969 if compile_package; then
|
gokhlayeh@215
|
1970 remove_src
|
gokhlayeh@186
|
1971 refresh_packages_from_compile
|
gokhlayeh@186
|
1972 gen_package
|
gokhlayeh@186
|
1973
|
gokhlayeh@186
|
1974 # Update packages-incoming repository.
|
gokhlayeh@186
|
1975 store_pkgname=$PACKAGE
|
gokhlayeh@186
|
1976 pkg_repository=$INCOMING_REPOSITORY
|
gokhlayeh@186
|
1977 update_packages_db
|
gokhlayeh@186
|
1978
|
gokhlayeh@186
|
1979 PACKAGE=$store_pkgname
|
gokhlayeh@186
|
1980 unset store_pkgname
|
gokhlayeh@186
|
1981
|
gokhlayeh@186
|
1982 # Upgrade to cooked packages if it was previously installed.
|
gokhlayeh@186
|
1983 report step "Look for package(s) to upgrade"
|
gokhlayeh@186
|
1984 for pkg in $(look_for_rwanted) $PACKAGE; do
|
gokhlayeh@186
|
1985 if [ -d $INSTALLED/$pkg ]; then
|
gokhlayeh@186
|
1986 tazpkg get-install $pkg --forced
|
gokhlayeh@186
|
1987 fi
|
gokhlayeh@186
|
1988 done
|
gokhlayeh@186
|
1989 report end-step
|
gokhlayeh@186
|
1990 else
|
gokhlayeh@186
|
1991
|
gokhlayeh@186
|
1992 # Set package as broken.
|
gokhlayeh@186
|
1993 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
|
gokhlayeh@186
|
1994 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
|
gokhlayeh@186
|
1995 fi
|
gokhlayeh@186
|
1996 gen_cookmd5
|
gokhlayeh@186
|
1997 cook_code=1
|
gokhlayeh@186
|
1998 fi
|
gokhlayeh@186
|
1999
|
gokhlayeh@186
|
2000 # Remove build_depends in cook mode (if in cooklist, it's done when
|
gokhlayeh@186
|
2001 # checking build_depends of next package and we remove only unneeded
|
gokhlayeh@186
|
2002 # packages to keep chroot minimal and gain some time).
|
gokhlayeh@210
|
2003 if [ "$COMMAND" = cook ]; then
|
gokhlayeh@210
|
2004 remove_build_depends $MISSING_PACKAGE
|
gokhlayeh@210
|
2005 [ -x /usr/bin/clean-chroot ] && clean-chroot
|
gokhlayeh@210
|
2006 fi
|
gokhlayeh@210
|
2007
|
gokhlayeh@186
|
2008 # Regen the cooklist if it was planned and command is not cook.
|
gokhlayeh@186
|
2009 [ "$regen_cooklist" ] && unset regen_cooklist && \
|
gokhlayeh@186
|
2010 [ "$COMMAND" != cook ] && sort_cooklist
|
gokhlayeh@186
|
2011
|
gokhlayeh@186
|
2012 # Some hacks to set the bloc & function status as failed if cook was
|
gokhlayeh@186
|
2013 # failed.
|
gokhlayeh@186
|
2014 report_return_code=$cook_code
|
gokhlayeh@186
|
2015 report close-bloc
|
gokhlayeh@186
|
2016 report end-sublog
|
gokhlayeh@186
|
2017 return $cook_code
|
gokhlayeh@186
|
2018 }
|
gokhlayeh@186
|
2019
|
gokhlayeh@186
|
2020 cook_list()
|
gokhlayeh@186
|
2021 {
|
gokhlayeh@204
|
2022 if [ -s $tmp/cooklist ]; then
|
gokhlayeh@204
|
2023 if [ -f /usr/bin/tazchroot ]; then
|
gokhlayeh@204
|
2024 # Note : options -main variables- are automatically keeped by
|
gokhlayeh@204
|
2025 # the sub-applications tazchroot/tazwok; as well as report data.
|
gokhlayeh@204
|
2026 cd $LOCAL_REPOSITORY
|
gokhlayeh@204
|
2027 [ ! -f tazchroot.conf ] && configure_tazchroot
|
gokhlayeh@204
|
2028 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
|
gokhlayeh@204
|
2029 return
|
gokhlayeh@204
|
2030 fi
|
gokhlayeh@204
|
2031 while [ -s $tmp/cooklist ]; do
|
gokhlayeh@204
|
2032 PACKAGE=$(sed 1!d $tmp/cooklist)
|
gokhlayeh@204
|
2033 cook
|
gokhlayeh@204
|
2034 done
|
gokhlayeh@204
|
2035 remove_build_depends $MISSING_PACKAGE $remove_later
|
gokhlayeh@210
|
2036 [ -x /usr/bin/clean-chroot ] && clean-chroot
|
gokhlayeh@204
|
2037 else
|
gokhlayeh@186
|
2038 echo "Nothing to cook."
|
gokhlayeh@186
|
2039 return
|
gokhlayeh@186
|
2040 fi
|
gokhlayeh@186
|
2041 }
|
gokhlayeh@186
|
2042
|
gokhlayeh@186
|
2043 configure_tazchroot()
|
gokhlayeh@186
|
2044 {
|
gokhlayeh@190
|
2045 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
|
gokhlayeh@186
|
2046 # Tazchroot configuration file - created by tazwok.
|
gokhlayeh@186
|
2047
|
gokhlayeh@186
|
2048 # Default chroot path
|
gokhlayeh@186
|
2049 SLITAZ_DIR=$SLITAZ_DIR
|
gokhlayeh@186
|
2050 SLITAZ_VERSION=$SLITAZ_VERSION
|
gokhlayeh@186
|
2051 $( [ "$undigest" ] && echo "undigest=$undigest" )
|
gokhlayeh@186
|
2052 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
|
gokhlayeh@186
|
2053 chroot_dir=\$LOCAL_REPOSITORY/chroot
|
gokhlayeh@186
|
2054
|
gokhlayeh@186
|
2055 # Default scripts path (theses scripts are added in the
|
gokhlayeh@186
|
2056 # $chroot_dir/usr/bin and can be called with tazchroot script)
|
gokhlayeh@186
|
2057 script_dir=/var/lib/tazchroot
|
gokhlayeh@186
|
2058
|
gokhlayeh@186
|
2059 # List of directories to mount.
|
gokhlayeh@192
|
2060 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do echo $LOCAL_REPOSITORY/$dir; done)
|
gokhlayeh@186
|
2061 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
|
gokhlayeh@186
|
2062
|
gokhlayeh@186
|
2063 create_chroot()
|
gokhlayeh@186
|
2064 {
|
gokhlayeh@186
|
2065 mkdir -p \$chroot_dir
|
gokhlayeh@186
|
2066 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
|
gokhlayeh@186
|
2067 tazpkg get-install \$pkg --root="\$chroot_dir"
|
gokhlayeh@186
|
2068 done
|
gokhlayeh@186
|
2069
|
gokhlayeh@186
|
2070 # Store list of installed packages needed by cleanchroot.
|
gokhlayeh@194
|
2071 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
|
gokhlayeh@186
|
2072
|
gokhlayeh@186
|
2073 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
|
gokhlayeh@186
|
2074 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
|
gokhlayeh@186
|
2075 -i \$chroot_dir/etc/slitaz/slitaz.conf
|
gokhlayeh@186
|
2076 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
|
gokhlayeh@186
|
2077 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
|
gokhlayeh@186
|
2078 }
|
gokhlayeh@186
|
2079
|
gokhlayeh@186
|
2080 mount_chroot()
|
gokhlayeh@186
|
2081 {
|
gokhlayeh@186
|
2082 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
|
gokhlayeh@194
|
2083 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
|
gokhlayeh@194
|
2084 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
|
gokhlayeh@194
|
2085 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
|
gokhlayeh@194
|
2086 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
|
gokhlayeh@194
|
2087 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
|
gokhlayeh@194
|
2088 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
|
gokhlayeh@186
|
2089 mount -t proc proc \$chroot_dir/proc
|
gokhlayeh@186
|
2090 mount -t sysfs sysfs \$chroot_dir/sys
|
gokhlayeh@186
|
2091 mount -t devpts devpts \$chroot_dir/dev/pts
|
gokhlayeh@186
|
2092 mount -t tmpfs shm \$chroot_dir/dev/shm
|
gokhlayeh@186
|
2093 for dir in \$list_dir; do
|
gokhlayeh@186
|
2094 mkdir -p \$dir \$chroot_dir\$dir
|
gokhlayeh@186
|
2095 mount \$dir \$chroot_dir\$dir
|
gokhlayeh@186
|
2096 done
|
gokhlayeh@186
|
2097 }
|
gokhlayeh@186
|
2098
|
gokhlayeh@186
|
2099 umount_chroot()
|
gokhlayeh@186
|
2100 {
|
gokhlayeh@186
|
2101 for dir in \$list_dir; do
|
gokhlayeh@186
|
2102 umount \$chroot_dir\$dir
|
gokhlayeh@186
|
2103 done
|
gokhlayeh@186
|
2104 umount \$chroot_dir/dev/shm
|
gokhlayeh@186
|
2105 umount \$chroot_dir/dev/pts
|
gokhlayeh@186
|
2106 umount \$chroot_dir/sys
|
gokhlayeh@186
|
2107 umount \$chroot_dir/proc
|
gokhlayeh@186
|
2108 }
|
gokhlayeh@186
|
2109 EOF
|
gokhlayeh@186
|
2110 }
|
gokhlayeh@186
|
2111
|
gokhlayeh@186
|
2112 ########################################################################
|
gokhlayeh@186
|
2113 ######################### END OF NEW FUNCTIONS #########################
|
gokhlayeh@186
|
2114 ########################################################################
|
gokhlayeh@186
|
2115
|
pascal@111
|
2116 # List packages providing a virtual package
|
pascal@111
|
2117 whoprovide()
|
pascal@111
|
2118 {
|
pascal@111
|
2119 local i;
|
gokhlayeh@195
|
2120 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
|
pascal@111
|
2121 . $i
|
pascal@111
|
2122 case " $PROVIDE " in
|
pascal@111
|
2123 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
|
pascal@111
|
2124 esac
|
pascal@111
|
2125 done
|
pascal@111
|
2126 }
|
pascal@111
|
2127
|
gokhlayeh@186
|
2128 ########################################################################
|
gokhlayeh@186
|
2129 # TAZWOK COMMANDS
|
gokhlayeh@186
|
2130 ########################
|
pankso@7
|
2131
|
pankso@7
|
2132 case "$COMMAND" in
|
pankso@7
|
2133 stats)
|
paul@166
|
2134 # Tazwok general statistics from the wok config file.
|
pankso@7
|
2135 #
|
gokhlayeh@186
|
2136 get_tazwok_config
|
gokhlayeh@186
|
2137 echo -e "\n\033[1mTazwok configuration statistics\033[0m
|
pankso@7
|
2138 ================================================================================
|
pankso@7
|
2139 Wok directory : $WOK
|
pankso@7
|
2140 Packages repository : $PACKAGES_REPOSITORY
|
gokhlayeh@186
|
2141 Incoming repository : $INCOMING_REPOSITORY
|
pankso@7
|
2142 Sources repository : $SOURCES_REPOSITORY
|
gokhlayeh@186
|
2143 Log directory : $LOCAL_REPOSITORY/log
|
pankso@7
|
2144 Packages in the wok : `ls -1 $WOK | wc -l`
|
pankso@16
|
2145 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
|
gokhlayeh@186
|
2146 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
|
gokhlayeh@186
|
2147 ================================================================================\n"
|
gokhlayeh@186
|
2148 ;;
|
pankso@133
|
2149 edit)
|
gokhlayeh@186
|
2150 get_tazwok_config
|
pankso@133
|
2151 check_for_package_on_cmdline
|
pankso@133
|
2152 check_for_receipt
|
gokhlayeh@186
|
2153 $EDITOR $WOK/$PACKAGE/receipt
|
gokhlayeh@186
|
2154 ;;
|
pascal@98
|
2155 build-depends)
|
gokhlayeh@186
|
2156 # List dependencies to rebuild wok, or only a package
|
gokhlayeh@186
|
2157 get_tazwok_config
|
gokhlayeh@215
|
2158 report(){ : ; }
|
gokhlayeh@242
|
2159 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
|
gokhlayeh@186
|
2160 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
|
gokhlayeh@186
|
2161 --look_for=dep --with_dev --with_args
|
gokhlayeh@186
|
2162 else
|
gokhlayeh@186
|
2163 check_for_package_on_cmdline
|
gokhlayeh@186
|
2164 scan $PACKAGE --look_for=bdep --with_dev
|
gokhlayeh@186
|
2165 fi
|
gokhlayeh@186
|
2166 ;;
|
gokhlayeh@186
|
2167 gen-cooklist)
|
gokhlayeh@215
|
2168 check_root
|
gokhlayeh@204
|
2169 get_options_list="pkg"
|
gokhlayeh@186
|
2170 get_tazwok_config
|
gokhlayeh@215
|
2171 report(){ : ; }
|
gokhlayeh@204
|
2172 if ! [ "$pkg" ]; then
|
gokhlayeh@242
|
2173 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
|
gokhlayeh@242
|
2174 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
|
gokhlayeh@242
|
2175 else
|
gokhlayeh@242
|
2176 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
|
gokhlayeh@242
|
2177 fi
|
gokhlayeh@186
|
2178 fi
|
gokhlayeh@204
|
2179 gen_cook_list
|
gokhlayeh@186
|
2180 ;;
|
pascal@119
|
2181 check-depends)
|
gokhlayeh@186
|
2182 # Check package depends /!\
|
gokhlayeh@186
|
2183 get_tazwok_config
|
pascal@119
|
2184 echo ""
|
paul@121
|
2185 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
|
pascal@119
|
2186 ================================================================================"
|
pascal@119
|
2187 TMPDIR=/tmp/tazwok$$
|
pascal@119
|
2188 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
|
pascal@119
|
2189
|
pascal@119
|
2190 # Build ALL_DEPENDS variable
|
pascal@119
|
2191 scan_dep()
|
pascal@119
|
2192 {
|
pascal@119
|
2193 local i
|
pascal@119
|
2194 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
|
pascal@128
|
2195 for i in $DEPENDS $SUGGESTED ; do
|
pascal@119
|
2196 case " $ALL_DEPENDS " in
|
pascal@119
|
2197 *\ $i\ *) continue;;
|
pascal@119
|
2198 esac
|
pascal@120
|
2199 [ -d $WOK/$i ] || {
|
pascal@120
|
2200 ALL_DEPENDS="$ALL_DEPENDS$i "
|
pascal@120
|
2201 continue
|
pascal@120
|
2202 }
|
pascal@128
|
2203 DEPENDS=""
|
pascal@128
|
2204 SUGGESTED=""
|
pascal@119
|
2205 . $WOK/$i/receipt
|
pascal@119
|
2206 scan_dep
|
pascal@119
|
2207 done
|
pascal@119
|
2208 }
|
pankso@133
|
2209
|
pascal@119
|
2210 # Check for ELF file
|
pascal@119
|
2211 is_elf()
|
pascal@119
|
2212 {
|
pascal@119
|
2213 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
|
pascal@119
|
2214 = "ELF" ]
|
pascal@119
|
2215 }
|
pascal@119
|
2216
|
pascal@119
|
2217 # Print shared library dependencies
|
pascal@119
|
2218 ldd()
|
pascal@119
|
2219 {
|
pascal@130
|
2220 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
|
pascal@119
|
2221 }
|
pascal@119
|
2222
|
pascal@119
|
2223 mkdir $TMPDIR
|
pascal@119
|
2224 cd $TMPDIR
|
pascal@140
|
2225 for i in $LOCALSTATE/files.list.lzma \
|
pascal@140
|
2226 $LOCALSTATE/undigest/*/files.list.lzma ; do
|
pascal@119
|
2227 [ -f $i ] && lzma d $i -so >> files.list
|
pascal@119
|
2228 done
|
pascal@119
|
2229 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
|
pascal@119
|
2230 tazpkg extract $pkg > /dev/null 2>&1
|
pascal@119
|
2231 . */receipt
|
pascal@119
|
2232 ALL_DEPENDS="$DEFAULT_DEPENDS "
|
pascal@119
|
2233 scan_dep
|
pascal@119
|
2234 find */fs -type f | while read file ; do
|
pascal@119
|
2235 is_elf $file || continue
|
pascal@119
|
2236 case "$file" in
|
pascal@119
|
2237 *.o|*.ko|*.ko.gz) continue;;
|
pascal@119
|
2238 esac
|
pascal@119
|
2239 ldd $file | while read lib rem; do
|
pascal@119
|
2240 case "$lib" in
|
pascal@128
|
2241 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
|
pascal@119
|
2242 continue;;
|
pascal@119
|
2243 esac
|
gokhlayeh@195
|
2244 for dep in $(fgrep $lib files.list | cut -d: -f1); do
|
pascal@119
|
2245 case " $ALL_DEPENDS " in
|
pascal@119
|
2246 *\ $dep\ *) continue 2;;
|
pascal@119
|
2247 esac
|
gokhlayeh@195
|
2248 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
|
pascal@128
|
2249 case " $ALL_DEPENDS " in
|
pascal@129
|
2250 *\ $vdep\ *) continue 3;;
|
pascal@128
|
2251 esac
|
pascal@128
|
2252 done
|
pascal@119
|
2253 done
|
pascal@128
|
2254 [ -n "$dep" ] || dep="UNKNOWN"
|
pascal@119
|
2255 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
|
pascal@119
|
2256 done
|
pascal@119
|
2257 done
|
pascal@119
|
2258 rm -rf */
|
pascal@119
|
2259 done
|
pascal@119
|
2260 cd /tmp
|
pascal@119
|
2261 rm -rf $TMPDIR
|
gokhlayeh@186
|
2262 ;;
|
pascal@76
|
2263 check)
|
paul@154
|
2264 # Check wok consistency
|
gokhlayeh@186
|
2265 get_tazwok_config
|
pascal@76
|
2266 echo ""
|
pascal@76
|
2267 echo -e "\033[1mWok and packages checking\033[0m
|
pascal@76
|
2268 ================================================================================"
|
pascal@77
|
2269 cd $WOK
|
pascal@77
|
2270 for pkg in $(ls)
|
pascal@76
|
2271 do
|
pascal@76
|
2272 [ -f $pkg/receipt ] || continue
|
gokhlayeh@186
|
2273 RECEIPT= $pkg/receipt
|
gokhlayeh@186
|
2274 source_receipt
|
gokhlayeh@186
|
2275 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
|
gokhlayeh@186
|
2276 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
|
gokhlayeh@186
|
2277 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
|
gokhlayeh@186
|
2278 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
|
gokhlayeh@186
|
2279 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
|
pascal@97
|
2280 if [ -n "$WANTED" ]; then
|
pascal@97
|
2281 if [ ! -f $WANTED/receipt ]; then
|
gokhlayeh@186
|
2282 echo "Package $PACKAGE wants unknown $WANTED package" >&2
|
pascal@97
|
2283 else
|
pascal@97
|
2284 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
|
pascal@103
|
2285 if [ "$VERSION" = "$WANTED" ]; then
|
pascal@103
|
2286 # BASEVERSION is computed in receipt
|
gokhlayeh@195
|
2287 fgrep -q '_pkg=' $pkg/receipt &&
|
pascal@103
|
2288 BASEVERSION=$VERSION
|
pascal@103
|
2289 fi
|
pascal@97
|
2290 if [ "$VERSION" != "$BASEVERSION" ]; then
|
gokhlayeh@186
|
2291 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
|
pascal@97
|
2292 fi
|
pascal@97
|
2293 fi
|
pascal@97
|
2294 fi
|
pascal@97
|
2295
|
pascal@94
|
2296 if [ -n "$CATEGORY" ]; then
|
pascal@94
|
2297 case " $(echo $CATEGORIES) " in
|
pascal@94
|
2298 *\ $CATEGORY\ *);;
|
gokhlayeh@186
|
2299 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
|
pascal@94
|
2300 esac
|
pascal@94
|
2301 else
|
gokhlayeh@186
|
2302 echo"Package $PACKAGE has no CATEGORY" >&2
|
pascal@94
|
2303 fi
|
gokhlayeh@186
|
2304 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
|
gokhlayeh@186
|
2305 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
|
pascal@122
|
2306 case "$WGET_URL" in
|
pascal@178
|
2307 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
|
gokhlayeh@186
|
2308 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
|
pascal@122
|
2309 '') ;;
|
gokhlayeh@186
|
2310 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
|
pascal@122
|
2311 esac
|
pascal@112
|
2312 case "$WEB_SITE" in
|
pascal@125
|
2313 ftp*|http*);;
|
gokhlayeh@186
|
2314 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
|
gokhlayeh@186
|
2315 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
|
pascal@112
|
2316 esac
|
pascal@78
|
2317 case "$MAINTAINER" in
|
gokhlayeh@186
|
2318 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
|
pascal@78
|
2319 esac
|
pascal@78
|
2320 case "$MAINTAINER" in
|
pascal@78
|
2321 *@*);;
|
gokhlayeh@186
|
2322 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
|
pascal@78
|
2323 esac
|
gokhlayeh@186
|
2324 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
|
pascal@76
|
2325 for i in $DEPENDS; do
|
pascal@76
|
2326 [ -d $i ] && continue
|
pascal@111
|
2327 [ -n "$(whoprovide $i)" ] && continue
|
pascal@76
|
2328 echo -e "$MSG $i"
|
pascal@76
|
2329 MSG=""
|
pascal@76
|
2330 done
|
gokhlayeh@186
|
2331 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
|
pascal@92
|
2332 for i in $BUILD_DEPENDS; do
|
pascal@92
|
2333 [ -d $i ] && continue
|
pascal@111
|
2334 [ -n "$(whoprovide $i)" ] && continue
|
pascal@92
|
2335 echo -e "$MSG $i"
|
pascal@92
|
2336 MSG=""
|
pascal@92
|
2337 done
|
pascal@76
|
2338 MSG="Dependencies loop between $PACKAGE and :\n"
|
pascal@76
|
2339 ALL_DEPS=""
|
pascal@76
|
2340 check_for_deps_loop $PACKAGE $DEPENDS
|
pascal@140
|
2341 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
|
pascal@141
|
2342 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
|
paul@154
|
2343 echo "$pkg should be rebuilt after $i installation"
|
pascal@140
|
2344 done
|
pascal@76
|
2345 done
|
gokhlayeh@186
|
2346 ;;
|
pankso@7
|
2347 list)
|
paul@166
|
2348 # List packages in wok directory. User can specify a category.
|
pankso@7
|
2349 #
|
gokhlayeh@186
|
2350 get_tazwok_config
|
pankso@7
|
2351 if [ "$2" = "category" ]; then
|
pankso@7
|
2352 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
|
pankso@7
|
2353 exit 0
|
pankso@7
|
2354 fi
|
pankso@7
|
2355 # Check for an asked category.
|
pankso@7
|
2356 if [ -n "$2" ]; then
|
pankso@7
|
2357 ASKED_CATEGORY=$2
|
pankso@7
|
2358 echo ""
|
pankso@7
|
2359 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
|
pankso@7
|
2360 echo "================================================================================"
|
pankso@7
|
2361 for pkg in $WOK/*
|
pankso@7
|
2362 do
|
erjo@168
|
2363 [ ! -f $pkg/receipt ] && continue
|
pankso@7
|
2364 . $pkg/receipt
|
pankso@7
|
2365 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
|
pankso@7
|
2366 echo -n "$PACKAGE"
|
pankso@28
|
2367 echo -e "\033[28G $VERSION"
|
pankso@7
|
2368 packages=$(($packages+1))
|
pankso@7
|
2369 fi
|
pankso@7
|
2370 done
|
pankso@7
|
2371 echo "================================================================================"
|
gokhlayeh@236
|
2372 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
|
pankso@7
|
2373 else
|
pankso@7
|
2374 # By default list all packages and version.
|
pankso@7
|
2375 echo ""
|
pankso@7
|
2376 echo -e "\033[1mList of packages in the wok\033[0m"
|
pankso@7
|
2377 echo "================================================================================"
|
pankso@7
|
2378 for pkg in $WOK/*
|
pankso@7
|
2379 do
|
erjo@168
|
2380 [ ! -f $pkg/receipt ] && continue
|
pankso@7
|
2381 . $pkg/receipt
|
pankso@7
|
2382 echo -n "$PACKAGE"
|
pankso@28
|
2383 echo -en "\033[28G $VERSION"
|
pankso@7
|
2384 echo -e "\033[42G $CATEGORY"
|
pankso@7
|
2385 packages=$(($packages+1))
|
pankso@7
|
2386 done
|
pankso@7
|
2387 echo "================================================================================"
|
gokhlayeh@236
|
2388 echo -e "$packages packages available in the wok.\n"
|
pankso@7
|
2389 fi
|
pankso@7
|
2390 ;;
|
pankso@7
|
2391 info)
|
MikeDSmith25@82
|
2392 # Information about a package.
|
pankso@7
|
2393 #
|
gokhlayeh@186
|
2394 get_tazwok_config
|
pankso@7
|
2395 check_for_package_on_cmdline
|
pankso@7
|
2396 check_for_receipt
|
pankso@7
|
2397 . $WOK/$PACKAGE/receipt
|
pankso@7
|
2398 echo ""
|
MikeDSmith25@82
|
2399 echo -e "\033[1mTazwok package information\033[0m
|
pankso@7
|
2400 ================================================================================
|
pankso@7
|
2401 Package : $PACKAGE
|
pankso@7
|
2402 Version : $VERSION
|
pankso@7
|
2403 Category : $CATEGORY
|
pankso@7
|
2404 Short desc : $SHORT_DESC
|
pankso@7
|
2405 Maintainer : $MAINTAINER"
|
pankso@7
|
2406 if [ ! "$WEB_SITE" = "" ]; then
|
pankso@7
|
2407 echo "Web site : $WEB_SITE"
|
pankso@7
|
2408 fi
|
pankso@7
|
2409 if [ ! "$DEPENDS" = "" ]; then
|
pankso@7
|
2410 echo "Depends : $DEPENDS"
|
pankso@7
|
2411 fi
|
pankso@7
|
2412 if [ ! "$WANTED" = "" ]; then
|
pankso@7
|
2413 echo "Wanted src : $WANTED"
|
pankso@7
|
2414 fi
|
pankso@7
|
2415 echo "================================================================================"
|
pankso@7
|
2416 echo ""
|
gokhlayeh@186
|
2417 ;;
|
pankso@7
|
2418 check-log)
|
pankso@7
|
2419 # We just cat the file log to view process info.
|
pankso@7
|
2420 #
|
gokhlayeh@186
|
2421 get_tazwok_config
|
pankso@7
|
2422 if [ ! -f "$LOG" ]; then
|
gokhlayeh@186
|
2423 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
|
gokhlayeh@186
|
2424 exit 1
|
pankso@7
|
2425 else
|
pankso@7
|
2426 echo ""
|
pankso@7
|
2427 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
|
pankso@7
|
2428 echo "================================================================================"
|
pankso@7
|
2429 cat $LOG
|
pankso@7
|
2430 echo "================================================================================"
|
pankso@7
|
2431 echo ""
|
gokhlayeh@237
|
2432 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
|
gokhlayeh@237
|
2433 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
|
gokhlayeh@237
|
2434 echo "================================================================================"
|
gokhlayeh@237
|
2435 cat "$WOK/$PACKAGE/warning.txt"
|
gokhlayeh@237
|
2436 echo "================================================================================"
|
gokhlayeh@237
|
2437 echo ""
|
gokhlayeh@237
|
2438 fi
|
pankso@7
|
2439 fi
|
gokhlayeh@186
|
2440 ;;
|
pankso@7
|
2441 search)
|
pankso@7
|
2442 # Search for a package by pattern or name.
|
pankso@7
|
2443 #
|
gokhlayeh@186
|
2444 get_tazwok_config
|
pankso@7
|
2445 if [ -z "$2" ]; then
|
gokhlayeh@186
|
2446 echo -e "\nPlease specify a pattern or a package name to search." >&2
|
gokhlayeh@186
|
2447 echo -e "Example : 'tazwok search gcc'.\n" >&2
|
gokhlayeh@186
|
2448 exit 1
|
pankso@7
|
2449 fi
|
pankso@7
|
2450 echo ""
|
pankso@7
|
2451 echo -e "\033[1mSearch result for :\033[0m $2"
|
pankso@7
|
2452 echo "================================================================================"
|
gokhlayeh@195
|
2453 list=`ls -1 $WOK | fgrep $2`
|
pankso@7
|
2454 for pkg in $list
|
pankso@7
|
2455 do
|
pankso@7
|
2456 . $WOK/$pkg/receipt
|
pankso@7
|
2457 echo -n "$PACKAGE "
|
pankso@7
|
2458 echo -en "\033[24G $VERSION"
|
pankso@7
|
2459 echo -e "\033[42G $CATEGORY"
|
gokhlayeh@186
|
2460 packages=$(($PACKAGEs+1))
|
pankso@7
|
2461 done
|
pankso@7
|
2462 echo "================================================================================"
|
gokhlayeh@238
|
2463 echo "$packages packages found for : $2"
|
pankso@7
|
2464 echo ""
|
gokhlayeh@186
|
2465 ;;
|
pankso@7
|
2466 compile)
|
pankso@7
|
2467 # Configure and make a package with the receipt.
|
pankso@7
|
2468 #
|
gokhlayeh@186
|
2469 get_tazwok_config
|
gokhlayeh@186
|
2470 source_lib report
|
gokhlayeh@186
|
2471 report start
|
pankso@7
|
2472 compile_package
|
gokhlayeh@186
|
2473 ;;
|
pankso@7
|
2474 genpkg)
|
paul@121
|
2475 # Generate a package.
|
pankso@7
|
2476 #
|
gokhlayeh@186
|
2477 get_tazwok_config
|
gokhlayeh@186
|
2478 source_lib report
|
gokhlayeh@186
|
2479 report start
|
pankso@7
|
2480 gen_package
|
gokhlayeh@186
|
2481 ;;
|
pankso@7
|
2482 cook)
|
pankso@7
|
2483 # Compile and generate a package. Just execute tazwok with
|
pankso@7
|
2484 # the good commands.
|
pankso@7
|
2485 #
|
pankso@7
|
2486 check_root
|
gokhlayeh@186
|
2487 get_tazwok_config
|
gokhlayeh@186
|
2488 source_lib report
|
gokhlayeh@186
|
2489 report start
|
gokhlayeh@215
|
2490 update_wan_db
|
gokhlayeh@215
|
2491 check_for_commit
|
gokhlayeh@215
|
2492 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
|
gokhlayeh@215
|
2493 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
|
gokhlayeh@215
|
2494 if [ "$plan_regen_cookorder" ]; then
|
gokhlayeh@215
|
2495 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
|
gokhlayeh@215
|
2496 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
|
gokhlayeh@215
|
2497 fi
|
gokhlayeh@186
|
2498 cook
|
gokhlayeh@186
|
2499 ;;
|
gokhlayeh@186
|
2500 sort-cooklist)
|
gokhlayeh@186
|
2501 if [ ! "$LIST" ]; then
|
gokhlayeh@186
|
2502 echo "Usage : tazwok sort-cooklist cooklist" >&2\
|
gokhlayeh@186
|
2503 exit 1
|
gokhlayeh@186
|
2504 fi
|
gokhlayeh@186
|
2505 get_tazwok_config
|
gokhlayeh@186
|
2506 source_lib report
|
gokhlayeh@186
|
2507 report start
|
gokhlayeh@186
|
2508 cooklist=$LIST
|
gokhlayeh@186
|
2509 sort_cooklist
|
gokhlayeh@186
|
2510 cp -af $tmp/cooklist $cooklist
|
gokhlayeh@186
|
2511 ;;
|
pankso@7
|
2512 cook-list)
|
gokhlayeh@204
|
2513 # Cook all packages listed in a file or in default cooklist.
|
gokhlayeh@186
|
2514 check_root
|
gokhlayeh@204
|
2515 get_options_list="pkg forced"
|
gokhlayeh@186
|
2516 get_tazwok_config
|
gokhlayeh@186
|
2517 source_lib report
|
gokhlayeh@186
|
2518 report start
|
gokhlayeh@204
|
2519 if ! [ "$pkg" ]; then
|
gokhlayeh@204
|
2520 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
|
gokhlayeh@186
|
2521 fi
|
gokhlayeh@204
|
2522 gen_cook_list
|
gokhlayeh@186
|
2523 cook_list
|
gokhlayeh@186
|
2524 ;;
|
gokhlayeh@186
|
2525 clean)
|
gokhlayeh@186
|
2526 # Clean up a package work directory + thoses which want it.
|
pankso@7
|
2527 #
|
gokhlayeh@186
|
2528 get_tazwok_config
|
pankso@7
|
2529 check_for_package_on_cmdline
|
pankso@7
|
2530 check_for_receipt
|
gokhlayeh@186
|
2531 source_lib report
|
gokhlayeh@186
|
2532 report start
|
pankso@7
|
2533 . $RECEIPT
|
gokhlayeh@186
|
2534 clean
|
gokhlayeh@186
|
2535 ;;
|
pankso@7
|
2536 gen-clean-wok)
|
paul@121
|
2537 # Generate a clean wok from the current wok by copying all receipts
|
pankso@7
|
2538 # and stuff directory.
|
pankso@7
|
2539 #
|
gokhlayeh@186
|
2540 get_tazwok_config
|
gokhlayeh@186
|
2541 source_lib report
|
gokhlayeh@186
|
2542 report start
|
gokhlayeh@186
|
2543 if [ -z "$ARG" ]; then
|
gokhlayeh@186
|
2544 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
|
gokhlayeh@186
|
2545 exit 1
|
pankso@7
|
2546 else
|
gokhlayeh@186
|
2547 dest=$ARG
|
pankso@7
|
2548 mkdir -p $dest
|
pankso@7
|
2549 fi
|
gokhlayeh@186
|
2550 report step "Creating clean wok in : $dest"
|
pankso@7
|
2551 for pkg in `ls -1 $WOK`
|
pankso@7
|
2552 do
|
pankso@7
|
2553 mkdir -p $dest/$pkg
|
pankso@7
|
2554 cp -a $WOK/$pkg/receipt $dest/$pkg
|
gokhlayeh@186
|
2555 [ -f $WOK/$pkg/description.txt ] && \
|
gokhlayeh@186
|
2556 cp -a $WOK/$pkg/description.txt $dest/$pkg
|
pankso@7
|
2557 if [ -d "$WOK/$pkg/stuff" ]; then
|
pankso@7
|
2558 cp -a $WOK/$pkg/stuff $dest/$pkg
|
pankso@7
|
2559 fi
|
pankso@7
|
2560 done
|
gokhlayeh@186
|
2561 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
|
gokhlayeh@186
|
2562 report end-step
|
pankso@7
|
2563 echo "Packages cleaned : `ls -1 $dest | wc -l`"
|
pankso@7
|
2564 echo ""
|
gokhlayeh@186
|
2565 ;;
|
pankso@7
|
2566 clean-wok)
|
pankso@7
|
2567 # Clean all packages in the work directory
|
pankso@7
|
2568 #
|
gokhlayeh@186
|
2569 get_tazwok_config
|
gokhlayeh@186
|
2570 source_lib report
|
gokhlayeh@186
|
2571 report start
|
gokhlayeh@186
|
2572 report step "Cleaning wok"
|
gokhlayeh@186
|
2573 for PACKAGE in `ls -1 $WOK`
|
pankso@7
|
2574 do
|
gokhlayeh@186
|
2575 set_common_path
|
gokhlayeh@186
|
2576 source_receipt
|
gokhlayeh@186
|
2577 clean
|
pankso@7
|
2578 done
|
pankso@7
|
2579 echo "`ls -1 $WOK | wc -l` packages cleaned."
|
gokhlayeh@186
|
2580 ;;
|
gokhlayeh@266
|
2581 clean-src)
|
gokhlayeh@266
|
2582 # Remove tarball unrelated to wok receipts from src repo.
|
gokhlayeh@266
|
2583 check_root
|
gokhlayeh@266
|
2584 get_options_list="forced"
|
gokhlayeh@266
|
2585 get_tazwok_config
|
gokhlayeh@266
|
2586 cd $SOURCES_REPOSITORY
|
gokhlayeh@266
|
2587 echo -n "Checking $SOURCES_REPOSITORY..."
|
gokhlayeh@266
|
2588 for TARBALL in *; do
|
gokhlayeh@266
|
2589 [ "$TARBALL" = sources.list ] && continue
|
gokhlayeh@266
|
2590 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
|
gokhlayeh@266
|
2591 echo $TARBALL >> $tmp/obsolete
|
gokhlayeh@266
|
2592 done
|
gokhlayeh@266
|
2593 status
|
gokhlayeh@266
|
2594 echo ""
|
gokhlayeh@266
|
2595 echo -e "\033[1mObsolete/unrelated-to-wok sourcess :\033[0m"
|
gokhlayeh@266
|
2596 horizontal_line
|
gokhlayeh@266
|
2597 cat $tmp/obsolete
|
gokhlayeh@266
|
2598 horizontal_line
|
gokhlayeh@266
|
2599 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
|
gokhlayeh@266
|
2600 echo ""
|
gokhlayeh@266
|
2601 echo -n "Please confirm removing (type uppercase YES): "
|
gokhlayeh@266
|
2602 read answer
|
gokhlayeh@266
|
2603 if [ "$answer" = YES ]; then
|
gokhlayeh@266
|
2604 echo -n "Removing old sources..."
|
gokhlayeh@266
|
2605 cat $tmp/obsolete | while read i; do
|
gokhlayeh@266
|
2606 rm -f $SOURCES_REPOSITORY/$i
|
gokhlayeh@266
|
2607 done
|
gokhlayeh@266
|
2608 status
|
gokhlayeh@266
|
2609 fi
|
gokhlayeh@266
|
2610 ;;
|
pankso@7
|
2611 gen-list)
|
gokhlayeh@186
|
2612 get_tazwok_config
|
gokhlayeh@204
|
2613 if [ "$2" ]; then
|
gokhlayeh@204
|
2614 if [ -d "$2" ]; then
|
gokhlayeh@204
|
2615 pkg_repository=$2
|
gokhlayeh@204
|
2616 else
|
gokhlayeh@204
|
2617 echo -e "\nUnable to find directory : $2\n" >&2
|
gokhlayeh@204
|
2618 exit 1
|
gokhlayeh@204
|
2619 fi
|
gokhlayeh@204
|
2620 fi
|
gokhlayeh@204
|
2621
|
gokhlayeh@186
|
2622 source_lib report
|
gokhlayeh@186
|
2623 report start
|
gokhlayeh@204
|
2624 if [ "$pkg_repository" ]; then
|
gokhlayeh@204
|
2625 gen_packages_db
|
gokhlayeh@204
|
2626 else
|
gokhlayeh@204
|
2627 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
|
gokhlayeh@204
|
2628 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
|
gokhlayeh@204
|
2629 fi
|
gokhlayeh@186
|
2630 ;;
|
gokhlayeh@186
|
2631 check-list)
|
gokhlayeh@186
|
2632 # The directory to move into by default is the repository,
|
gokhlayeh@186
|
2633 # if $2 is not empty cd into $2.
|
pankso@7
|
2634 #
|
gokhlayeh@186
|
2635 get_tazwok_config
|
gokhlayeh@204
|
2636 if [ "$2" ]; then
|
pankso@7
|
2637 if [ -d "$2" ]; then
|
gokhlayeh@204
|
2638 pkg_repository=$2
|
pankso@7
|
2639 else
|
gokhlayeh@186
|
2640 echo -e "\nUnable to find directory : $2\n" >&2
|
gokhlayeh@186
|
2641 exit 1
|
pankso@7
|
2642 fi
|
pankso@7
|
2643 fi
|
gokhlayeh@186
|
2644
|
gokhlayeh@186
|
2645 source_lib report
|
gokhlayeh@204
|
2646 report start
|
gokhlayeh@204
|
2647 if [ "$pkg_repository" ]; then
|
gokhlayeh@204
|
2648 update_packages_db
|
gokhlayeh@204
|
2649 else
|
gokhlayeh@204
|
2650 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
|
gokhlayeh@204
|
2651 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
|
gokhlayeh@204
|
2652 fi
|
gokhlayeh@186
|
2653 ;;
|
pankso@7
|
2654 new-tree)
|
MikeDSmith25@82
|
2655 # Just create a few directories and generate an empty receipt to prepare
|
pankso@7
|
2656 # the creation of a new package.
|
pankso@7
|
2657 #
|
gokhlayeh@186
|
2658 get_tazwok_config
|
pankso@7
|
2659 check_for_package_on_cmdline
|
pankso@7
|
2660 if [ -d $WOK/$PACKAGE ]; then
|
gokhlayeh@186
|
2661 echo -e "\n$PACKAGE package tree already exists.\n" >&2
|
gokhlayeh@186
|
2662 exit 1
|
pankso@7
|
2663 fi
|
pankso@7
|
2664 echo "Creating : $WOK/$PACKAGE"
|
pankso@7
|
2665 mkdir $WOK/$PACKAGE
|
pankso@7
|
2666 cd $WOK/$PACKAGE
|
pankso@7
|
2667 echo -n "Preparing the receipt..."
|
pankso@7
|
2668 #
|
pankso@7
|
2669 # Default receipt begin.
|
pankso@7
|
2670 #
|
pankso@7
|
2671 echo "# SliTaz package receipt." > receipt
|
pankso@7
|
2672 echo "" >> receipt
|
pankso@7
|
2673 echo "PACKAGE=\"$PACKAGE\"" >> receipt
|
pankso@7
|
2674 # Finish the empty receipt.
|
pankso@7
|
2675 cat >> receipt << "EOF"
|
pankso@7
|
2676 VERSION=""
|
pankso@7
|
2677 CATEGORY=""
|
pankso@7
|
2678 SHORT_DESC=""
|
pankso@7
|
2679 MAINTAINER=""
|
pankso@7
|
2680 DEPENDS=""
|
pankso@7
|
2681 TARBALL="$PACKAGE-$VERSION.tar.gz"
|
pankso@7
|
2682 WEB_SITE=""
|
pankso@7
|
2683 WGET_URL=""
|
pankso@7
|
2684
|
pankso@7
|
2685 # Rules to configure and make the package.
|
pankso@7
|
2686 compile_rules()
|
pankso@7
|
2687 {
|
pankso@7
|
2688 cd $src
|
gokhlayeh@204
|
2689 ./configure && make && make install
|
pankso@7
|
2690 }
|
pankso@7
|
2691
|
pankso@7
|
2692 # Rules to gen a SliTaz package suitable for Tazpkg.
|
pankso@7
|
2693 genpkg_rules()
|
pankso@7
|
2694 {
|
pankso@7
|
2695 mkdir -p $fs/usr
|
pankso@7
|
2696 cp -a $_pkg/usr/bin $fs/usr
|
pankso@7
|
2697 }
|
pankso@7
|
2698
|
pankso@7
|
2699 EOF
|
pankso@7
|
2700 #
|
pankso@7
|
2701 # Default receipt end.
|
pankso@7
|
2702 #
|
pankso@7
|
2703 status
|
pankso@7
|
2704 # Interactive mode, asking and seding.
|
pankso@7
|
2705 if [ "$3" = "--interactive" ]; then
|
paul@154
|
2706 echo "Entering into interactive mode..."
|
pankso@7
|
2707 echo "================================================================================"
|
pankso@7
|
2708 echo "Package : $PACKAGE"
|
pankso@7
|
2709 # Version.
|
pankso@7
|
2710 echo -n "Version : " ; read anser
|
pankso@7
|
2711 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
|
pankso@7
|
2712 # Category.
|
pankso@7
|
2713 echo -n "Category : " ; read anser
|
pankso@7
|
2714 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
|
pankso@7
|
2715 # Short description.
|
pankso@7
|
2716 echo -n "Short desc : " ; read anser
|
pankso@7
|
2717 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
|
pankso@7
|
2718 # Maintainer.
|
pankso@7
|
2719 echo -n "Maintainer : " ; read anser
|
pankso@7
|
2720 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
|
pankso@7
|
2721 # Web site.
|
pankso@7
|
2722 echo -n "Web site : " ; read anser
|
pankso@133
|
2723 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
|
pankso@7
|
2724 echo ""
|
pankso@7
|
2725 # Wget URL.
|
pankso@7
|
2726 echo "Wget URL to download source tarball."
|
pankso@7
|
2727 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
|
pankso@7
|
2728 echo -n "Wget url : " ; read anser
|
pankso@7
|
2729 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
|
pankso@7
|
2730 # Ask for a stuff dir.
|
pankso@7
|
2731 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
|
pankso@7
|
2732 if [ "$anser" = "y" ]; then
|
pankso@7
|
2733 echo -n "Creating the stuff directory..."
|
pankso@7
|
2734 mkdir stuff && status
|
pankso@7
|
2735 fi
|
pankso@7
|
2736 # Ask for a description file.
|
pankso@7
|
2737 echo -n "Are you going to write a description ? (y/N) : " ; read anser
|
pankso@7
|
2738 if [ "$anser" = "y" ]; then
|
pankso@7
|
2739 echo -n "Creating the description.txt file..."
|
pankso@7
|
2740 echo "" > description.txt && status
|
pankso@7
|
2741 fi
|
pankso@7
|
2742 echo "================================================================================"
|
pankso@7
|
2743 echo ""
|
pankso@7
|
2744 fi
|
gokhlayeh@186
|
2745 ;;
|
pankso@7
|
2746 remove)
|
pankso@7
|
2747 # Remove a package from the wok.
|
pankso@7
|
2748 #
|
gokhlayeh@186
|
2749 get_tazwok_config
|
pankso@7
|
2750 check_for_package_on_cmdline
|
pankso@7
|
2751 echo ""
|
pascal@83
|
2752 echo -n "Please confirm deletion (y/N) : "; read anser
|
pascal@83
|
2753 if [ "$anser" = "y" ]; then
|
pascal@83
|
2754 echo -n "Removing $PACKAGE..."
|
pascal@83
|
2755 rm -rf $WOK/$PACKAGE && status
|
pascal@83
|
2756 echo ""
|
pascal@83
|
2757 fi
|
gokhlayeh@186
|
2758 ;;
|
pankso@106
|
2759 hgup)
|
paul@166
|
2760 # Pull and update a Hg wok.
|
gokhlayeh@186
|
2761 get_tazwok_config
|
gokhlayeh@195
|
2762 if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
|
pankso@106
|
2763 check_root
|
pankso@106
|
2764 fi
|
pankso@106
|
2765 cd $WOK
|
gokhlayeh@186
|
2766 hg pull && hg update
|
gokhlayeh@186
|
2767 ;;
|
pankso@108
|
2768 maintainers)
|
gokhlayeh@186
|
2769 get_tazwok_config
|
pankso@108
|
2770 echo ""
|
pankso@108
|
2771 echo "List of maintainers for: $WOK"
|
pankso@108
|
2772 echo "================================================================================"
|
pankso@108
|
2773 touch /tmp/slitaz-maintainers
|
pankso@108
|
2774 for pkg in $WOK/*
|
pankso@108
|
2775 do
|
pankso@108
|
2776 . $pkg/receipt
|
gokhlayeh@195
|
2777 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
|
pankso@108
|
2778 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
|
pankso@108
|
2779 echo "$MAINTAINER"
|
pankso@108
|
2780 fi
|
pankso@108
|
2781 done
|
pankso@108
|
2782 echo "================================================================================"
|
pankso@108
|
2783 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
|
pankso@108
|
2784 echo ""
|
pankso@108
|
2785 # Remove tmp files
|
gokhlayeh@186
|
2786 rm -f /tmp/slitaz-maintainers
|
gokhlayeh@186
|
2787 ;;
|
pankso@107
|
2788 maintained-by)
|
paul@166
|
2789 # Search for packages maintained by a contributor.
|
gokhlayeh@186
|
2790 get_tazwok_config
|
pankso@107
|
2791 if [ ! -n "$2" ]; then
|
gokhlayeh@186
|
2792 echo "Specify a name or email of a maintainer." >&2
|
gokhlayeh@186
|
2793 exit 1
|
pankso@107
|
2794 fi
|
pankso@107
|
2795 echo "Maintainer packages"
|
pankso@107
|
2796 echo "================================================================================"
|
pankso@107
|
2797 for pkg in $WOK/*
|
pankso@107
|
2798 do
|
pankso@107
|
2799 . $pkg/receipt
|
gokhlayeh@195
|
2800 if echo "$MAINTAINER" | fgrep -q "$2"; then
|
pankso@107
|
2801 echo "$PACKAGE"
|
gokhlayeh@186
|
2802 packages=$(($PACKAGEs+1))
|
pankso@107
|
2803 fi
|
pankso@107
|
2804 done
|
pankso@107
|
2805 echo "================================================================================"
|
gokhlayeh@186
|
2806 echo "Packages maintained by $2: $PACKAGEs"
|
gokhlayeh@186
|
2807 echo ""
|
gokhlayeh@186
|
2808 ;;
|
erjo@159
|
2809 check-src)
|
erjo@159
|
2810 # Verify if upstream package is still available
|
erjo@159
|
2811 #
|
gokhlayeh@186
|
2812 get_tazwok_config
|
erjo@159
|
2813 check_for_package_on_cmdline
|
erjo@159
|
2814 check_for_receipt
|
gokhlayeh@186
|
2815 source_receipt
|
erjo@159
|
2816 check_src()
|
erjo@159
|
2817 {
|
erjo@159
|
2818 for url in $@; do
|
pascal@178
|
2819 busybox wget -s $url 2>/dev/null && break
|
erjo@159
|
2820 done
|
erjo@159
|
2821 }
|
gokhlayeh@186
|
2822 if [ "$WGET_URL" ];then
|
erjo@159
|
2823 echo -n "$PACKAGE : "
|
erjo@159
|
2824 check_src $WGET_URL
|
erjo@159
|
2825 status
|
erjo@159
|
2826 else
|
erjo@159
|
2827 echo "No tarball to check for $PACKAGE"
|
erjo@159
|
2828 fi
|
gokhlayeh@186
|
2829 ;;
|
gokhlayeh@186
|
2830 get-src)
|
gokhlayeh@186
|
2831 check_root
|
gokhlayeh@225
|
2832 get_options_list="target nounpack"
|
gokhlayeh@186
|
2833 get_tazwok_config
|
gokhlayeh@186
|
2834 check_for_package_on_cmdline
|
gokhlayeh@186
|
2835 check_for_receipt
|
gokhlayeh@186
|
2836 source_receipt
|
gokhlayeh@186
|
2837 if [ "$WGET_URL" ];then
|
gokhlayeh@186
|
2838 source_lib report
|
gokhlayeh@186
|
2839 report start
|
gokhlayeh@225
|
2840 check_for_tarball
|
gokhlayeh@186
|
2841 else
|
gokhlayeh@186
|
2842 echo "No tarball to download for $PACKAGE"
|
gokhlayeh@186
|
2843 fi
|
gokhlayeh@186
|
2844 ;;
|
gokhlayeh@204
|
2845 check-commit)
|
gokhlayeh@186
|
2846 check_root
|
gokhlayeh@204
|
2847 get_options_list="missing forced"
|
gokhlayeh@186
|
2848 get_tazwok_config
|
gokhlayeh@186
|
2849 source_lib report
|
gokhlayeh@186
|
2850 report start
|
gokhlayeh@204
|
2851 if [ "$forced" ]; then
|
gokhlayeh@204
|
2852 rm -f $WOK/*/md5
|
gokhlayeh@204
|
2853 unset forced
|
gokhlayeh@204
|
2854 fi
|
gokhlayeh@204
|
2855 if [ "$missing" ]; then
|
gokhlayeh@204
|
2856 pkg=$(ls -1 $WOK)
|
gokhlayeh@204
|
2857 else
|
gokhlayeh@204
|
2858 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
|
gokhlayeh@204
|
2859 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
|
gokhlayeh@204
|
2860 } | sort -u)"
|
gokhlayeh@204
|
2861 fi
|
gokhlayeh@204
|
2862 cooklist=$PACKAGES_REPOSITORY/cooklist
|
gokhlayeh@186
|
2863 gen_cook_list
|
gokhlayeh@186
|
2864 ;;
|
gokhlayeh@186
|
2865 cook-commit)
|
gokhlayeh@186
|
2866 check_root
|
gokhlayeh@204
|
2867 get_options_list="missing forced"
|
gokhlayeh@186
|
2868 get_tazwok_config
|
gokhlayeh@186
|
2869 source_lib report
|
gokhlayeh@186
|
2870 report start
|
gokhlayeh@204
|
2871 if [ "$forced" ]; then
|
gokhlayeh@204
|
2872 rm -f $WOK/*/md5
|
gokhlayeh@204
|
2873 unset forced
|
gokhlayeh@204
|
2874 fi
|
gokhlayeh@204
|
2875 if [ "$missing" ]; then
|
gokhlayeh@204
|
2876 pkg=$(ls -1 $WOK)
|
gokhlayeh@204
|
2877 else
|
gokhlayeh@204
|
2878 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
|
gokhlayeh@204
|
2879 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
|
gokhlayeh@204
|
2880 } | sort -u)"
|
gokhlayeh@204
|
2881 fi
|
gokhlayeh@204
|
2882 cooklist=$PACKAGES_REPOSITORY/cooklist
|
gokhlayeh@186
|
2883 gen_cook_list
|
gokhlayeh@186
|
2884 cook_list
|
gokhlayeh@186
|
2885 ;;
|
gokhlayeh@186
|
2886 cook-all)
|
gokhlayeh@186
|
2887 check_root
|
gokhlayeh@204
|
2888 get_options_list="forced missing"
|
gokhlayeh@186
|
2889 get_tazwok_config
|
gokhlayeh@186
|
2890 source_lib report
|
gokhlayeh@186
|
2891 report start
|
gokhlayeh@204
|
2892 if [ "$missing" ]; then
|
gokhlayeh@204
|
2893 pkg=$(ls -1 $WOK)
|
gokhlayeh@204
|
2894 else
|
gokhlayeh@204
|
2895 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
|
gokhlayeh@204
|
2896 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
|
gokhlayeh@204
|
2897 } | sort -u)"
|
gokhlayeh@204
|
2898 fi
|
gokhlayeh@204
|
2899 cooklist=$PACKAGES_REPOSITORY/cooklist
|
gokhlayeh@204
|
2900 gen_cook_list
|
gokhlayeh@186
|
2901 cook_list
|
gokhlayeh@186
|
2902 ;;
|
gokhlayeh@186
|
2903 gen-wok-db)
|
gokhlayeh@186
|
2904 check_root
|
gokhlayeh@186
|
2905 get_tazwok_config
|
gokhlayeh@186
|
2906 source_lib report
|
gokhlayeh@186
|
2907 report start
|
gokhlayeh@204
|
2908 gen_wok_db
|
gokhlayeh@186
|
2909 ;;
|
gokhlayeh@186
|
2910 report)
|
gokhlayeh@186
|
2911 check_root
|
gokhlayeh@186
|
2912 get_tazwok_config
|
gokhlayeh@186
|
2913 cd $PACKAGES_REPOSITORY
|
gokhlayeh@239
|
2914 if [ "$2" ]; then
|
gokhlayeh@239
|
2915 case $2 in
|
gokhlayeh@239
|
2916 commit|cooklist|incoming|broken|blocked)
|
gokhlayeh@239
|
2917 show="$2"
|
gokhlayeh@239
|
2918 ;;
|
gokhlayeh@239
|
2919 *)
|
gokhlayeh@239
|
2920 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
|
gokhlayeh@239
|
2921 exit 1
|
gokhlayeh@239
|
2922 ;;
|
gokhlayeh@239
|
2923 esac
|
gokhlayeh@239
|
2924 else
|
gokhlayeh@239
|
2925 show="commit cooklist incoming broken blocked"
|
gokhlayeh@239
|
2926 fi
|
gokhlayeh@239
|
2927 for i in $show; do
|
gokhlayeh@186
|
2928 if [ -s $i ]; then
|
gokhlayeh@239
|
2929 echo ""
|
gokhlayeh@239
|
2930 echo -e "\033[1m$i\033[0m"
|
gokhlayeh@239
|
2931 echo "================================================================================"
|
gokhlayeh@239
|
2932 cat $i
|
gokhlayeh@239
|
2933 echo "================================================================================"
|
gokhlayeh@239
|
2934 echo ""
|
gokhlayeh@186
|
2935 fi
|
gokhlayeh@186
|
2936 done
|
gokhlayeh@186
|
2937 ;;
|
gokhlayeh@186
|
2938 check-incoming)
|
gokhlayeh@186
|
2939 check_root
|
gokhlayeh@214
|
2940 get_options_list="forced"
|
gokhlayeh@186
|
2941 get_tazwok_config
|
gokhlayeh@186
|
2942 source_lib report
|
gokhlayeh@186
|
2943 report start
|
gokhlayeh@186
|
2944 check_for_incoming
|
gokhlayeh@186
|
2945 ;;
|
gokhlayeh@190
|
2946 configure-chroot)
|
gokhlayeh@190
|
2947 check_root
|
gokhlayeh@190
|
2948 get_tazwok_config
|
gokhlayeh@190
|
2949 if [ -f /usr/bin/tazchroot ]; then
|
gokhlayeh@190
|
2950 cd $LOCAL_REPOSITORY
|
gokhlayeh@190
|
2951 configure_tazchroot
|
gokhlayeh@190
|
2952 else
|
gokhlayeh@190
|
2953 echo "The packages tazchroot need to be installed" >&2
|
gokhlayeh@190
|
2954 exit 1
|
gokhlayeh@190
|
2955 fi
|
gokhlayeh@190
|
2956 ;;
|
gokhlayeh@186
|
2957 chroot)
|
gokhlayeh@186
|
2958 check_root
|
gokhlayeh@186
|
2959 get_tazwok_config
|
gokhlayeh@186
|
2960 # Merge this and the other chroot function ?.
|
gokhlayeh@186
|
2961 if [ -f /usr/bin/tazchroot ]; then
|
gokhlayeh@186
|
2962 cd $LOCAL_REPOSITORY
|
gokhlayeh@186
|
2963 [ ! -f tazchroot.conf ] && configure_tazchroot
|
gokhlayeh@186
|
2964 tazchroot
|
gokhlayeh@186
|
2965 else
|
gokhlayeh@186
|
2966 echo "The packages tazchroot need to be installed" >&2
|
gokhlayeh@186
|
2967 exit 1
|
gokhlayeh@186
|
2968 fi
|
gokhlayeh@186
|
2969 ;;
|
gokhlayeh@186
|
2970 cook-toolchain)
|
gokhlayeh@186
|
2971 check_root
|
gokhlayeh@186
|
2972 get_tazwok_config
|
gokhlayeh@186
|
2973 echo -n "" > $PACKAGES_REPOSITORY/broken
|
gokhlayeh@186
|
2974 if [ -f /usr/bin/tazchroot ]; then
|
gokhlayeh@186
|
2975 cd $LOCAL_REPOSITORY
|
gokhlayeh@186
|
2976 [ ! -f tazchroot.conf ] && configure_tazchroot
|
gokhlayeh@186
|
2977 tazchroot cook-toolchain
|
gokhlayeh@186
|
2978 # Buggy : chroot can be elsewhere.
|
gokhlayeh@186
|
2979 rm -r $LOCAL_REPOSITORY/chroot
|
gokhlayeh@186
|
2980 # /!\ to be writed :
|
gokhlayeh@186
|
2981 # next rm chroot and plan cook-all by pushing all packages
|
gokhlayeh@186
|
2982 # in cooklist.
|
gokhlayeh@186
|
2983 else
|
gokhlayeh@186
|
2984 echo "The packages tazchroot need to be installed" >&2
|
gokhlayeh@186
|
2985 exit 1
|
gokhlayeh@186
|
2986 fi
|
gokhlayeh@186
|
2987 ;;
|
gokhlayeh@235
|
2988 webserver)
|
gokhlayeh@235
|
2989 check_root
|
gokhlayeh@235
|
2990 get_tazwok_config
|
gokhlayeh@235
|
2991 if [ "$ARG" = on ]; then
|
gokhlayeh@235
|
2992 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
|
gokhlayeh@235
|
2993 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
|
gokhlayeh@235
|
2994 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
|
gokhlayeh@235
|
2995 exit 1
|
gokhlayeh@235
|
2996 fi
|
gokhlayeh@235
|
2997 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
|
gokhlayeh@235
|
2998 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
|
gokhlayeh@235
|
2999 fi
|
gokhlayeh@235
|
3000 for pkg in php lighttpd; do
|
gokhlayeh@235
|
3001 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
|
gokhlayeh@235
|
3002 done
|
gokhlayeh@235
|
3003 if [ "$missing" ]; then
|
gokhlayeh@235
|
3004 echo "You need to install those packages to start webserver: $missing." >&2
|
gokhlayeh@235
|
3005 exit 1
|
gokhlayeh@235
|
3006 fi
|
gokhlayeh@235
|
3007 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
|
gokhlayeh@235
|
3008 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
|
gokhlayeh@235
|
3009 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
|
gokhlayeh@235
|
3010 fi
|
gokhlayeh@235
|
3011 if ! [ "$WEBSERVER" ]; then
|
gokhlayeh@235
|
3012 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
|
gokhlayeh@235
|
3013 read WEBSERVER
|
gokhlayeh@235
|
3014 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
|
gokhlayeh@235
|
3015 fi
|
gokhlayeh@235
|
3016 if [ -f "$WEBSERVER/repositories.list" ] && \
|
gokhlayeh@235
|
3017 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
|
gokhlayeh@235
|
3018 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
|
gokhlayeh@235
|
3019 exit 1
|
gokhlayeh@235
|
3020 fi
|
gokhlayeh@235
|
3021 mkdir -p $WEBSERVER
|
gokhlayeh@235
|
3022 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
|
gokhlayeh@235
|
3023 for file in index.php log.php; do
|
gokhlayeh@235
|
3024 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
|
gokhlayeh@235
|
3025 done
|
gokhlayeh@235
|
3026 source $LOCAL_REPOSITORY/tazchroot.conf
|
gokhlayeh@235
|
3027 echo "<?php
|
gokhlayeh@235
|
3028
|
gokhlayeh@235
|
3029 // Web interface configuration
|
gokhlayeh@235
|
3030
|
gokhlayeh@235
|
3031 \$version=\"${undigest:-$SLITAZ_VERSION}\";
|
gokhlayeh@235
|
3032 \$chroot=\"$chroot_dir\";
|
gokhlayeh@235
|
3033 \$lockfile=\"\$chroot/proc/1\";
|
gokhlayeh@235
|
3034 \$db_dir=\"$PACKAGES_REPOSITORY\";
|
gokhlayeh@235
|
3035 \$log_dir=\"$LOCAL_REPOSITORY/log\";
|
gokhlayeh@235
|
3036 \$packages=\"$PACKAGES_REPOSITORY\";
|
gokhlayeh@235
|
3037 \$incoming=\"$INCOMING_REPOSITORY\";
|
gokhlayeh@251
|
3038 \$wok=\"$WOK\";
|
gokhlayeh@235
|
3039
|
gokhlayeh@235
|
3040 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
|
gokhlayeh@235
|
3041 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
|
gokhlayeh@235
|
3042 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
|
gokhlayeh@235
|
3043 if [ -L "$WEBSERVER/conf.php" ]; then
|
gokhlayeh@235
|
3044 echo "Do yo want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
|
gokhlayeh@235
|
3045 read answer
|
gokhlayeh@235
|
3046 if [ "$answer" = y ]; then
|
gokhlayeh@235
|
3047 rm $WEBSERVER/conf.php
|
gokhlayeh@235
|
3048 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
|
gokhlayeh@235
|
3049 fi
|
gokhlayeh@235
|
3050 else
|
gokhlayeh@235
|
3051 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
|
gokhlayeh@235
|
3052 fi
|
gokhlayeh@235
|
3053 elif [ "$ARG" = off ]; then
|
gokhlayeh@235
|
3054 if ! [ "$WEBSERVER" ]; then
|
gokhlayeh@235
|
3055 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
|
gokhlayeh@235
|
3056 exit 1
|
gokhlayeh@235
|
3057 fi
|
gokhlayeh@235
|
3058 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
|
gokhlayeh@235
|
3059 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
|
gokhlayeh@235
|
3060 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
|
gokhlayeh@235
|
3061 if ! [ -s "$WEBSERVER/repositories.list" ]; then
|
gokhlayeh@235
|
3062 echo "$WEBSERVER/repositories.list is empty; tazwok doesn't remove the server automatically in case you have important stuff in it. If it's not the case, you can remove it using: rm -r $WEBSERVER"
|
gokhlayeh@235
|
3063 rm $WEBSERVER/conf.php
|
gokhlayeh@235
|
3064 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
|
gokhlayeh@235
|
3065 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
|
gokhlayeh@235
|
3066 rm $WEBSERVER/conf.php
|
gokhlayeh@235
|
3067 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
|
gokhlayeh@235
|
3068 fi
|
gokhlayeh@235
|
3069 else
|
gokhlayeh@235
|
3070 echo "Usage: tazwok webserver on/off" >&2
|
gokhlayeh@235
|
3071 exit 1
|
gokhlayeh@235
|
3072 fi
|
gokhlayeh@235
|
3073 ;;
|
pankso@7
|
3074 usage|*)
|
MikeDSmith25@82
|
3075 # Print usage also for all unknown commands.
|
pankso@7
|
3076 #
|
pankso@7
|
3077 usage
|
gokhlayeh@186
|
3078 ;;
|
pankso@7
|
3079 esac
|
pankso@7
|
3080
|
gokhlayeh@186
|
3081 report stop 2>/dev/null || exit 0
|