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