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 ---
17 noautolist
=' 00-dirtree binutils gcc glibc glibc32 uclibc musl linux linux-header clang llvm rustc cargo dietlibc busybox toybox '
44 .
scripts
/functions.
in
49 echo "Usage: Emerge-Pkg [ -cfg <config> ] [ -dry-run ] [ -force ] [ -nobackup ]"
50 echo "$spacer [ -consider-chksum ] [ -norebuild ] [ -deps=none|fast|indirect ]"
51 echo "$spacer [ -missing=yes|no|only ] [ -optional-deps=yes|no|ask ] [ -download ]"
52 echo "$spacer [ -repository repository-name ] [ -system ] [ pkg-name(s) ]"
54 echo "pkg-name(s) are only optional if a repository is specified."
59 # ---- Parse options + config
69 -cfg) options
="$options $1 $2" config
="$2"; shift ;;
70 -deps=*) deps
=${1/-deps=/} ;;
71 -missing=*) missing
=${1/-missing=/} ;;
72 -optional-deps=*) optional
=${1/-optional-deps=/} ;;
76 -nobackup) backup
=0 ;;
77 -consider-chksum) ignore_chksum
=0 ;;
78 -norebuild) rebuild
=0 ;;
79 -download|
-download-only) downloadonly
=1 ;;
80 -repository) repositories
="$repositories $2"; shift ;;
81 -prefix) options
="$options -prefix $2"; shift ;;
82 -v) options
="$options -v" ;;
83 -system) system
=1 deps
=none depth
=1 ;;
84 -*) help_msg
; exit 1 ;;
90 if [ ! -f config
/$config/config
-a $config = "default" ]; then
91 scripts
/Config
-oldconfig
94 .
scripts
/parse-config
97 local pkg
=$1 msg
="$2" typ
=$3
98 local buildtime
=$
(pkgbuildtime
$pkg)
100 [ "$verbose" = 1 ] && echo -n "$msg"
102 # some more check for packages not manually specified
103 if [ $depth != 0 ]; then
104 # no auto update list
105 if [ "$noautolist" != "${noautolist/ $pkg /}" ]; then
106 [ $verbose = 1 ] && echo " Vital, skipped by default."
110 # optional dep, not yet installed?
111 if [ "$typ" = '[OPT]' ]; then
112 if [ "$optional" = ask
]; then
113 echo -n " Add optional dep? (y/n$(fmt_time $buildtime)) "
118 echo " Optional added. $(fmt_time $buildtime)" ||
119 echo " Optional, skipped."
122 if [[ "$in" = y
* ]]; then
123 var_append deplist
" " "$pkg"
124 esttime
=$
((esttime
+ buildtime
))
125 [ "$deps" = indirect
] && dep4pkg
"$pkg"
126 [ "$deps" = indirect2
-a $depth -le 2 ] && dep4pkg
"$pkg"
131 # missing ones? yes, no, only TODO: maybe delete
132 if [ ! -f /var
/adm
/packages
/$pkg ]; then
133 if [ "$missing" = 'no' ]; then
134 [ $verbose = 1 ] && echo " Not missing, skipped."
137 elif [ "$missing" = 'only' ]; then
138 [ $verbose = 1 ] && echo " Only missing selected, skipped."
143 [ $verbose = 1 ] && echo " Added.$(fmt_time $buildtime)"
144 var_append deplist
" " "$pkg"
145 esttime
=$
((esttime
+ buildtime
))
146 [ "$deps" = indirect
] && dep4pkg
"$pkg"
147 [ "$deps" = indirect2
-a $depth -le 2 ] && dep4pkg
"$pkg"
156 local x
="${scanned[$pkg]}"
157 if [ "$x" = 1 ]; then
158 [ $debug = 1 ] && echo "already been at $pkg ..."
164 [ $verbose = 1 ] && echo -n "$deptree> $pkg ..."
166 for x
in package
/*/$pkg/$pkg.desc
; do
168 if [ "$confdir" ]; then
169 echo " Warning: Package in multiple trees! Skipped."
172 confdir
=${x/$pkg.desc/}
175 if [ -z "$confdir" ]; then
176 if [ $depth = 0 ]; then
177 echo " Error: No such package."
180 echo " Warning: No such package."
185 if [ ! -f /var
/adm
/packages
/$pkg ]; then
186 if [ "$typ" = "[OPT]" ]; then
187 add_if_req
$pkg ' Not installed.' $typ
189 add_if_req
$pkg ' Not installed.'
194 o_ver
=$
(grep -a '^Package Name and Version' \
195 /var
/adm
/packages
/$pkg | cut
-f6 -d' ')
196 # we avoid parse_desc here, because it is ~50x slower
197 n_ver
=$
(grep -a '^\[V\] ' $confdir/$pkg.desc \
198 architecture
/$SDECFG_ARCH/package
/$pkg/$pkg.desc \
199 target
/$SDECFG_TARGET/package
/$pkg/$pkg.desc \
200 2> /dev
/null | cut
-f2 -d' ' |
tail -n 1)
201 if [ "$o_ver" != "$n_ver" -a "$n_ver" != "0000" ]; then
202 add_if_req
$pkg " New version ($o_ver -> $n_ver)."
206 o_ck
=$
(grep -a '^\(ROCK Linux\|T2\) Package Source Checksum' \
207 /var
/adm
/packages
/$pkg |
sed 's,.*: ,,')
208 n_ck
=$
(pkgchksum package
/*/$pkg)
209 if [ $ignore_chksum = 0 -a "$o_ck" != "$n_ck" ]; then
210 add_if_req
$pkg " New source checksum."
214 if [ -f /var
/adm
/cache
/$pkg ] &&
215 grep -a -q '\[BUILDTIME\] .* ERROR' \
216 /var
/adm
/cache
/$pkg; then
217 [ $verbose = 1 ] && echo -n " Former build was broken."
218 if [ $rebuild = 1 ]; then
221 [ $verbose = 1 ] && echo " Skipped."
226 if [ $force = 1 -a $depth = 0 ]; then
227 add_if_req
$pkg ' Build forced.'
231 if [ $debug = 1 ]; then
232 echo " Installed and up-to-date."
241 local _deptree
="$deptree"
242 var_append deptree
'>' "$1"
245 for dep
in `grep -a '\[\(DEP\|OPT\)\]' package/*/$1/$1.cache 2>/dev/null`; do
246 add_if_updated
${dep#* } ${dep% *}
253 # the remaining arguments are packages to be built
258 # packages from repositories
259 for x
in $repositories; do
260 for x
in `egrep -a "^X .* $x .*" config/$config/packages |
266 # all installed packages if a system update
267 if [ $system -eq 1 ]; then
268 for x
in `cd /var/adm/packages/; ls *`; do
275 # we have to create a complete dependency graph ...
276 for x
in $deplist; do
283 echo "Unknown dependency resolution mode. Valid are none, fast and indirect."
287 # The deplist is quite unsorted (in alphabetically sorted chunks)
288 # so we need to work arround this here ...
291 deplist
=`echo -n $deplist | tr '\n' ' ' | tr -s ' '`
292 deplist
=$
(grep -a "^. .* .* .* \\(${deplist// /\\|}\\) " \
293 config
/$config/packages |
sort -k 3 | cut
-d ' ' -f 5 |
tr '\n' ' ')
295 if [ "$deplist" ]; then
296 echo "$(echo "$deplist" |
297 wc -w) packages scheduled to build$(fmt_time $esttime): $deplist" |
fold -s
300 echo "No package scheduled to build."
303 [ $dryrun = 1 ] && exit
305 [ $backup = 1 ] && options
="$options -update"
307 . config
/$config/config
309 for pkg
in $deplist; do
310 if scripts
/Download
-cfg $config $dloptions $pkg; then
311 if [ $downloadonly != 1 ] &&
312 ! scripts
/Build-Pkg
$options $pkg; then
313 if [ $SDECFG_CONTINUE_ON_ERROR_AFTER -gt 8 ]; then
314 echo "Aborting further builds due to config setting CONTINUE_ON_ERROR_AFTER."
319 echo "The download for package $pkg failed!"
323 [ "${dloptions/-quiet-mirror/}" = "$dloptions" ] &&
324 var_append dloptions
" " "-quiet-mirror"