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