Adam Michael | f8a6752 | 2016-09-14 15:07:50 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright 2016 The Bazel Authors. All rights reserved. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # This script takes in a regular expression and a zip file and writes a file |
| 18 | # containing the names of all files in the zip file that match the regular |
| 19 | # expression with one per line. Names of directories are not included. |
| 20 | |
| 21 | if [ "$#" -ne 3 ]; then |
| 22 | echo "Usage: zip_manifest_creator.sh <regexp> <input zip> <output manifest>" |
| 23 | exit 1 |
| 24 | fi |
| 25 | |
| 26 | REGEX="$1" |
| 27 | INPUT_ZIP="$2" |
| 28 | OUTPUT_MANIFEST="$3" |
| 29 | |
Adam Michael | 954c8ab | 2016-09-30 21:01:07 +0000 | [diff] [blame] | 30 | RUNFILES=${RUNFILES:-$0.runfiles} |
| 31 | |
| 32 | # For the sh_binary in BUILD.tools, zipper is here. |
Adam Michael | 78c1980 | 2016-10-13 23:09:25 +0000 | [diff] [blame] | 33 | ZIPPER=$RUNFILES/*/tools/zip/zipper/zipper |
Adam Michael | 954c8ab | 2016-09-30 21:01:07 +0000 | [diff] [blame] | 34 | if [ ! -x $ZIPPER ]; then |
| 35 | # For the sh_test in BUILD.oss, zipper is here. |
| 36 | ZIPPER=$RUNFILES/third_party/ijar/zipper |
| 37 | fi |
| 38 | if [ ! -x $ZIPPER ]; then |
| 39 | echo "zip_manifest_creator could not find zipper executable" |
| 40 | exit 1 |
| 41 | fi |
| 42 | |
| 43 | $ZIPPER v "$INPUT_ZIP" \ |
| 44 | | cut -d ' ' -f3 \ |
| 45 | | grep -v \/$ \ |
| 46 | | grep -x "$REGEX" \ |
| 47 | > "$OUTPUT_MANIFEST" |
Adam Michael | e7cc19a | 2016-09-15 18:56:30 +0000 | [diff] [blame] | 48 | exit 0 |