Skip to content

Commit

Permalink
Add podman-based development support
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnks committed Feb 13, 2019
1 parent be6d487 commit 439e4c2
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
27 changes: 27 additions & 0 deletions Dockerfile
@@ -0,0 +1,27 @@
# YUM development image

FROM centos:7

# Set up EPEL
RUN yum install -y \
epel-release

# Install useful stuff
RUN yum install -y \
python-pip \
python-ipdb \
ipython \
vim \
less
RUN rpm -e --nodeps yum
RUN rm -rf /var/cache/yum
RUN pip install --upgrade pip && pip install pudb

# Use the yum checkout mounted from the host
ENV PATH=/src/bin:$PATH \
PYTHONPATH=/src:$PYTHONPATH
RUN ln -s /src/etc/yum.conf /etc/yum.conf
RUN ln -s /src/etc/version-groups.conf /etc/yum/version-groups.conf

VOLUME ["/src"]
ENTRYPOINT ["/bin/bash"]
15 changes: 14 additions & 1 deletion Makefile
Expand Up @@ -13,6 +13,7 @@ WEB_DOC_PATH = /srv/projects/yum/web/download/docs/yum-api/

BUILDDIR = build
MOCK_CONF = epel-7-x86_64
PODMAN_IMAGE = yum-devel

all: subdirs

Expand Down Expand Up @@ -63,7 +64,7 @@ transifex:
make transifex-push
git commit -a -m 'Transifex push, yum.pot update'

.PHONY: docs test srpm rpm
.PHONY: docs test srpm rpm shell

DOCS = yum rpmUtils callback.py yumcommands.py shell.py output.py cli.py utils.py\
yummain.py
Expand Down Expand Up @@ -141,3 +142,15 @@ rpm: srpm
--no-clean --no-cleanup-after \
$(BUILDDIR)/SRPMS/$(PKGNAME)-$(VERSION)-$(RELEASE).src.rpm
@echo "The RPMs are in $(BUILDDIR)/RPMS"

### Container-based development ###

$(BUILDDIR)/image: Dockerfile $(BUILDDIR)
podman build -t $(PODMAN_IMAGE) .
@touch $@

shell: $(BUILDDIR)/image
@podman run \
-v=$(CURDIR):/src:ro,z \
--detach-keys="ctrl-@" \
-it $(PODMAN_ARGS) $(PODMAN_IMAGE) || true
26 changes: 26 additions & 0 deletions README.md
Expand Up @@ -48,3 +48,29 @@ You can build an RPM package by running:
$ make rpm

**Note:** Make sure you have `mock` and `lynx` installed.

## Development

You can run Yum from the current checkout in a container as follows (make sure
you have the `podman` package installed):

$ make shell

This will first build a CentOS 7 image (if not built already) and then run a
container with a shell where you can directly execute Yum:

[root@bf03d3a43cbf /] yum

When you edit the code on your host, the changes you make will be immediately
reflected inside the container since the checkout is bind-mounted.

**Warning:** There's a (probably) bug in podman at the moment which makes it
not see symlinks in a freshly created container, which, in turn, makes Yum not
see the `/etc/yum.conf` symlink when it runs for the first time. The
workaround is to `touch /etc/yum.conf` or simply re-run Yum.

**Note:** When you exit the container, it is not deleted but just stopped. To
re-attach to it, use (replace the ID appropriately):

$ podman start bf03d3a43cbf
$ podman attach bf03d3a43cbf

0 comments on commit 439e4c2

Please sign in to comment.