Browse Source

refactoring stuff

pull/1/head
Benedikt Kristinsson 10 months ago
parent
commit
7021fa3b93
  1. 8
      amzn/Dockerfile
  2. 32
      amzn/entrypoint.sh
  3. 18
      build-amzn.sh
  4. 19
      build-debian.sh
  5. 20
      debian/Dockerfile
  6. 52
      debian/entrypoint.sh
  7. 64
      jenkins.sh

8
amzn/Dockerfile

@ -2,6 +2,7 @@ FROM amazonlinux:1
ARG VERSION=27.1
ARG CPU_COUNT=8
ARG PREFIX=/emacs/target
RUN yum -y update && \
yum -y install devtoolset-9-gcc devtoolset-9-libgccjit-devel gnutls-devel git ncurses-devel && \
@ -9,18 +10,17 @@ RUN yum -y update && \
ADD emacs-${VERSION}.tar.xz /emacs
WORKDIR /emacs/emacs-${VERSION}
ARG PREFIX=/emacs/target
RUN ./configure --prefix=${PREFIX} --with-x=no CFLAGS="-I$ORIGIN/../include" --without-sound \
LDFLAGS="-L$ORIGIN/lib -Wl,-rpath=\\\$\$ORIGIN/../lib"
RUN make -j${CPU_COUNT}
RUN make install -j${CPU_COUNT}
ADD entrypoint-amzn.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint-amzn.sh
ADD entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
ENV VERSION ${VERSION}
ENV PREFIX ${PREFIX}
ENTRYPOINT ["/usr/local/bin/entrypoint-amzn.sh"]
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["package"]

32
amzn/entrypoint-amzn.sh → amzn/entrypoint.sh

