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