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