3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # This copyright note is auto-generated by scripts/Create-CopyPatch.
6 # T2 SDE: scripts/Emerge-Pkg
7 # Copyright (C) 2004 - 2020 The T2 SDE Project
8 # Copyright (C) 2004 - 2006 Rene Rebe <rene@exactcode.de>
10 # More information can be found in the files COPYING and README.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; version 2 of the License. A copy of the
15 # GNU General Public License can be found in the file COPYING.
16 # --- T2-COPYRIGHT-NOTE-END ---
20 blacklist
=' 00-dirtree binutils gcc glibc glibc32 uclibc linux linux-header clang llvm musl dietlibc '
44 .
scripts
/functions.
in
49 echo "Usage: Emerge-Pkg [ -cfg <config> ] [ -dry-run ] [ -force ] [ -nobackup ]"
50 echo "$spacer [ -consider-chksum ] [ -norebuild ]"
51 echo "$spacer [ -deps=none|fast|indirect ] [ -missing=yes|no|only ] [ -download-only ]"
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=/} ;;
75 -nobackup) backup
=0 ;;
76 -consider-chksum) ignore_chksum
=0 ;;
77 -norebuild) rebuild
=0 ;;
78 -download-only) downloadonly
=1 ;;
79 -repository) repositories
="$repositories $2"
80 deps
=none
; depth
=1; 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 .
scripts
/parse-config
94 [ "$verbose" = 1 ] && echo -n "$1"
96 # some more check for packages not manually specified
97 if [ $depth != 0 ]; then
99 if [ "$blacklist" != "${blacklist/ $package /}" ]; then
100 [ $verbose = 1 ] && echo " Automatic update avoided."
104 # missing ones? yes, no, only
105 if [ ! -f /var
/adm
/packages
/$package ]; then
106 if [ "$missing" = 'no' ]; then
107 [ $verbose = 1 ] && echo " Not missing, skipped."
110 elif [ "$missing" = 'only' ]; then
111 [ $verbose = 1 ] && echo " Only missing selected, skipped."
116 [ $verbose = 1 ] && echo " Added."
117 var_append deplist
" " "$package"
118 [ "$deps" = indirect
] && dep4pkg
"$package"
125 # some variable name mangling ...
126 local var
="__BEEN_HERE_${package//[^a-zA-Z0-9]/_}"
128 if [ "$x" = 1 ]; then
129 [ $debug = 1 ] && echo "already been at $package ..."
135 [ $verbose = 1 ] && echo -n "$deptree> $package ..."
137 for x
in package
/*/$package/$package.desc
; do
139 if [ "$confdir" ]; then
140 echo " Error: Package in multiple trees!"
143 confdir
=${x/$package.desc/}
146 if [ -z "$confdir" ]; then
147 echo " Error: No such package."
151 if [ ! -f /var
/adm
/packages
/$package ]; then
152 add_if_req
' Not installed.'
156 o_ver
=$
(grep '^Package Name and Version' \
157 /var
/adm
/packages
/$package | cut
-f6 -d' ')
158 # we avoid parse_desc here, because it takes approx. 50 slower
159 n_ver
=$
(grep '^\[V\] ' $confdir/$package.desc \
160 architecture
/$SDECFG_ARCH/package
/$package/$package.desc \
161 target
/$SDECFG_TARGET/package
/$package/$package.desc \
162 2> /dev
/null | cut
-f2 -d' ' |
tail -n 1)
163 if [ "$o_ver" != "$n_ver" -a "$n_ver" != "0000" ]; then
164 add_if_req
" New version ($o_ver -> $n_ver)."
168 o_ck
=$
(grep '^\(ROCK Linux\|T2\) Package Source Checksum' \
169 /var
/adm
/packages
/$package |
sed 's,.*: ,,')
170 n_ck
=$
( pkgchksum package
/*/$package )
171 if [ $ignore_chksum = 0 -a "$o_ck" != "$n_ck" ]; then
172 add_if_req
" New source checksum."
176 if [ -f /var
/adm
/cache
/$package ] &&
177 grep -q '\[BUILDTIME\] .* ERROR' \
178 /var
/adm
/cache
/$package; then
179 [ $verbose = 1 ] && echo -n " Former build was broken."
180 if [ $rebuild = 1 ]; then
183 [ $verbose = 1 ] && echo " Skipped."
188 if [ $force = 1 -a $depth = 0 ]; then
189 add_if_req
' Build forced.'
193 if [ $debug = 1 ]; then
194 echo " Installed and up-to-date."
204 var_append deptree
'>' "$1"
205 for x
in `grep '\[DEP\]' package/*/$1/$1.cache 2>/dev/null |
209 var_remove deptree
'>' "$1" # or cache the previous value?
213 # the remaining arguments are packages to be built
218 # packages from repositories
219 for x
in $repositories; do
220 for x
in `egrep "^X .* $x .*" config/$config/packages |
226 # all installed packages if a system update
227 if [ $system -eq 1 ]; then
228 for x
in `cd /var/adm/packages/; ls *`; do
235 # we have to create a complete dependency graph ...
237 for x
in $deplist; do
244 echo "Unknown dependency resolution mode. Valid are none, fast and indirect."
248 # The deplist is quite unsorted (in alphabetically sorted chunks)
249 # so we need to work arround this here ...
252 deplist
=`echo -n $deplist | tr '\n' ' ' | tr -s ' '`
253 deplist
=$
(grep "^. .* .* .* \\(${deplist// /\\|}\\) " \
254 config
/$config/packages |
sort -k 3 | cut
-d ' ' -f 5 |
tr '\n' ' ')
256 if [ "$deplist" ]; then
257 echo "$(echo "$deplist" |
258 wc -w) packages scheduled to build: $deplist" |
fold -s
261 echo "0 packages scheduled to build."
264 [ $dryrun = 1 ] && exit
266 [ $backup = 1 ] && options
="$options -update"
268 . config
/$config/config
270 for package
in $deplist; do
271 if scripts
/Download
-cfg $config $package; then [ $downloadonly != 1 ] &&
272 if ! scripts
/Build-Pkg
$options $package; then
273 if [ $SDECFG_CONTINUE_ON_ERROR_AFTER -gt 8 ]; then
274 echo "Aborting further builds due to config setting CONTINUE_ON_ERROR_AFTER."
279 echo "The download for package $package failed!"