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