Browse Source

build: test script for rpm repo.

Leonard Gram 7 years ago
parent
commit
7ac859715d

+ 22 - 0
scripts/build/update_repo/test-update-rpm-repo.sh

@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+# Usage
+# docker run -ti --rm -u 0:0 grafana/grafana-ci-deploy:1.1.0 bash
+# in the container:
+# mkdir -p /go/src/github.com/grafana/dist
+# cd /go/src/github.com/grafana
+#
+# outside of container:
+# cd <grafana project dir>/..
+# docker cp grafana <container_name>:/go/src/github.com/grafana/.
+# docker cp <gpg.key used for signing> <container_name>:/private.key
+#
+# in container:
+# gpg --batch --allow-secret-key-import --import /private.key
+# cd dist && wget https://dl.grafana.com/oss/release/grafana-5.4.3-1.x86_64.rpm && cd ..
+# run this script:
+# ./script/build/update_repo/test-update-rpm-repo.sh <gpg key password>
+
+GPG_PASS=${1:-}
+
+./scripts/build/update_repo/update-rpm.sh "oss" "$GPG_PASS" "v5.4.3" "dist" "grafana-testing-repo"

+ 4 - 4
scripts/build/update_repo/update-rpm.sh

@@ -4,6 +4,7 @@ RELEASE_TYPE="${1:-}"
 GPG_PASS="${2:-}"
 RELEASE_TAG="${3:-}"
 DIST_PATH="${4:-}"
+GCP_REPO_BUCKET="${5:-grafana-repo}"
 
 REPO="rpm"
 
@@ -24,7 +25,7 @@ fi
 set -e
 
 # Setup environment
-BUCKET="gs://grafana-repo/$RELEASE_TYPE/$REPO"
+BUCKET="gs://$GCP_REPO_BUCKET/$RELEASE_TYPE/$REPO"
 mkdir -p /rpm-repo
 
 # Download the database
@@ -33,9 +34,7 @@ gsutil -m rsync -r "$BUCKET" /rpm-repo
 # Add the new release to the repo
 cp $DIST_PATH/*.rpm /rpm-repo # adds to many files for enterprise
 rm /rpm-repo/grafana-latest-1*.rpm || true
-cd /rpm-repo
-createrepo .
-cd /go/src/github.com/grafana/grafana
+createrepo /rpm-repo
 
 # Setup signing and sign the repo
 
@@ -47,6 +46,7 @@ pkill gpg-agent || true
 ./scripts/build/update_repo/sign-rpm-repo.sh "$GPG_PASS"
 
 # Update the repo and db on gcp
+gsutil -m cp /rpm-repo/*.rpm "$BUCKET" # sync binaries first to avoid cache misses
 gsutil -m rsync -r -d /rpm-repo "$BUCKET"
 
 # usage: