Skip to content

Commit b682d66

Browse files
committed
refactor: remove trizen and 3rd package + simplify/consolidate Docker image creation
1 parent c471b01 commit b682d66

File tree

6 files changed

+149
-67
lines changed

6 files changed

+149
-67
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,51 +33,46 @@ jobs:
3333
with:
3434
username: ${{ secrets.DOCKERHUB_USERNAME }}
3535
password: ${{ secrets.DOCKERHUB_TOKEN }}
36-
- name: Build and push
37-
uses: docker/build-push-action@v2
38-
with:
39-
context: .
40-
file: ./Dockerfile
41-
builder: ${{ steps.buildx.outputs.name }}
42-
push: true
43-
tags: mpsq/emacs-native-comp-wayland-builder:latest
4436

4537
artifact:
4638
runs-on: ubuntu-latest
4739
needs: [image]
4840
container:
49-
image: mpsq/emacs-native-comp-wayland-builder:latest
50-
options: --user root
41+
image: mpsq/emacs-builder:latest
5142
env:
5243
OLD_COMMIT_N: ${{ github.event.inputs.old_commit_n }}
5344
NEW_COMMIT_N: ${{ github.event.inputs.new_commit_n }}
5445
steps:
5546
- name: Prepare artifacts
5647
run: |
57-
pacman --noconfirm -S jq openssh bc
58-
cd /home/pcr
48+
./pull.bash
5949
6050
# Get/set version number
61-
version=$(ls emacs* | sed -r 's/.*([0-9]{2}\.[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{6}).*/\1/gi')
51+
version=$(grep AC_INIT configure.ac | sed -e 's/^.\+\ \([0-9]\+\.[0-9]\+\.[0-9]\+\?\).\+$/\1/')
52+
version+="."
53+
version+="$NEW_COMMIT_N"
6254
echo "pkg_version=$version" >> $GITHUB_ENV
6355
56+
makepkg
57+
6458
# Unpack artifacts
65-
mkdir pkg
66-
tar xf "$(ls emacs*)" -C pkg
67-
rm pkg/.BUILDINFO pkg/.MTREE pkg/.PKGINFO
68-
tar czf "$version".tar.gz -C pkg .
59+
mkdir out
60+
tar xf emacs-1-1-x86_64.pkg.tar.zst -C out
61+
rm emacs-1-1-x86_64.pkg.tar.zst
62+
rm out/.BUILDINFO out/.MTREE out/.PKGINFO
63+
tar czf "$version".tar.gz -C out .
6964
sum=$(sha512sum "$version".tar.gz | sed -r 's/(.*)\s\s.*/\1/')
7065
echo "pkg_sum=$sum" >> $GITHUB_ENV
7166
7267
# Get release body
7368
delta=$(echo "$NEW_COMMIT_N - $OLD_COMMIT_N" | bc)
7469
echo -en "# Commits since last release\n\n" > body.md
75-
echo -en "Check [upstream](https://github.com//flatwhatson/emacs/commits) for the full history.\n\n" >> body.md
70+
echo -en "Check [upstream](https://github.com/flatwhatson/emacs/commits) for the full history.\n\n" >> body.md
7671
7772
# Get the list of commits since last release
7873
curl -s "$UPSTREAM_GH"/commits?per_page="$delta" | \
7974
# Parse and retain only the commit message + its url
80-
jq -r '.[].commit | (.message | capture("(?<id>.+)\n").id) + " [commit](" + .html_url + ")"' | \
75+
jq -r '.[] | (.commit.message | capture("(?<id>.+)\n").id) + " [commit](" + .html_url + ")"' | \
8176
# Remove "Merge" commits
8277
sed '/^Merge/,+1 d' | \
8378
# Remove any special char at the beginning of the message
@@ -112,32 +107,28 @@ jobs:
112107
PRIV_KEY: ${{ secrets.PRIV_KEY }}
113108
PUB_KEY: ${{ secrets.PUB_KEY }}
114109
run: |
115-
cd /root
116110
mkdir .ssh
117111
118112
# Setup SSH
119113
echo "$PUB_KEY" | tr -d '\r' > .ssh/id_aur.pub
120114
echo "$PRIV_KEY" | base64 --decode > .ssh/id_aur
121115
chmod 600 .ssh/id_aur
122-
echo -en 'Host aur.archlinux.org\n IdentityFile /root/.ssh/id_aur\n User aur\n' > .ssh/config
116+
echo -en 'Host aur.archlinux.org\n IdentityFile /home/pcr/.ssh/id_aur\n User aur\n' > .ssh/config
123117
ssh-keyscan aur.archlinux.org > .ssh/known_hosts
124118
ssh-keyscan 95.216.144.15 >> .ssh/known_hosts
125119
126120
# Setup git
127-
cd /home/pcr
128121
git config --global user.name "Méril Pilon"
129122
git config --global user.email "me@mpsq.org"
130123
git clone ssh://aur.archlinux.org/emacs-gcc-wayland-devel-bin.git
131-
chown -R pcr:pcr emacs-gcc-wayland-devel-bin
132124
cd emacs-gcc-wayland-devel-bin
133125
134126
# Amend package, set pkgver, sha512 sum and pkgrel + fix permissions
135127
sed -i -r -e 's~pkgver=.*~pkgver='$PKG_VERSION'~' PKGBUILD
136128
sed -i -r -e 's~sha512sums=.*~sha512sums=\("'"$PKG_SUM"'"\)~' PKGBUILD
137129
sed -i -r -e 's/pkgrel=.*/pkgrel=1/' PKGBUILD
138-
chown pcr:pcr PKGBUILD
139130
rm .SRCINFO
140-
su pcr -c "makepkg --printsrcinfo > .SRCINFO"
131+
makepkg --printsrcinfo > .SRCINFO
141132
142133
# Push changes
143134
git add .SRCINFO PKGBUILD

Dockerfile

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,67 @@
1-
FROM mpsq/emacs-native-comp-wayland-builder:latest
1+
#
2+
# This Dockerfile is used to build the image "mpsq/emacs-builder".
3+
# Link: https://hub.docker.com/repository/docker/mpsq/emacs-builder
4+
#
5+
# What is the point of this?
6+
# - Have an Archlinux environment
7+
# - Pull and compile Emacs so it is much faster to produce subsequent binaries
8+
#
9+
# This image is obviously then used in the GitHub action to compile Emacs.
10+
#
11+
# At the moment, this image is built manually from times to times (= very
12+
# infrequently). In the future, I might get CI to do it, maybe on a monthly
13+
# basis.
14+
#
15+
FROM archlinux:base-devel
216

17+
COPY deps .
18+
19+
RUN pacman -Syu --noconfirm && \
20+
pacman -U --noconfirm libgccjit-10.2.0-2-x86_64.pkg.tar.zst && \
21+
pacman -S --noconfirm \
22+
# Emacs deps
23+
alsa-lib \
24+
cairo \
25+
clang \
26+
binutils \
27+
gnutls \
28+
gpm \
29+
gtk3 \
30+
harfbuzz \
31+
jansson \
32+
libotf \
33+
libxml2 \
34+
lld \
35+
llvm \
36+
webkit2gtk \
37+
xorgproto \
38+
# Pipeline deps
39+
bc \
40+
expac \
41+
git \
42+
jq \
43+
openssh && \
44+
groupadd -r pcr && useradd --no-log-init -r -g pcr pcr && \
45+
mkdir /home/pcr && \
46+
chown -R pcr:pcr /home/pcr && \
47+
echo "pcr ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/user && \
48+
chmod 0440 /etc/sudoers.d/user
49+
50+
WORKDIR /home/pcr
351
USER pcr
452

5-
RUN \
6-
rm /home/pcr/emacs* && \
7-
trizen \
8-
--quiet \
9-
--nocolors \
10-
--noedit \
11-
--noconfirm \
12-
--noinstall \
13-
--movepkg-dir=/home/pcr \
14-
-S emacs-native-comp-git-enhanced
53+
COPY PKGBUILD .
54+
COPY pull.bash .
55+
56+
ENV CC="/usr/bin/clang" \
57+
CXX="/usr/bin/clang++" \
58+
CPP="/usr/bin/clang -E" \
59+
LD="/usr/bin/lld" \
60+
AR="/usr/bin/llvm-ar" \
61+
AS="/usr/bin/llvm-as" \
62+
CFLAGS="-g -flto -fuse-ld=lld" \
63+
CXXFLAGS="-g -flto -fuse-ld=lld"
64+
65+
RUN ["./pull.bash"]
66+
RUN makepkg && \
67+
rm emacs-1-1-x86_64.pkg.tar.zst

PKGBUILD

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
pkgname=emacs
2+
pkgver=1
3+
pkgrel=1
4+
pkgdesc="The extensible, customizable, self-documenting real-time display editor"
5+
arch=('x86_64')
6+
url="https://www.gnu.org/software/emacs/emacs.html"
7+
license=('GPL3')
8+
depends=()
9+
source=()
10+
sha1sums=()
11+
12+
build() {
13+
cd /home/pcr/emacs
14+
15+
[[ -x configure ]] || ( ./autogen.sh git && ./autogen.sh autoconf )
16+
17+
_conf=(
18+
--prefix=/usr
19+
--sysconfdir=/etc
20+
--libexecdir=/usr/lib
21+
--localstatedir=/var
22+
--mandir=/usr/share/man
23+
--with-gameuser=:games
24+
--with-sound=alsa
25+
--with-modules
26+
--with-x-toolkit=gtk3
27+
--with-cairo
28+
--with-xwidgets
29+
--with-nativecomp
30+
--with-pgtk
31+
--without-compress-install
32+
--without-gconf
33+
--without-gsettings
34+
--without-m17n-flt
35+
--enable-autodepend
36+
--enable-link-time-optimization
37+
)
38+
39+
./configure --with-nativecomp CC='clang' "${_conf[@]}"
40+
41+
make -j$(nproc)
42+
}
43+
44+
package() {
45+
cd /home/pcr/emacs
46+
make DESTDIR="$pkgdir" install
47+
48+
mv "$pkgdir"/usr/bin/{ctags,ctags.emacs}
49+
mv "$pkgdir"/usr/share/man/man1/{ctags.1,ctags.emacs.1};
50+
51+
# fix user/root permissions on usr/share files
52+
find "$pkgdir"/usr/share/emacs/ | xargs chown root:root
53+
54+
# fix permssions on /var/games
55+
mkdir -p "$pkgdir"/var/games/emacs
56+
chmod 775 "$pkgdir"/var/games
57+
chmod 775 "$pkgdir"/var/games/emacs
58+
chown -R root:games "$pkgdir"/var/games
59+
}

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,9 @@ Please create an issue (or, even better, a PR).
3535

3636
# Thanks
3737

38-
All the hard work is done by other people:
39-
4038
- [github.com/masm11](https://github.com/masm11) for the Wayland support
41-
- [github.com/flatwhatson](https://github.com/flatwhatson) for maitaining a
39+
- [github.com/flatwhatson](https://github.com/flatwhatson) for maintaining a
4240
[clean branch](https://github.com/flatwhatson/emacs) with Wayland support
43-
- [github.com/VitalyAnkh](https://github.com/VitalyAnkh) for
44-
[emacs-native-comp-git-enhanced](https://aur.archlinux.org/packages/emacs-native-comp-git-enhanced/)
4541
- Obviously [core Emacs maintainers](https://www.gnu.org/people/people.en.html)!
4642

4743
# Related

builder/Dockerfile

Lines changed: 0 additions & 26 deletions
This file was deleted.

pull.bash

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ -d "emacs" ]]; then
4+
cd emacs
5+
git pull --rebase origin pgtk-nativecomp
6+
else
7+
git clone --depth=1 https://github.com/flatwhatson/emacs
8+
cd emacs
9+
fi

0 commit comments

Comments
 (0)