Skip to content

Commit

Permalink
Makefile: Move developer into make targets
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Milner <smilner@redhat.com>
  • Loading branch information
ashcrow committed Jun 19, 2018
1 parent 8513226 commit 93b92e0
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 22 deletions.
46 changes: 46 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ COMPOSEFLAGS ?=
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
CACHE_ARGS := $(shell if test -d cache; then echo $(shell pwd)/cache; fi)

REPO ?= /srv/rhcos/repo
OSTREE_INSTALL_URL ?= https://dl.fedoraproject.org/pub/fedora/linux/releases/28/Everything/x86_64/os
REF ?= openshift/3.10/x86_64/os

all: rpmostree-compose

.PHONY: syntax-check
Expand All @@ -22,10 +26,52 @@ init-ostree-repo:
ostree --repo=build-repo init --mode=bare-user
ostree --repo=repo init --mode=archive

.PHONY: check-tools
check-tools:
which ostree
which rpm-ostree
which rpmdistro-gitoverlay
which imagefactory
which qemu-img
which mock


# Runs all targets needed to create an image
.PHONY: build-rhcos
build-rhcos: check-tools clean repo-refresh rdgo rpmostree-compose os-image

# Cleans up
.PHONY: clean
clean:
rm -rf build build-0 build-1 src snapshot

# Pulls sources, builds packages, and creates a dnf repo for use
.PHONY: rdgo
rdgo:
rpmdistro-gitoverlay init
rpmdistro-gitoverlay resolve --fetch-all
rpmdistro-gitoverlay build


# Composes an ostree
.PHONY: rpmostree-compose
rpmostree-compose: ${ROOT_DIR}/openshift.repo init-ostree-repo
mkdir -p ${REPO}
ostree init --repo=${REPO} --mode=archive
if test -d cache; then cachedir='--cachedir $(shell pwd)/cache'; fi && \
cd ${ROOT_DIR} && set -x && \
rpm-ostree compose tree $(COMPOSEFLAGS) $${cachedir:-} --repo=$(shell pwd)/build-repo host.yaml
ostree --repo=repo pull-local build-repo
ostree --repo=repo summary -u

# Makes an image using the ostree
.PHONY: os-image
os-image:
ostree --repo=repo remote add rhcos --no-gpg-verify ${OSTREE_INSTALL_URL}
ostree --repo=repo pull --mirror --commit-metadata-only rhcos
sed -i 's,\(<url>\).*\(<\/url\),\1${INSTALLER_TREE_URL}\2,' rhcos.tdl
sed -i 's,@@OSTREE_INSTALL_URL@@,${OSTREE_INSTALL_URL},' cloud.ks
sed -i 's,@@OSTREE_INSTALL_REF@@,${REF},' cloud.ks
imagefactory --debug base_image --file-parameter install_script cloud.ks --parameter offline_icicle True rhcos.tdl
export IMAGE=`ls /var/lib/imagefactory/storage/*.body`
qemu-img convert -f raw -O qcow2 ${IMAGE} rhcos-devel.qcow2
27 changes: 5 additions & 22 deletions README-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,18 @@
- mock

### May need to be built from source
- [coreos-assembler](https://github.com/cgwalters/coreos-assembler/): [container](http://quay.io/cgwalters/coreos-assembler)
- [rpmdistro-gitoverlay](https://github.com/projectatomic/rpmdistro-gitoverlay)
- [imagefactory-plugins-TinMan](https://github.com/redhat-imaging/imagefactory)

## Building

Choose a local mirror to use for OSTREE_INSTALL_URL from [the list](https://admin.fedoraproject.org/mirrormanager/mirrors/Fedora/28/x86_64)

- Clone ``openshift/os``
- Move into the cloned repo
- Build packages from source repos:
- ``rpmdistro-gitoverlay init``
- ``rpmdistro-gitoverlay resolve --fetch-all``
- ``rpmdistro-gitoverlay build``
- Make the ostree
- ``export REPO=/tmp/repo``
- ``ostree init --repo=$REPO --mode=archive``
- ``podman run --privileged --rm -v $REPO:/srv quay.io/cgwalters/coreos-assembler``
- ``cd /srv && coreos-assembler --repo=/srv --cachedir=cache host.yml``
- ``exit``
- ``ostree summary --repo=$REPO --update``
- Make the qcow2
- ``ostree --repo=repo remote add rhcos --no-gpg-verify ${OSTREE_INSTALL_URL}``
- ``ostree --repo=repo pull --mirror --commit-metadata-only rhcos``
- ``sed -i 's,\(<url>\).*\(<\/url\),\1${INSTALLER_TREE_URL}\2,' rhcos.tdl``
- ``sed -i 's,@@OSTREE_INSTALL_URL@@,${OSTREE_INSTALL_URL},' cloud.ks``
- ``export REF="openshift/3.10/x86_64/os"``
- ``sed -i 's,@@OSTREE_INSTALL_REF@@,${REF},' cloud.ks``
- ``imagefactory --debug base_image --file-parameter install_script cloud.ks --parameter offline_icicle True rhcos.tdl``
- ``export IMAGE=`ls /var/lib/imagefactory/storage/*.body```
- ``qemu-img convert -f raw -O qcow2 $IMAGE rhcos-devel.qcow2``
- Build packages from source repos: ``make rdgo``
- Make the ostree: ``make rpmostree-compose OSTREE_INSTALL_URL=<OSTREE_INSTALL_URL_HERE> ``
- Make the qcow2: ``make os-image``


# Container Image
Expand Down

0 comments on commit 93b92e0

Please sign in to comment.