blob: b421f32e6592ac1b6c5c86c6b82944d2b36d8c98 [file] [log] [blame]
Adam Michaelf8a67522016-09-14 15:07:50 +00001#!/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
21if [ "$#" -ne 3 ]; then
22 echo "Usage: zip_manifest_creator.sh <regexp> <input zip> <output manifest>"
23 exit 1
24fi
25
26REGEX="$1"
27INPUT_ZIP="$2"
28OUTPUT_MANIFEST="$3"
29
Adam Michael954c8ab2016-09-30 21:01:07 +000030RUNFILES=${RUNFILES:-$0.runfiles}
31
32# For the sh_binary in BUILD.tools, zipper is here.
Adam Michael78c19802016-10-13 23:09:25 +000033ZIPPER=$RUNFILES/*/tools/zip/zipper/zipper
Adam Michael954c8ab2016-09-30 21:01:07 +000034if [ ! -x $ZIPPER ]; then
35 # For the sh_test in BUILD.oss, zipper is here.
36 ZIPPER=$RUNFILES/third_party/ijar/zipper
37fi
38if [ ! -x $ZIPPER ]; then
39 echo "zip_manifest_creator could not find zipper executable"
40 exit 1
41fi
42
43$ZIPPER v "$INPUT_ZIP" \
44 | cut -d ' ' -f3 \
45 | grep -v \/$ \
46 | grep -x "$REGEX" \
47 > "$OUTPUT_MANIFEST"
Adam Michaele7cc19a2016-09-15 18:56:30 +000048exit 0