Skip to content

Commit

Permalink
Add extra repo support in googet packaging startup script (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaitanyaKulkarni28 authored Oct 18, 2024
1 parent eb8ab86 commit 8fcea1d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packagebuild/daisy_startupscript_goo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ SRC_PATH=$(curl -f -H Metadata-Flavor:Google ${URL}/daisy-sources-path)
REPO_OWNER=$(curl -f -H Metadata-Flavor:Google ${URL}/repo-owner)
REPO_NAME=$(curl -f -H Metadata-Flavor:Google ${URL}/repo-name)
GIT_REF=$(curl -f -H Metadata-Flavor:Google ${URL}/git-ref)
EXTRA_REPO=$(curl -f -H Metadata-Flavor:Google ${URL}/extra-repo)
EXTRA_GIT_REF=$(curl -f -H Metadata-Flavor:Google ${URL}/extra-git-ref)
BUILD_DIR=$(curl -f -H Metadata-Flavor:Google ${URL}/build-dir)
VERSION=$(curl -f -H Metadata-Flavor:Google ${URL}/version)
SBOM_UTIL_GCS_ROOT=$(curl -f -H Metadata-Flavor:Google ${URL}/sbom-util-gcs-root)
Expand All @@ -35,6 +37,7 @@ sed -i 's/^.*debian buster-backports main.*$//g' /etc/apt/sources.list

try_command apt-get -y update
try_command apt-get install -y --no-install-{suggests,recommends} git-core
try_command apt-get install -y make unzip

# We always install go, needed for goopack.
echo "Installing go"
Expand All @@ -43,6 +46,20 @@ install_go
# Install goopack.
GO111MODULE=on $GO install -v github.com/google/googet/v2/goopack@latest

# Install grpc proto compiler.
install_protoc
$GO install -v google.golang.org/protobuf/cmd/protoc-gen-go@latest
$GO install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

ORIG_DIR=$(pwd)
if [[ -n "$EXTRA_REPO" && -n "$EXTRA_GIT_REF" ]]; then
echo "Pulling extra repo: $EXTRA_REPO with reference: $EXTRA_GIT_REF"
git_checkout "$REPO_OWNER" "$EXTRA_REPO" "$EXTRA_GIT_REF"
# git_checkout clones the repo and cd's into it. Make sure we are back in
# original build directory.
cd "$ORIG_DIR"
fi

git_checkout "$REPO_OWNER" "$REPO_NAME" "$GIT_REF"
if [[ -n "$BUILD_DIR" ]]; then
cd "$BUILD_DIR"
Expand Down
8 changes: 8 additions & 0 deletions packagebuild/test_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ DEFAULT_PROJECT='gcp-guest'
DEFAULT_ZONE='us-west1-a'
DEFAULT_OWNER='GoogleCloudPlatform'
DEFAULT_GIT_REF='master'
DEFAULT_EXTRA_GIT_REPO=''
DEFAULT_EXTRA_GIT_REF=''
DEFAULT_GCS_PATH='${SCRATCHPATH}/packages'
DEFAULT_BUILD_DIR='.'
DEFAULT_VERSION='1dummy'
Expand All @@ -36,6 +38,8 @@ DEFAULT_VERSION='1dummy'
[[ -z "${ZONE}" ]] && read -p "Build zone [${DEFAULT_ZONE}]: " ZONE
[[ -z "${OWNER}" ]] && read -p "Repo owner or org [${DEFAULT_OWNER}]: " OWNER
[[ -z "${GIT_REF}" ]] && read -p "Ref [${DEFAULT_GIT_REF}]: " GIT_REF
[[ -z "${EXTRA_REPO}" ]] && read -p "Extra git repo [${DEFAULT_EXTRA_GIT_REPO}]: " EXTRA_REPO
[[ -z "${EXTRA_REF}" ]] && read -p "Extra git ref [${DEFAULT_EXTRA_GIT_REF}]: " EXTRA_REF
[[ -z "${GCS_PATH}" ]] && read -p "GCS Path to upload to [${DEFAULT_GCS_PATH}]: " GCS_PATH
[[ -z "${BUILD_DIR}" ]] && read -p "Directory to build from [${DEFAULT_BUILD_DIR}]: " BUILD_DIR
[[ -z "${REPO}" ]] && read -p "Repo name: " REPO
Expand All @@ -45,6 +49,8 @@ DEFAULT_VERSION='1dummy'
[[ -z "${ZONE}" ]] && ZONE=${DEFAULT_ZONE}
[[ -z "${OWNER}" ]] && OWNER=${DEFAULT_OWNER}
[[ -z "${GIT_REF}" ]] && GIT_REF=${DEFAULT_GIT_REF}
[[ -z "${EXTRA_REPO}" ]] && EXTRA_REPO=${DEFAULT_EXTRA_GIT_REPO}
[[ -z "${EXTRA_REF}" ]] && EXTRA_REF=${DEFAULT_EXTRA_GIT_REF}
[[ -z "${GCS_PATH}" ]] && GCS_PATH=${DEFAULT_GCS_PATH}
[[ -z "${BUILD_DIR}" ]] && BUILD_DIR=${DEFAULT_BUILD_DIR}
[[ -z "${VERSION}" ]] && VERSION=${DEFAULT_VERSION}
Expand All @@ -66,4 +72,6 @@ daisy \
-var:git_ref=${GIT_REF} \
-var:build_dir=${BUILD_DIR} \
-var:version=${VERSION} \
-var:extra_repo=${EXTRA_REPO} \
-var:extra_git_ref=${EXTRA_REF} \
"${WF}"

0 comments on commit 8fcea1d

Please sign in to comment.