3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Emerge-Pkg
5 # Copyright (C) 2004 - 2024 The T2 SDE Project
6 # Copyright (C) 2004 - 2006 Rene Rebe <rene@exactcode.de>
8 # This Copyright note is generated by scripts/Create-CopyPatch,
9 # more information can be found in the files COPYING and README.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License version 2.
13 # --- T2-COPYRIGHT-NOTE-END ---
42 .
scripts
/functions.
in
47 echo "Usage: Emerge-Pkg [ -cfg <config> ] [ -dry-run ] [ -force ] [ -nobackup ]"
48 echo "$spacer [ -consider-chksum ] [ -norebuild ] [ -deps=none|fast|indirect ]"
49 echo "$spacer [ -missing=yes|no|only ] [ -optional-deps=yes|no|ask ] [ -download ]"
50 echo "$spacer [ -repository repository-name ] [ -system ] [ pkg-name(s) ]"
52 echo "pkg-name(s) are only optional if a repository is specified."
57 # ---- Parse options + config
67 -cfg) options
="$options $1 $2" config
="$2"; shift ;;
68 -deps=*) deps
=${1/-deps=/} ;;
69 -missing=*) missing
=${1/-missing=/} ;;
70 -optional-deps=*) optional
=${1/-optional-deps=/} ;;
74 -nobackup) backup
=0 ;;
75 -consider-chksum) ignore_chksum
=0 ;;
76 -norebuild) rebuild
=0 ;;
77 -download|
-download-only) downloadonly
=1 ;;
78 -repository) repositories
="$repositories $2"; shift ;;
79 -prefix) options
="$options -prefix $2"; shift ;;
80 -v) options
="$options -v" ;;
81 -noclearsrc) options
="$options -noclearsrc" ;;
82 -xtrace) options
="$options -xtrace" ;;
83 -system) system
=1 deps
=none
;;
84 -*) help_msg
; exit 1 ;;
91 fast|indirect
*|none
) : ;;
93 echo "Unknown dependency resolution mode. Valid are none, fast and indirect."
97 if [ ! -f config
/$config/config
-a $config = "default" ]; then
98 scripts
/Config
-oldconfig
101 .
scripts
/parse-config
103 noautolist
=" 00-dirtree $SDECFG_DEFAULT_CC $SDECFG_LIBC ${SDECFG_LIBC}32 "
110 while read sel _ _ _ pkg _
; do
112 done < <(cat config
/$config/packages
)
116 local pkg
=$1 msg
="$2" typ
=$3
117 local buildtime
=$
(pkgbuildtime
$pkg)
119 [ "$verbose" = 1 ] && echo -n "$msg"
121 # some more check for packages not manually specified
122 if [ $depth != 0 ]; then
123 # no auto update list
124 if [ "$noautolist" != "${noautolist/ $pkg /}" ]; then
125 [ $verbose = 1 ] && echo " Vital, skipped by default."
130 if [ $depth -gt 0 ]; then
131 # optional dep, not yet installed?
132 if [ "$typ" = '[OPT]' ]; then
133 if [ "$optional" = ask
]; then
134 echo -n " Add optional dep? (y/N$(fmt_time $buildtime)) "
136 # force further updates? TODO: limit input validation
137 [[ "$in" = *\
* ]] && optional
=$in
141 echo " Optional added. $(fmt_time $buildtime)" ||
142 echo " Optional, skipped."
145 if [[ "$in" = y
* ]]; then
147 esttime
=$
((esttime
+ buildtime
))
148 [ "$deps" = indirect
] && dep4pkg
"$pkg"
149 [ "$deps" = indirect2
-a $depth -le 2 ] && dep4pkg
"$pkg"
154 # missing ones? yes, no, only TODO: maybe delete
155 if [ ! -f /var
/adm
/packages
/$pkg ]; then
156 if [ "$missing" = 'no' ]; then
157 [ $verbose = 1 ] && echo " Not missing, skipped."
160 elif [ "$missing" = 'only' ]; then
161 [ $verbose = 1 ] && echo " Only missing selected, skipped."
166 [ $verbose = 1 ] && echo " Added.$(fmt_time $buildtime)"
168 esttime
=$
((esttime
+ buildtime
))
169 [ "$deps" = indirect
] && dep4pkg
"$pkg"
170 [ "$deps" = indirect2
-a $depth -le 2 ] && dep4pkg
"$pkg"
177 if [ "${scanned[$pkg]}" = 1 ]; then
178 [ $debug = 1 ] && echo "already been at $pkg ..."
185 [ ${#packages[@]} = 0 ] && read_packages
187 [ $verbose = 1 ] && echo -n "$deptree$pkg:"
189 for x
in package
/*/$pkg/$pkg.desc
; do
191 if [ "$confdir" ]; then
192 echo " Warning: Package in multiple trees! Skipped."
195 confdir
=${x/$pkg.desc/}
198 if [ -z "$confdir" ]; then
199 if [ $depth = 0 ]; then
200 echo " Error: No such package."
203 echo " Warning: No such package."
208 # TODO: keep unselected in the config, to avoid re-config for masked pkgs
209 if [ -z "${packages[$pkg]}" ]; then
210 if [ $depth = 0 ]; then
211 local desc
=$
(echo package
/*/$pkg/$pkg.desc
)
212 if [ -e "$desc" ]; then
213 echo " Package not cached, re-reading config:"
214 scripts
/Config
-oldconfig -cfg $config
218 if [ -z "${packages[$pkg]}" ]; then
219 echo " Error: No such package."
223 echo " Warning: No such package."
228 if [ "${packages[$pkg]}" != X
]; then
229 echo " Not selected."
233 if [ ! -f /var
/adm
/packages
/$pkg ]; then
234 if [ "$typ" = "[OPT]" ]; then
235 add_if_req
$pkg ' Not installed.' $typ
237 add_if_req
$pkg ' Not installed.'
242 o_ver
=$
(grep -a '^Package Name and Version' \
243 /var
/adm
/packages
/$pkg | cut
-f6 -d' ')
244 # we avoid parse_desc here, because it is ~50x slower
245 n_ver
=$
(grep -a '^\[V\] ' $confdir/$pkg.desc \
246 architecture
/$SDECFG_ARCH/package
/$pkg/$pkg.desc \
247 target
/$SDECFG_TARGET/package
/$pkg/$pkg.desc \
248 2> /dev
/null | cut
-f2 -d' ' |
tail -n 1)
249 if [ "$o_ver" != "$n_ver" -a "$n_ver" != "0000" ]; then
250 add_if_req
$pkg " New version ($o_ver -> $n_ver)."
254 o_ck
=$
(grep -a '^\(ROCK Linux\|T2\) Package Source Checksum' \
255 /var
/adm
/packages
/$pkg |
sed 's,.*: ,,')
256 n_ck
=$
(pkgchksum package
/*/$pkg)
257 if [ $ignore_chksum = 0 -a "$o_ck" != "$n_ck" ]; then
258 add_if_req
$pkg " New source checksum."
262 if [ -f /var
/adm
/cache
/$pkg ] &&
263 grep -a -q '\[BUILDTIME\] .* ERROR' \
264 /var
/adm
/cache
/$pkg; then
265 [ $verbose = 1 ] && echo -n " Former build was broken."
266 if [ $rebuild = 1 ]; then
269 [ $verbose = 1 ] && echo " Skipped."
274 if [ $force = 1 -a $depth = 0 ]; then
275 add_if_req
$pkg ' Build forced.'
279 if [ $debug = 1 ]; then
280 echo " Installed and up-to-date."
289 local _deptree
="$deptree"
290 deptree
="$deptree$1|"
293 for dep
in `grep -a '\[\(DEP\|OPT\)\]' package/*/$1/$1.cache 2>/dev/null`; do
294 add_if_updated
${dep#* } ${dep% *}
301 # the remaining arguments are packages to be built
303 # override previously unselected dependency scan
304 [ "${deplist[$pkg]}" ] || scanned
[$pkg]=
308 # packages from repositories
309 for x
in $repositories; do
310 for pkg
in `egrep -a "^X .* $x .*" config/$config/packages |
316 # all installed packages if a system update
317 if [ "$system" ]; then
319 for pkg
in `cd /var/adm/packages/; ls *`; do
325 # The deplist is unsorted: sort by priority and convert to string.
327 deplist
=`echo -n "${!deplist[@]}" | tr '\n' ' ' | tr -s ' '`
328 deplist
=$
(grep -a "^. .* .* .* \\(${deplist// /\\|}\\) " \
329 config
/$config/packages |
sort -k 3 | cut
-d ' ' -f 5 |
tr '\n' ' ')
331 if [ "$deplist" ]; then
332 echo "$(echo "$deplist" |
333 wc -w) packages scheduled to build$(fmt_time $esttime): $deplist" |
fold -s
336 echo "No package scheduled to build."
339 [ $dryrun = 1 ] && exit
340 [ $backup = 1 ] && options
="$options -update"
342 for pkg
in $deplist; do
343 if scripts
/Download
-cfg $config $dloptions $pkg; then
344 if [ $downloadonly != 1 ] &&
345 ! scripts
/Build-Pkg
$options $pkg; then
346 if [ $SDECFG_CONTINUE_ON_ERROR_AFTER -gt 8 ]; then
347 echo "Aborting further builds due to config setting CONTINUE_ON_ERROR_AFTER."
352 echo "The download for package $pkg failed!"
356 [ "${dloptions/-quiet-mirror/}" = "$dloptions" ] &&
357 var_append dloptions
" " "-quiet-mirror"