Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding scripts for publishing to S3 RPM repo #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions rpms/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Container for publishing GeoDocker RPMs to RPM repo on hosted S3
FROM centos:7
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably should be the same Docker image that is used for building RPMs, why not?


RUN yum update -y && \
yum install -y awscli createrepo && \
yum clean all

ENV REGION "us-east-1"
ENV AWS_PROFILE "geotrellis"

COPY scripts/publish-rpm.sh /publish-rpm.sh
COPY scripts/promote-rpm.sh /promote-rpm.sh

VOLUME /rpmbuild /root/.aws

CMD ["/publish-rpm.sh", "-s", "/rpmbuild", "-t", "geotrellis-yum"]
9 changes: 8 additions & 1 deletion rpms/build/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
.PHONY: all gcc4 aws-build-gdal rpms src wheels
.PHONY: all gcc4 aws-build-gdal rpms src wheels publish-rpms

FAMILY := quay.io/geodocker/emr-build
VERSION := 7
GCC4IMAGE := $(FAMILY):gcc4-$(VERSION)
BASEIMAGE := quay.io/geodocker/jupyter-geopyspark:base-$(VERSION)
RPMIMAGE := quay.io/geodocker/rpm-build:1
INTERFACE ?= eth0
IP_ADDR := $(shell ifconfig $(INTERFACE) | grep -i mask | awk '{print $$2}' | cut -f2 -d:)
BUILD_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))

all:
echo "see build.sh"
Expand Down Expand Up @@ -54,3 +56,8 @@ cleanest: cleaner

mrproper: cleanest
rm -f rpmbuild/SOURCES/SOURCES/*

# Publish built RPMS to
publish-rpms: rpms
docker build . -t quay.io/geodocker/rpm-build:1
docker run -it --rm -v $(HOME)/.aws:/root/.aws -v $(BUILD_DIR)/rpmbuild:/rpmbuild quay.io/geodocker/rpm-build:1
1 change: 0 additions & 1 deletion rpms/build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ The following images can be built from the materials in this directory:
- [`quay.io/geodocker/jupyter-geopyspark:aws-build-gdal-3`](Dockerfile.aws-build-gdal) is an image used to build the `gdal-and-friend.tar.gz` binary blob. This image is meant to mimic the environment of an EC2 (EMR) instance as closely as possible so as to create a compatible artifact.
- [`quay.io/geodocker/jupyter-geopyspark:base-3`](Dockerfile.base) is the ancestor images of the image produced in the root of this repository. It contains mostly slow-rate-of-change binary dependencies.
- [`quay.io/geodocker/emr-build:gcc4-3`](Dockerfile.gcc4) is used to build RPMs with gcc 4.8.
- [`quay.io/geodocker/emr-build:gcc6-3`](Dockerfile.gcc6) is used to build RPMs with gcc 6.4.

## Files and Directories ##

Expand Down
1 change: 1 addition & 0 deletions rpms/build/rpmbuild/RPMS/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.rpm
44 changes: 44 additions & 0 deletions rpms/build/scripts/promote-rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
set -e
if [ ! -z "${DEBUG}" ]; then
set -x
fi

while getopts "s:t:r:" opt; do
case $opt in
r) RPM_MATCH=$OPTARG ;;
s) SOURCE_BUCKET=$OPTARG ;;
t) TARGET_BUCKET=$OPTARG ;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done

die() { echo "$*" 1>&2 ; exit 1; }
[ -z "${RPM_MATCH}" ] || die "RPM_MATCH string must be specifie."
[ -z "${SOURCE_BUCKET}" ] || die "SOURCE_BUCKET must be specified"
[ -z "${TARGET_BUCKET}" ] || die "TARGET_BUCKET must be specified"

SOURCE_DIR="/tmp/${SOURCE_BUCKET}"
TARGET_DIR="/tmp/${TARGET_BUCKET}"

mkdir -p $SOURCE_DIR
mkdir -p $TARGET_DIR
aws s3 sync "s3://${SOURCE_BUCKET}" $SOURCE_DIR
aws s3 sync "s3://${TARGET_BUCKET}" $TARGET_DIR

# copy the RPMs to target directory
mkdir -pv $TARGET_DIR/x86_64/
cp -rv $SOURCE_DIR/x86_64/$RPM_MATCH-1.x86_64.rpm $TARGET_DIR/x86_64/

# optionally update the target RPM repo
if [ -e "${TARGET_DIR}/noarch/repodata/repomd.xml" ]; then
UPDATE="--update "
else
UPDATE=""
fi
for a in $TARGET_DIR/x86_64 ; do createrepo -v $UPDATE --deltas $a/ ; done

aws s3 sync $TARGET_DIR s3://$TARGET_BUCKET
37 changes: 37 additions & 0 deletions rpms/build/scripts/publish-rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
set -e
if [ ! -z "${DEBUG}" ]; then
set -x
fi

while getopts "s:t:" opt; do
case $opt in
s) SOURCE_DIR=$OPTARG ;;
t) TARGET_BUCKET=$OPTARG ;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done

die() { echo "$*" 1>&2 ; exit 1; }
[ -z "${SOURCE_DIR}" ] || die "SOURCE_DIR must be specified"
[ -z "${TARGET_BUCKET}" ] || die "TARGET_BUCKET must be specified"

echo "Publishing RPMS from $SOURCE_DIR to s3://$TARGET_BUCKET"

TMP_DIR="/tmp/${TARGET_BUCKET}"

mkdir -pv $TMP_DIR/x86_64/
aws s3 sync "s3://${TARGET_BUCKET}" $TMP_DIR

cp -rv $SOURCE_DIR/RPMS/* $TMP_DIR/x86_64/
if [ -e "$TMP_DIR/x86_64/repodata/repomd.xml" ]; then
UPDATE="--update "
else
UPDATE=""
fi
for a in $TMP_DIR/x86_64 ; do createrepo -v $UPDATE --deltas $a/ ; done

aws s3 sync $TMP_DIR s3://$TARGET_BUCKET