mkacr.sh revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# This script builds the overhead information used by bfu to do
# automatic conflict resolution. This overhead information is stored
# in a gzip'ed cpio archive called "conflict_resolution.gz" in the
# archive directory. It contains all of the class-action script
# required to upgrade the editable files, plus a control file
# (editable_file_db) which lists the editable files and the
# class-action scripts needed to upgrade them.
#
isa=$1
dir=$2
# This clause matches architecture specific entries. e.g. CLASSES_i386=
# It has a different format to the other ERE entries as this allows
# the variable substition.
$1 ~ "CLASSES_"matchisa"[\t ]*$" {
gsub(/"/, "", $2);
numisaclasses = split($2, isaclasses, " ");
next;
}
/^CLASSES *=/ {
gsub(/"/, "", $2);
numclasses = split($2, classes, " ");
next;
}
/^PKG *=/ {
gsub(/"/, "", $2);
pkg = $2;
next;
}
/^ARCH *=/ {
mach = "-";
gsub(/"/, "", $2);
if ($2 ~ /ISA/) {
pkgisa = matchisa;
} else {
dotpos = index($2, ".");
if (dotpos != 0 ) {
pkgisa = substr($2, 1, dotpos - 1);
mach = substr($2, dotpos + 1);
} else {
pkgisa = $2
}
}
if (pkgisa != matchisa)
exit 0;
next;
}
END {
if (numclasses == 0 && numisaclasses == 0)
exit 0;
for (i in isaclasses) {
if (isaclasses[i] == "none")
continue;
printf("%s %s %s %s %s\n", pkg, pkginst, pkgisa, mach,
isaclasses[i]);
}
for (i in classes) {
if (classes[i] == "none")
continue;
printf("%s %s %s %s %s\n", pkg, pkginst, pkgisa, mach,
classes[i]);
}
}
}
# $1 is one of non_on_classes
# $2 is editablefilelist
nononclass=$1
efilelist=$2
pkgdir=$3
if [ "$1" = "build" ] ; then
# print the target file name and pkg name from editablefilelist
else
fi
done
fi
}
#
# the process_pkdefs_directory function generates the conflict
# resolution information for a single pkgdefs directory (there can
# be more than one in an ON workspace).
#
# It gets two arguments explicitly:
# $1 - the location of the pkgdefs directory
# $2 - a string to be used as a "uniquifier" for generating
# pathnames for class files (there can be more than one
# class action script with the same name, but they are all
# stored in one directory in the conflict resolution
# database).
#
# It gets two pieces of data globally: the values of the "corepkgs"
# and the "bfu_incompatible_classes" variables.
#
pkgdefsdir=$1
un=$2
cd $pkgdefsdir
# Step 1: Generate a list of packages to be processed, with the
# "core" packages at the head of the list.
print "Step 1: Generating list of packages to be processed"
fi
if [ -d $dir -a -s $dir/pkginfo.tmpl -a \
-s $dir/prototype_$isa ] ; then
print $dir
fi
if [ -d $dir -a -s $dir/pkginfo.tmpl -a \
-s $dir/prototype_$isa ] ; then
print $dir
fi
done | sort > $allpkglist
# make copy of pkglist so comm doesn't keep going because it's
# appending to an input file
comm -13 $pkgcopy $allpkglist >> $pkglist
#
# Step 2: build a list of all of the classes in all the packages
# (except for the "none" class). The order of each package's class
# list must match the order in the pkginfo.tmpl file.
#
print "Step 2: Build list of all classes in all packages."
fi
done > $allclasslist_t
if [ -s common_files/i.$class -o \
-s common_files/i.${class}_$isa ] ; then
else
echo ${non_on_classes} |
if [ $? -eq 0 ] ; then
else
fi
fi
done > $allclasslist
#
# Step 3: For each package with at least one installation class,
# scan the package's prototype files and look for files that are
# editable or volatile and which have class-action scripts. Make
# a list of those files, with their packages and script names.
#
print "Step 3: Build list of editable files."
fi
while read pkginst; do
if [ -s $pkginst/prototype_com ] ; then
else
fi
'(/^[ev] /) && ($2 != "none") && ($2 != "build") {
printf("%s %s %s\n", $3, pkginst, $2);}
(/^[ev] /) && ($2 == "build") {
split($3,buildtgt,"=");
printf("%s %s %s\n", buildtgt[1], pkginst,$2);}'
done > $editablefilelist
#
# Step 4: Use the information in $allclasslist and
# $editablefilelist to generate the list of files
# to be copied to the bfu archive and the
# editable-file/class-action-script database to be installed
# in the archive.
#
print "Step 4: Merge class list and editable files list"
fi
do
-v uniquifier=$un '
{ if ($2 == pkgdir && $3 == class)
printf("%s i.%s %s %s %s %s %s %s\n", $1,
class, pkg, $2, isa, mach, iscommon,
uniquifier);
done > $db
for badclass in $bfu_incompatible_classes; do
if ($2 == badclass)
class = replclass;
else
class = $2;
printf("%s %s %s %s %s %s %s %s\n",
$1, class, $3, $4, $5, $6, $7, $8)
done
#
# Step 5 - Copy the editable-file/class-action-script database file
# to the class scripts to the archive directory.
#
print "Step 5: Create bfu conflict resolution directory"
fi
if [ -s common_files/i.$class ] ; then
cp common_files/i.$class \
elif [ -s common_files/i.${class}_$isa ] ; then
cp common_files/i.${class}_$isa \
else
echo ${non_on_classes} |
if [ $? -eq 0 ] ; then
#
# process_non_on_classes is called only once
# per non_on_class due to sort -u above.
#
${editablefilelist} \
continue;
else
$editablefilelist | sort -u > $classpk
cat >&2 <<EOF
mkacr: The class script i.$class cannot be found in the pkgdefs common files
directory, and there is more than one package that uses it.
EOF
exit 1
fi
fi
else
exit 1
fi
fi
done
else
fi
}
#
# Execution starts here
#
export LC_ALL=C
USAGE="Usage: $0 <workspace> <instruction-set-architecture> <archive-dir>"
if [ $# -ne 3 ] ; then
exit 1
fi
workspace=$1
isa=$2
if [ -d $workspace/pkgdefs ] ; then
:
else
exit 1
fi
if [ ! -d $3 ] ; then
exit 1
fi
archivedir=$(cd $3; pwd)
print -u2 "$0: Instruction set architecture must be \"sparc\" or \"i386\""
exit 1
fi
#
# temporary file scorecard, in order of appearance:
# (Temporary files that begin with "ps." are pass-specific. mkacr
# generates its database in multiple passes: one for each pkgdef
# directory in the ON source base. Currently there are 2:
# that begin with "ps." are deleted at the end of each pass.)
#
# ps.pkglist package names, starting with core pkgs
#
# ps.allpkglist pass 1 additional package list
#
# ps.pkgcopy pass 1 temporary copy of core package names
#
# ps.allclasslist list of all classes
#
# ps.allclasslist_t preliminary version of ps.allclasslist
#
# ps.editablefilelist list of editable files.
#
# ps.db, tmpdb temporary files used in construction of editable_file_db
#
# ps.cpioerr stderr from cpio.
#
tmpdir=$(mktemp -t -d mkacr.XXXXXX)
if [ -z "$tmpdir" ] ; then
print -u2 "mktemp failed to produce output; aborting"
exit 1
fi
if [ ! -d "$tmpdir" ] ; then
exit 1
fi
if [ "$ACR_DEBUG" = "yes" ] ; then
print "Temporary files will be left in $tmpdir"
else
trap 'rm -rf $tmpdir' 0
fi
#
# set up the list of corepkgs and bfs-incompatible classes for the
#
corepkgs="
SUNWcar.*
SUNWcakr.*
SUNWckr
SUNWcsd
SUNWcsr
SUNWcsu
SUNWcsl
SUNWcslr
SUNWkvm.*
"
"
i.pkcs11conf
"
fi
#
# set up the list of corepkgs and bfs-incompatible classes for the
#
corepkgs="SUNWrmodr"
fi
if [ "$ACR_DEBUG" = "yes" ] ; then
print "Final processing: Create bfu conflict resolution archive"
fi
print "Creating conflict resolution archive: \c";
(cd $tmpdir
find conflict_resolution -print | cpio -ocB 2>$cpioerr |
gzip -c > $archivedir/conflict_resolution.gz ) || exit 1
awk '/^[0-9]* blocks$/ { blocks=1; print $0; next }
END {
if (!blocks) {
# Terminate the "print \c" line above.
print
}
}' <$cpioerr
exit 0