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