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