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