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