2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # Filename: scripts/Emerge-Pkg
6 # Copyright (C) 2006 - 2008 The OpenSDE Project
7 # Copyright (C) 2004 - 2006 The T2 SDE Project
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 as published by
13 # the Free Software Foundation; version 2 of the License. A copy of the
14 # GNU General Public License can be found in the file COPYING.
15 # --- SDE-COPYRIGHT-NOTE-END ---
19 blacklist
=" 00-dirtree binutils gcc glibc glibc32 uclibc linux24 linux26 linux-header "
45 echo "Usage: Emerge-Pkg [ -cfg <config> ] [ -dry-run ] [ -force ] [ -noupdate ]"
46 echo "$spacer [ -consider-chksum ] [ -norebuild ]"
47 echo "$spacer [ -deps=none|fast|indirect ] [ -download-only ]"
48 echo "$spacer [ -repository repository-name ] [ -system ] [ pkg-name(s) ]"
50 echo "pkg-name(s) are only optional if a repository is specified."
55 # ---- Parse options + config
65 -cfg) options
="$options $1 $2" ; config
="$2" ; shift ;;
66 -deps=*) deps
=${1/-deps=/} ;;
70 -noupdate) update
=0 ;;
71 -consider-chksum) ignore_chksum
=0 ;;
72 -norebuild) rebuild
=0 ;;
73 -download-only) downloadonly
=1 ;;
74 -repository) repositories
="$repositories $2"
76 -prefix) options
="$options -prefix $2" ; shift ;;
77 -system) system
=1 ; deps
=none
;;
78 -*) help_msg
; exit 1 ;;
88 [ "$verbose" = 1 ] && echo -n "$1"
90 if [ $depth != 0 -a "$blacklist" != "${blacklist/ $package /}" ]; then
91 [ $verbose = 1 ] && echo " Automatic update avoided."
93 [ $verbose = 1 ] && echo " Added."
94 var_append deplist
" " "$package"
95 [ $deps = indirect
] && dep4pkg
"$package"
103 # some variable name mangling ...
104 local var
=__BEEN_HERE_
${package//-/_}
107 if [ "$x" = 1 ]; then
108 [ $debug = 1 ] && echo "already been at $package ..."
114 [ $verbose = 1 ] && echo -n "checking $package ..."
116 for x
in package
/*/$package/$package.desc
; do
118 if [ "$confdir" ]; then
119 echo " Error: Package in multiple trees!"
122 confdir
=${x/$package.desc/}
125 if [ -z "$confdir" ]; then
126 echo " Error: No such package."
130 if [ ! -f /var
/adm
/packages
/$package ]; then
131 add_if_req
' Not installed.'
135 o_ver
=$
(grep '^Package Name and Version' \
136 /var
/adm
/packages
/$package | cut
-f6 -d' ')
137 n_ver
=$
(grep '^\[V\] ' $confdir/$package.desc | cut
-f2 -d' ')
138 if [ "$o_ver" != "$n_ver" -a "$n_ver" != "0000" ]; then
139 add_if_req
" New version ($o_ver -> $n_ver)."
143 o_ck
=$
(grep '^\(ROCK Linux\|T2\|OpenSDE\) Package Source Checksum' \
144 /var
/adm
/packages
/$package |
sed 's,.*: ,,')
145 n_ck
=$
( pkgchksum package
/*/$package )
146 if [ $ignore_chksum = 0 -a "$o_ck" != "$n_ck" ]; then
147 add_if_req
" New source checksum."
151 if [ -f /var
/adm
/cache
/$package ] &&
152 grep -q '\[BUILDTIME\] .* ERROR' \
153 /var
/adm
/cache
/$package; then
154 [ $verbose = 1 ] && echo -n " Former build was broken."
155 if [ $rebuild = 1 ]; then
158 [ $verbose = 1 ] && echo " Skipped."
163 if [ $force = 1 -a $depth = 0 ]; then
164 add_if_req
' Build forced.'
168 if [ $debug = 1 ]; then
169 echo " Installed and up-to-date."
179 for x
in `grep '\[DEP\]' package/*/$1/$1.cache 2>/dev/null |
186 # the remaining arguments are packages to be built
191 # packages from repositories
192 for x
in $repositories ; do
193 for x
in `egrep "^X .* $x .*" config/$config/packages |
199 # all packages if a system update
200 if [ $system -eq 1 ]; then
201 for x
in `grep "^X" config/$config/packages | cut -d ' ' -f 5`; do
208 # we have to create a complete dependency graph ...
210 for x
in $deplist ; do
217 echo "Unknown dependency resolution mode. Valid are none and fast."
222 deplist
=`echo -n $deplist | tr '\n' ' ' | tr -s ' '`
223 deplist
=`grep "^. .* .* .* \\(${deplist// /\\|}\\) " \
224 config/$config/packages | sort -k 3 | cut -d ' ' -f 5 | tr '\n' ' '`
226 echo "Packages scheduled to build: ${deplist:-none}"
228 [ $dryrun = 1 ] && exit
230 # the deplist is quite unsorted (in alphabetically sorted chunks)
231 # so we need to work arround this here ...
233 [ $update = 1 ] && options
="$options -update"
235 . config
/$config/config
237 for package
in $deplist ; do
238 if .
/bin
/sde-download
$package ; then [ $downloadonly != 1 ] && \
239 if ! .
/scripts
/Build-Pkg
$options $package; then
240 if [ $SDECFG_CONTINUE_ON_ERROR_AFTER -gt 8 ]; then
241 echo "Aborting further builds, check SDECFG_CONTINUE_ON_ERROR_AFTER."
246 echo "The download for package $package failed!"