Skip to content

Instantly share code, notes, and snippets.

@jeremyje
Created April 11, 2020 18:36
Show Gist options
  • Select an option

  • Save jeremyje/1abfd3c658f4a2969e40ba0e09e66971 to your computer and use it in GitHub Desktop.

Select an option

Save jeremyje/1abfd3c658f4a2969e40ba0e09e66971 to your computer and use it in GitHub Desktop.
Debug OSX Unzipping
#!/bin/bash
ARCHIVES_DIR=$PWD/archives
TOOLCHAIN_DIR=$PWD/toolchain
TOOLCHAIN_BIN=${TOOLCHAIN_DIR}/bin
THIRDPARTY_DIR=$PWD/third_party
mkdir -p ${ARCHIVES_DIR}/
curl -o ${ARCHIVES_DIR}/protoc.zip -L https://github.com/protocolbuffers/protobuf/releases/download/v3.11.4/protoc-3.11.4-osx-x86_64.zip
touch ${ARCHIVES_DIR}/protoc.zip
mkdir -p ${TOOLCHAIN_BIN}/
mkdir -p ${TOOLCHAIN_DIR}/protoc-temp/
cp ${ARCHIVES_DIR}/protoc.zip ${TOOLCHAIN_DIR}/protoc-temp/
(cd ${TOOLCHAIN_DIR}/protoc-temp/; unzip -q -o protoc.zip)
cp ${TOOLCHAIN_DIR}/protoc-temp/bin/protoc ${TOOLCHAIN_BIN}/protoc
rm -rf ${TOOLCHAIN_DIR}/protoc-temp/
touch ${TOOLCHAIN_BIN}/protoc
mkdir -p ${ARCHIVES_DIR}/
curl -o ${ARCHIVES_DIR}/googleapis.zip -L \
https://github.com/googleapis/googleapis/archive/master.zip
touch ${ARCHIVES_DIR}/googleapis.zip
rm -rf ${THIRDPARTY_DIR}/google_protobuf/include/
mkdir -p ${TOOLCHAIN_DIR}/googleapis-temp/
mkdir -p ${TOOLCHAIN_BIN}/
mkdir -p ${THIRDPARTY_DIR}/google_protobuf/include/google/
# Copy protobuf
cp ${ARCHIVES_DIR}/protoc.zip ${TOOLCHAIN_DIR}/googleapis-temp/
cp ${ARCHIVES_DIR}/googleapis.zip ${TOOLCHAIN_DIR}/googleapis-temp/
(cd ${TOOLCHAIN_DIR}/googleapis-temp/; unzip -q -o protoc.zip)
cp -rf ${TOOLCHAIN_DIR}/googleapis-temp/include/google/ \
${THIRDPARTY_DIR}/google_protobuf/include/
# Copy google/apis
(cd ${TOOLCHAIN_DIR}/googleapis-temp/; unzip -q -o googleapis.zip)
cp -rf ${TOOLCHAIN_DIR}/googleapis-temp/googleapis-master/google/api/ \
${THIRDPARTY_DIR}/google_protobuf/include/google/
cp -rf ${TOOLCHAIN_DIR}/googleapis-temp/googleapis-master/google/rpc/ \
${THIRDPARTY_DIR}/google_protobuf/include/google/
cp -rf ${TOOLCHAIN_DIR}/googleapis-temp/googleapis-master/google/longrunning/ \
${THIRDPARTY_DIR}/google_protobuf/include/google/
find ${THIRDPARTY_DIR}/google_protobuf/include/google/ -type f -name '*BUILD.bazel' -exec rm {} +
# Figure out why macOS does not copy the base directory over.
rm -rf ${TOOLCHAIN_DIR}/googleapis-temp
touch ${THIRDPARTY_DIR}/google_protobuf/include/google/
find .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment