emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alternatives for reliable build environments for emacs?


From: Yuri Khan
Subject: Re: Alternatives for reliable build environments for emacs?
Date: Thu, 28 Oct 2021 23:07:25 +0700

On Thu, 28 Oct 2021 at 19:57, <joakim@verona.se> wrote:

> I'm finding it increasingly difficult to build emacs in my distro,
> Fedora(Ok, I havent managed to build emacs using distro dependencies for
> a long time)
>
> What are the alternatives?
> I have tried guix and docker but not yet flatpak.
>
> These are nice because you can pin the dependency versions, to make sure
> you have a reproducible build environment.
>
> These all have the drawback that they are inconvenient when making local
> modifications to the emacs source, at least for me. Way back in the days
> when my original build environment worked, I automatically merged some
> branches and applied local patchs with stgit, and its these kind of
> things I've found awkward with the above mentioned containerized build
> systems.

I’m not an Emacs developer but the issue is familiar. I use Docker for
similar cases: (1) building software targeting an older version of the
distribution than is installed on my host system, or (2) building
software using newer versions of the toolchain than I’m comfortable
installing on my host machine.

The trick is that you keep the toolchain and build dependencies in the
container, but bind-mount the source and build trees so they are not
parts of the container image. This way, you work with the source tree
using your local tools; the container is completely disposable.

I’d use the following workspace layout:

…/emacs-workspace
  build/     ← out-of-tree build directory
  docker/    ← separate directory so nothing gets into Docker build context
    Dockerfile
  emacs/     ← source tree
  .env       ← see below
  docker-compose.yml  ← convenience wrapper
  Makefile   ← convenience wrapper over docker-compose

Sample configuration files below are completely untested and provided
only to give an idea.

docker/Dockerfile:
```
FROM ubuntu:20.04  # whatever distro is closest to yours

RUN apt-get update && \
    apt-get install --yes \
        build-essential gdb \
        …more toolchain and dependencies…
RUN adduser ubuntu  # non-privileged build user if not already provided by image
```

docker-compose.yaml:
```
version: "3.7"
services:
  builder:
    build:
      context: docker/
    user: ${DOCKER_UID:-1000}:${DOCKER_GID:-1000}
    volumes:
      - ./build:/home/ubuntu/build
      - ./emacs:/home/ubuntu/emacs
      - /tmp/.X11-unix:/tmp/.X11-unix
```

.env:
```
# If your local user ID or group ID is different from those in the container,
# specify them here
# DOCKER_UID=1001
# DOCKER_GID=1001
```

Makefile:
```
DOCKER_RUN = docker-compose run \
    --rm \
    --user=ubuntu \
    --workdir=/home/ubuntu/emacs \
    builder
CONFIGURE_FLAGS = …

configure:
    $(DOCKER_RUN) ./configure $(CONFIGURE_FLAGS)

build:
    $(DOCKER_RUN) make

debug:
    $(DOCKER_RUN) gdb --args ../build/emacs $(ARGS)
```



reply via email to

[Prev in Thread] Current Thread [Next in Thread]