3 # This script must be executed with the following environment variables
6 # export FROZEN_DIR=<place to write conf files>
7 # export PKGDIR=<location of openembedded package source>
8 # export DISTRO=<distro being frozen>
11 # where {directories} are one or more directories containing built
12 # packages. If not given or empty FROZEN_DIR defaults to the directory
13 # on BBPATH containing conf/local.conf. With no arguments $TMPDIR/work must
14 # be the location of the built packages.
16 # The output of the script consists of two files:
17 # $FROZEN_DIR/$DISTRO-bbfiles.conf
18 # defines BBFILES to a list of all the .bb files required
20 # $FROZEN_DIR/$DISTRO-packages.conf
21 # defines BBFILES to a list of the directories containing
24 # The output path definitions use ${PKGDIR} (literally)
26 # Check the arguments.
27 test -n "$DISTRO" || {
28 echo "FATAL: freeze: set \$DISTRO to the name of the distro to freeze" >&2
31 test -r "$PKGDIR/packages/freeze/freeze.bb" || {
32 echo "FATAL: freeze: set \$PKGDIR to the directory containing OE packages" >&2
35 if test -n "$FROZEN_DIR" -a -d "$FROZEN_DIR"
37 : # ok, given a directory
42 for d in ${BBPATH//:/ }
44 if test -r "$d/conf/local.conf"
48 elif test -z "$FROZEN_DIR" -a -d "$d"
50 # default to the first existing directory on
56 if test -n "$FROZEN_DIR"
58 echo "NOTE: freeze: \$FROZEN_DIR=\"$FROZEN_DIR\"" >&2
59 echo "NOTE: (defaulted from \$BBPATH=\"$BBPATH\")" >&2
61 echo "FATAL: freeze: set \$FROZEN_DIR to the directory for the new .conf files" >&2
66 if test -d "$TMPDIR/work"
70 echo "FATAL: freeze: give one or more directories containing built packages" >&2
75 # First some helper functions
77 # output "$@" if there is exactly one argument (so this selectively
78 # outputs a file name if the pattern matches exactly one file).
80 if test $# -eq 1 -a -r "$1"
82 echo '${PKGDIR}/packages/'"$1 \\"
89 # Perform edit '$1' on '$2' and check to see if the result is a valid
90 # file name. If '$1' is empty '$2' is checked with no edit
95 nf="$(echo "$2" | sed -n "$1")"
96 test -n "$nf" && output */$nf.bb
102 # Output a note - because bitbake swallows the stderr stream and redirects to the
103 # log file, which never gets read, it is necessary to do something horrible here.
105 echo "ERROR:" "$@" >/dev/tty
108 echo "NOTE:" "$@" >/dev/tty
111 # Say where the files go (this goes to the log file)
112 bbnote "frozen bbfiles.conf --> $FROZEN_DIR/$DISTRO-bbfiles.conf" >&2
113 bbnote "frozen packages.conf --> $FROZEN_DIR/$DISTRO-packages.conf" >&2
115 # List the built packages, for each one find the corresponding bb file
116 # (from the packages directory).
119 (cd "$d"; ls) | while read x
129 bberror "$full: not a directory, ignored" >&2
130 elif echo "$d" | egrep '\-[^-][^-]*-[a-z][a-z]*[0-9][0-9.]*$'
134 bberror "$full: expected package-version-rev" >&2
137 bberror " name not recognised as a package and so ignored" >&2
144 bberror "$report: at least this directory was ignored" >&2
145 bberror " The output files may be wrong, some .bb files may be missing!" >&2
147 } | sed 's/^\(.*\)-\([^-]*\)-\([^-]*\)$/\1 \2 \3/' | {
148 # the check commands need to be executed from the packages directory so they
149 # can use shell wildcarding to match the bb files
150 cd "$PKGDIR/packages"
151 # This would be several orders of magnitude easier if portmap did not have
152 # the version '5-7' (etc). This is the only package with a '-' in the
157 # Each package/version must be found in $PKGDIR/packages, this search
158 # is a heuristic, note that there are never any '_' characters in the
159 # work directory name.
162 check 's/-/[-_]/gp' "$p-$v" ||
163 check 's/_1\.0$//p' "$f" ||
164 check 's/_\([0-9.]*\)cvs200[0-9]*$/_\1cvs/p' "$f" ||
165 check 's/_\([0-9.]*\)+cvs200[0-9]*$/_\1+cvs/p' "$f" ||
166 check 's/_0\.1cvs200[0-9]*$/_cvs/p' "$f" ||
167 check 's/_\([0-9.]*\)+cvs200[0-9]*$/_cvs/p' "$f" ||
168 check 's/_0\.1cvs\(200[0-9]*\)$/_\1/p' "$f" ||
169 check 's/_\([0-9.]*\)+svn200[0-9]*$/_svn/p' "$f" || {
170 bberror "($p,$v,$r): package not found" >&2
174 bberror "at least one package has not been found" >&2
178 # in all cases add freeze and unfreeze
179 echo '${PKGDIR}/packages/freeze/freeze.bb '"\\"
180 echo '${PKGDIR}/packages/freeze/unfreeze.bb '"\\"
181 # check for a problem
184 bberror "At least $report was not found." >&2
185 bberror "This can be ignored if the .bb file has been removed, however if not" >&2
186 bberror "the frozen .conf output files are useless unless you fix them up" >&2
189 # the simple bb file list (package/bbfile.bb)
190 out="$FROZEN_DIR/$DISTRO-bbfiles.conf"
191 echo '# automatically generated by bitbake freeze' >"$out"
192 echo 'BBFILES := "\' >>"$out"
195 } | sed 's!^\(.*\)/[^/]*\.bb \\$!\1/*.bb \\!' | uniq | {
196 # the package directories list (package)
197 out="$FROZEN_DIR/$DISTRO-packages.conf"
198 echo '# automatically generated by bitbake freeze' >"$out"
199 echo 'BBFILES := "\' >>"$out"