@ -3,27 +3,19 @@
set -e
set -x
if [ "$1" = "shell" ]; then
exec -l /bin/bash
elif [ "$1" = "emacs" ]; then
if [ "$1" = "emacs" ]; then
exec $EMACSROOT/bin/emacs
elif [ ! "$1" = "package" ]; then
echo "invalid args: '$1'"
exit 1
exec $@
fi
if [ -z "$VERSION" ]; then
echo "varible VERSION must be set!"
exit 1
fi
if [ -z "$PREFIX" ]; then
PREFIX=/emacs/target
fi
CPU_COUNT=$(grep "processor" -c /proc/cpuinfo)
DIST=/emacs/dist
TARGET=$PREFIX
mkdir -p $TARGET
BUILDS=/emacs/amzn
# we compiled emacs with runpath set to '$ORIGIN/../lib' ($ORIGIN is a
# special token so we can specify a location relative to the
@ -40,20 +32,14 @@ cp /usr/lib64/libgnutls.so.26 $TARGET/lib/
# in the output we see that the binary is dynamically linking the
# files we copied
ldd $TARGET/bin/emacs
ldd $PREFIX/bin/emacs
mkdir -p $BUILDS
mkdir -p $DIST/amzn
# make a tarball
(
rm $DIST/amzn/czemacs-${VERSION}.tar.gz || true
cd $TARGET
rm $BUILDS/czemacs-${VERSION}.tar.gz || true
tar -cf $DIST/amzn/czemacs-${VERSION}.tar.gz .
)
# copy the compiled $TARGET
(
rm -rf $DIST/amzn/czemacs-${VERSION} || true
mkdir -p $DIST/amzn/czemacs-${VERSION}
cp -r $TARGET/* $DIST/amzn/czemacs-${VERSION}/
cd $PREFIX
tar -czf $BUILDS/czemacs-${VERSION}.tar.gz *
)

18
build-amzn.sh

@ -1,18 +0,0 @@
#!/bin/bash
set -x
set -e
VERSION="27.1"
PREFIX=/home/bkristinsson/.local
DIST="$(pwd)/dist"
(
cd amzn/
wget -q https://ftp.gnu.org/pub/gnu/emacs/emacs-${VERSION}.tar.xz
docker build --build-arg PREFIX=$PREFIX --build-arg VERSION=$VERSION -t build-emacs-amzn .
docker run --rm -v $DIST:/emacs/dist build-emacs-amzn $1
)
# docker rmi build-emacs-amzn

19
build-debian.sh

@ -1,19 +0,0 @@
#!/bin/bash
set -x
set -e
VERSION="27.1"
PREFIX=/emacs/target
DIST="$(pwd)/dist"
(
cd debian/
wget -q https://ftp.gnu.org/pub/gnu/emacs/emacs-${VERSION}.tar.xz
docker build --build-arg VERSION=$VERSION -t build-emacs-debian .
docker run -v $DIST/:/emacs/dist --rm build-emacs-debian $1
)
# docker image rmi build-emacs-debian

20
debian/Dockerfile

@ -1,31 +1,31 @@
FROM debian:bullseye
ENV DEBIAN_FRONTEND noninteractive
ARG VERSION=27.1
ARG CPU_COUNT=8
ARG PREFIX=/emacs/target
ENV VERSION ${VERSION}
ENV PREFIX ${PREFIX}
ENV DEBIAN_FRONTEND noninteractive
RUN mkdir /emacs && mkdir /emacs/target && mkdir /emacs/build/ && \
RUN mkdir -p /emacs/target && \
apt-get update && \
apt-get install -y wget build-essential autoconf texinfo gnutls-bin \
libgnutls28-dev pkg-config libncurses-dev patchelf \
ruby ruby-dev rubygems build-essential && \
gem install --no-document fpm
gem install --no-document fpm
# untars !
ADD emacs-${VERSION}.tar.xz /emacs
WORKDIR /emacs/emacs-${VERSION}
ARG PREFIX=/emacs/target
RUN ./configure --prefix=$PREFIX --with-x=no CFLAGS="-I$EMACSROOT/include" \
LDFLAGS="-L$EMACSROOT/lib -Wl,-rpath=\\\$\$ORIGIN/../lib"
RUN ./configure --prefix=$PREFIX --with-x=no CFLAGS="-I$ORIGIN/include" \
LDFLAGS="-L$ORIGIN/lib -Wl,-rpath=\\\$\$ORIGIN/../lib"
RUN make -j${CPU_COUNT}
RUN make install -j${CPU_COUNT}
ADD entrypoint.sh /usr/local/bin/
ADD entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENV VERSION ${VERSION}
ENV PREFIX ${PREFIX}
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["package"]

52
debian/entrypoint.sh

@ -3,34 +3,26 @@
set -e
set -x
if [ "$1" = "shell" ]; then
exec -l /bin/bash
elif [ "$1" = "emacs" ]; then
exec $EMACSROOT/bin/emacs
if [ "$1" = "emacs" ]; then
exec $PREFIX/bin/emacs
elif [ ! "$1" = "package" ]; then
echo "invalid args: '$1'"
exit 1
exec $@
fi
if [ -z "$VERSION" ]; then
echo "varible VERSION must be set!"
exit 1
fi
if [ -z "$PREFIX" ]; then
PREFIX=/emacs/target
fi
CPU_COUNT=$(grep "processor" -c /proc/cpuinfo)
DIST=/emacs/dist
TARGET=$PREFIX
mkdir -p $TARGET
BUILDS=/emacs/debian
# we compiled emacs with runpath set to '$ORIGIN/../lib' ($ORIGIN is a
# special token so we can specify a location relative to the
# executable
#
# Same as running
# $ patchelf --set-rpath '$ORIGIN/../lib' $TARGET/bin/emacs
# $ patchelf --set-rpath '$ORIGIN/../lib' $PREFIX/bin/emacs
#
# https://www.reddit.com/r/emacs/comments/6nnd6x/selfcontainedrelocatableportable_emacs24_for_linux/dkbbs6h/
#
@ -41,42 +33,22 @@ cp /usr/lib/x86_64-linux-gnu/libgnutls.so.30 $EMACSROOT/lib/
# in the output we see that the binary is dynamically linking the
# files we copied
ldd $TARGET/bin/emacs
ldd $PREFIX/bin/emacs
mkdir -p $DIST/debian
mkdir -p $BUILDS
# make a tarball
(
rm $DIST/debian/emacs-${VERSION}.tar.gz || true
cd $TARGET
rm $BUILDS/emacs-${VERSION}.tar.gz || true
cd $PREFIX
tar -cf $DIST/debian/emacs-${VERSION}.tar.gz .
tar czf $BUILDS/emacs-${VERSION}.tar.gz *
)
# make a .deb with fpm
(
# set dependencies (check with apt)
fpm -t deb -v $VERSION -n emacs -s dir $TARGET/=/usr
cp *.deb $DIST/debian/
fpm -t deb -v $VERSION -n emacs -s dir $PREFIX/=/usr
cp *.deb $BUILDS
)
# copy the compiled $TARGET
(
rm -rf $DIST/debian/emacs-${VERSION} || true
mkdir -p $DIST/debian/emacs-${VERSION}
cp -r $TARGET/* $DIST/debian/emacs-${VERSION}/
)
# if [ ! -d "/emacs/emacs-${VERSION}" ]; then
# (
# cd /emacs
# wget https://ftp.gnu.org/gnu/emacs/emacs-${VERSION}.tar.xz
# tar xf emacs-${VERSION}.tar.xz
# rm emacs-${VERSION}.tar.xz
# # todo: check signature
# )
# fi

64
jenkins.sh

@ -0,0 +1,64 @@
#!/bin/bash
set -x
set -e
build_debian() {
cp emacs-${VERSION}.tar.xz debian/
PREFIX=/emacs/target
sudo docker build --build-arg PREFIX=$PREFIX --build-arg VERSION=$VERSION -t emacs-debian debian/
# debian tags:
# * :debian
# * :27.1
# * :27.1-debian
sudo docker tag emacs-debian benediktkr/emacs:debian
sudo docker tag emacs-debian benediktkr/emacs:${VERSION}
sudo docker tag emacs-debian benediktkr/emacs:${VERSION}-debian
sudo docker rm emacs-debian-package || true
sudo docker run --name emacs-debian-package emacs-debian
sudo docker cp emacs-debian-package:/emacs/debian dist/
sudo docker rm emacs-debian-package
}
build_amzn () {
cp emacs-${VERSION}.tar.xz amzn/
PREFIX=/home/bkristinsson/.local
sudo docker build --build-arg PREFIX=$PREFIX --build-arg VERSION=$VERSION -t emacs-amzn amzn/
# amzn tags:
# * :amzn
# * :27.1-amzn
sudo docker tag emacs-amzn benediktkr/emacs:amzn
sudo docker tag emacs-amzn benediktkr/emacs:${VERSION}-amzn
sudo docker rm emacs-amzn-package || true
sudo docker run --name emacs-amzn-package emacs-amzn
sudo docker cp emacs-amzn-package:/emacs/amzn dist/
sudo docker rm emacs-amzn-package
}
VERSION="27.1"
COPYTO="$(pwd)/dist"
mkdir -p $COPYTO
env
if [ ! -f emacs-${VERSION}.tar.xz ]; then
wget -q https://ftp.gnu.org/pub/gnu/emacs/emacs-${VERSION}.tar.xz
fi
build_debian
build_amzn
Loading…
Cancel
Save