diff options
author | Raphael Moll <ralf@android.com> | 2014-04-24 19:13:47 -0700 |
---|---|---|
committer | Raphael Moll <ralf@android.com> | 2014-05-15 17:49:02 -0700 |
commit | ea40d2f4c5af9744f7140a31d551a55dade128d9 (patch) | |
tree | cb058e015a3ba6e55ebbfda8e20ff4fcdf3f0a44 /build/tools/mk_sdk_repo_xml.sh | |
parent | a5afedd2e21846f8cd8d662c4a7ef7ec3dc6dfee (diff) | |
download | android_development-ea40d2f4c5af9744f7140a31d551a55dade128d9.tar.gz android_development-ea40d2f4c5af9744f7140a31d551a55dade128d9.tar.bz2 android_development-ea40d2f4c5af9744f7140a31d551a55dade128d9.zip |
SDK: support generating repository XML with latest XSD.
The latest version of the repository XSD changes:
- archive attributes (os/arch) are now element (host-os)
- system images are not longer in the repository.xml and
get their own XML file.
Change-Id: If5820a84d5c754b816b17b5713bbdb2597736eff
Diffstat (limited to 'build/tools/mk_sdk_repo_xml.sh')
-rwxr-xr-x | build/tools/mk_sdk_repo_xml.sh | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/build/tools/mk_sdk_repo_xml.sh b/build/tools/mk_sdk_repo_xml.sh index 0bb0e51f2..79298baa5 100755 --- a/build/tools/mk_sdk_repo_xml.sh +++ b/build/tools/mk_sdk_repo_xml.sh @@ -45,7 +45,7 @@ OUT="$1" [[ -z "$OUT" ]] && error "Missing output.xml name." shift -# Get the schema type. Must be either "repository" or "addon". +# Get the schema filename. E.g. ".../.../sdk-repository-10.xsd". Can be relative or absolute. SCHEMA="$1" [[ ! -f "$SCHEMA" ]] && error "Invalid XML schema name: $SCHEMA." shift @@ -106,7 +106,6 @@ ATTRS=( Platform.MinToolsRev min-tools-rev 1 Platform.MinPlatformToolsRev min-platform-tools-rev 3 Sample.MinApiLevel min-api-level 2 - SystemImage.Abi abi 5 Layoutlib.Api layoutlib/api 4 Layoutlib.Revision layoutlib/revision 4 # from source.properties for addon.xml packages @@ -119,6 +118,10 @@ ATTRS=( Extra.Path path 1 Extra.OldPaths old-paths 3 Extra.MinApiLevel min-api-level 2 + # for system-image + SystemImage.Abi abi r:3,s:1 + SystemImage.TagId tag-id r:9,s:2 + SystemImage.TagDisplay tag-display r:9,s:2 # from addon manifest.ini for addon.xml packages # (note that vendor/name are mapped to different XML elements based on the XSD version) vendor-id vendor-id 4 @@ -135,6 +138,23 @@ ATTRS=( revision revision 1 ) +# Start with repo-10, addon-7 and sys-img-3, we don't encode the os/arch +# in the <archive> attributes anymore. Instead we have separate elements. + +function uses_new_host_os() { + if [[ "$ROOT" == "sdk-repository" && "$XSD_VERSION" -ge "10" ]]; then return 0; fi + if [[ "$ROOT" == "sdk-addon" && "$XSD_VERSION" -ge "7" ]]; then return 0; fi + if [[ "$ROOT" == "sdk-sys-img" && "$XSD_VERSION" -ge "3" ]]; then return 0; fi + return 1 +} + +ATTRS_ARCHIVE=( + Archive.HostOs host-os 1 + Archive.HostBits host-bits 1 + Archive.JvmBits jvm-bits 1 + Archive.MinJvmVers min-jvm-version 1 +) + # Starting with XSD repo-7 and addon-5, some revision elements are no longer just # integers. Instead they are in major.minor.micro.preview format. This defines @@ -224,6 +244,13 @@ function parse_attributes() { local VALUE local REV local USED + local S + + # Get the first letter of the schema name (e.g. sdk-repo => 'r') + # This can be r, a or s and would match the min-XSD per-schema value + # in the ATTRS list. + S=$(basename "$SCHEMA") + S="${S:4:1}" # $1 here is the ATTRS list above. while [[ "$1" ]]; do @@ -234,6 +261,12 @@ function parse_attributes() { DST=$2 REV=$3 + if [[ $REV =~ ([ras0-9:,]+,)?$S:([0-9])(,.*)? ]]; then + # Per-schema type min-XSD revision. Format is "[<type>:rev],*] + # where type is one of r, a or s matching $S above. + REV="${BASH_REMATCH[2]}" + fi + if [[ $XSD_VERSION -ge $REV ]]; then # Parse the property, if present. Any space is replaced by @ VALUE=$( grep "^$SRC=" "$PROPS" | cut -d = -f 2 | tr ' ' '@' | tr -d '\r' ) @@ -390,13 +423,28 @@ while [[ -n "$1" ]]; do fi SHA1=$( sha1sum "$SRC" | cut -d " " -f 1 ) + if uses_new_host_os ; then + USE_HOST_OS=1 + else + OLD_OS_ATTR=" os='$OS'" + fi + cat >> "$OUT" <<EOFA - <sdk:archive os='$OS' arch='any'> + <sdk:archive$OLD_OS_ATTR> <sdk:size>$SIZE</sdk:size> <sdk:checksum type='sha1'>$SHA1</sdk:checksum> <sdk:url>$DST</sdk:url> - </sdk:archive> EOFA + if [[ $USE_HOST_OS ]]; then + # parse the Archive.Host/Jvm info from the source.props if present + MAP=$(parse_attributes "$PROPS" ${ATTRS_ARCHIVE[@]}) + # Always generate host-os if not present + if [[ "${MAP/ host-os /}" == "$MAP" ]]; then + MAP="$MAP host-os $OS" + fi + output_attributes "archive" "$OUT" $MAP + fi + echo " </sdk:archive>" >> "$OUT" # Skip to next arch/zip entry. # If not a valid OS, close the archives/package nodes. |