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