Zack Williams | 1497a40 | 2018-02-16 15:22:42 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # validate_manifest.sh |
| 3 | # |
| 4 | # Copyright 2017-present Open Networking Foundation |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
| 18 | # Validates the repo manifest, per the DTD format given here: |
| 19 | # https://gerrit.googlesource.com/git-repo/+/master/docs/manifest-format.txt |
| 20 | |
| 21 | echo "Verifying default.xml using manifest.dtd" |
| 22 | |
| 23 | # check that xmllint is available |
| 24 | if ! [ -x "$(command -v xmllint)" ] |
| 25 | then |
| 26 | echo "Please install 'xmllint' to use this script" |
| 27 | exit 1 |
| 28 | fi |
| 29 | |
| 30 | # run the verification |
| 31 | xmllint --noout --dtdvalid manifest.dtd default.xml |
| 32 | status=$? |
| 33 | |
| 34 | if [ $status -ne 0 ] |
| 35 | then |
| 36 | echo "FAILURE: default.xml isn't valid - exit status: $status" |
| 37 | exit $status |
| 38 | else |
| 39 | echo "SUCCESS: default.xml validated correctly" |
| 40 | exit 0 |
| 41 | fi |