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 ;;
90 if [ ! -f config
/$config/config
-a $config = "default" ]; then
91 scripts
/Config
-oldconfig
94 .
scripts
/parse-config
96 noautolist
=' 00-dirtree $SDECFG_DEFAULT_CC $SDECFG_LIBC ${SDECFG_LIBC}32 '
101 local pkg
=$1 msg
="$2" typ
=$3
102 local buildtime
=$
(pkgbuildtime
$pkg)
104 [ "$verbose" = 1 ] && echo -n "$msg"
106 # some more check for packages not manually specified
107 if [ $depth != 0 ]; then
108 # no auto update list
109 if [ "$noautolist" != "${noautolist/ $pkg /}" ]; then
110 [ $verbose = 1 ] && echo " Vital, skipped by default."
114 # optional dep, not yet installed?
115 if [ "$typ" = '[OPT]' ]; then
116 if [ "$optional" = ask
]; then
117 echo -n " Add optional dep? (y/n$(fmt_time $buildtime)) "
122 echo " Optional added. $(fmt_time $buildtime)" ||
123 echo " Optional, skipped."
126 if [[ "$in" = y
* ]]; then
128 esttime
=$
((esttime
+ buildtime
))
129 [ "$deps" = indirect
] && dep4pkg
"$pkg"
130 [ "$deps" = indirect2
-a $depth -le 2 ] && dep4pkg
"$pkg"
135 # missing ones? yes, no, only TODO: maybe delete
136 if [ ! -f /var
/adm
/packages
/$pkg ]; then
137 if [ "$missing" = 'no' ]; then
138 [ $verbose = 1 ] && echo " Not missing, skipped."
141 elif [ "$missing" = 'only' ]; then
142 [ $verbose = 1 ] && echo " Only missing selected, skipped."
147 [ $verbose = 1 ] && echo " Added.$(fmt_time $buildtime)"
149 esttime
=$
((esttime
+ buildtime
))
150 [ "$deps" = indirect
] && dep4pkg
"$pkg"
151 [ "$deps" = indirect2
-a $depth -le 2 ] && dep4pkg
"$pkg"
158 if [ "${scanned[$pkg]}" = 1 ]; then
159 [ $debug = 1 ] && echo "already been at $pkg ..."
165 [ $verbose = 1 ] && echo -n "$deptree> $pkg ..."
167 for x
in package
/*/$pkg/$pkg.desc
; do
169 if [ "$confdir" ]; then
170 echo " Warning: Package in multiple trees! Skipped."
173 confdir
=${x/$pkg.desc/}
176 if [ -z "$confdir" ]; then
177 if [ $depth = 0 ]; then
178 echo " Error: No such package."
181 echo " Warning: No such package."
186 if [ ! -f /var
/adm
/packages
/$pkg ]; then
187 if [ "$typ" = "[OPT]" ]; then
188 add_if_req
$pkg ' Not installed.' $typ
190 add_if_req
$pkg ' Not installed.'
195 o_ver
=$
(grep -a '^Package Name and Version' \
196 /var
/adm
/packages
/$pkg | cut
-f6 -d' ')
197 # we avoid parse_desc here, because it is ~50x slower
198 n_ver
=$
(grep -a '^\[V\] ' $confdir/$pkg.desc \
199 architecture
/$SDECFG_ARCH/package
/$pkg/$pkg.desc \
200 target
/$SDECFG_TARGET/package
/$pkg/$pkg.desc \
201 2> /dev
/null | cut
-f2 -d' ' |
tail -n 1)
202 if [ "$o_ver" != "$n_ver" -a "$n_ver" != "0000" ]; then
203 add_if_req
$pkg " New version ($o_ver -> $n_ver)."
207 o_ck
=$
(grep -a '^\(ROCK Linux\|T2\) Package Source Checksum' \
208 /var
/adm
/packages
/$pkg |
sed 's,.*: ,,')
209 n_ck
=$
(pkgchksum package
/*/$pkg)
210 if [ $ignore_chksum = 0 -a "$o_ck" != "$n_ck" ]; then
211 add_if_req
$pkg " New source checksum."
215 if [ -f /var
/adm
/cache
/$pkg ] &&
216 grep -a -q '\[BUILDTIME\] .* ERROR' \
217 /var
/adm
/cache
/$pkg; then
218 [ $verbose = 1 ] && echo -n " Former build was broken."
219 if [ $rebuild = 1 ]; then
222 [ $verbose = 1 ] && echo " Skipped."
227 if [ $force = 1 -a $depth = 0 ]; then
228 add_if_req
$pkg ' Build forced.'
232 if [ $debug = 1 ]; then
233 echo " Installed and up-to-date."
242 local _deptree
="$deptree"
243 var_append deptree
'>' "$1"
246 for dep
in `grep -a '\[\(DEP\|OPT\)\]' package/*/$1/$1.cache 2>/dev/null`; do
247 add_if_updated
${dep#* } ${dep% *}
254 # the remaining arguments are packages to be built
256 # override previously unselected dependency scan
257 [ "${deplist[$pkg]}" ] || scanned
[$pkg]=
261 # packages from repositories
262 for x
in $repositories; do
263 for pkg
in `egrep -a "^X .* $x .*" config/$config/packages |
269 # all installed packages if a system update
270 if [ "$system" ]; then
271 for pkg
in `cd /var/adm/packages/; ls *`; do
278 # we have to create a complete dependency graph ...
279 for pkg
in ${!deplist[@]}; do
286 echo "Unknown dependency resolution mode. Valid are none, fast and indirect."
290 # The deplist is unsorted: sort by priority and convert to string.
292 deplist
=`echo -n "${!deplist[@]}" | tr '\n' ' ' | tr -s ' '`
293 deplist
=$
(grep -a "^. .* .* .* \\(${deplist// /\\|}\\) " \
294 config
/$config/packages |
sort -k 3 | cut
-d ' ' -f 5 |
tr '\n' ' ')
296 if [ "$deplist" ]; then
297 echo "$(echo "$deplist" |
298 wc -w) packages scheduled to build$(fmt_time $esttime): $deplist" |
fold -s
301 echo "No package scheduled to build."
304 [ $dryrun = 1 ] && exit
305 [ $backup = 1 ] && options
="$options -update"
307 for pkg
in $deplist; do
308 if scripts
/Download
-cfg $config $dloptions $pkg; then
309 if [ $downloadonly != 1 ] &&
310 ! scripts
/Build-Pkg
$options $pkg; then
311 if [ $SDECFG_CONTINUE_ON_ERROR_AFTER -gt 8 ]; then
312 echo "Aborting further builds due to config setting CONTINUE_ON_ERROR_AFTER."
317 echo "The download for package $pkg failed!"
321 [ "${dloptions/-quiet-mirror/}" = "$dloptions" ] &&
322 var_append dloptions
" " "-quiet-mirror"