Browse Source

exec_prefix

pull/1/head
Benedikt Kristinsson 7 months ago
parent
commit
fbbeac2c02
5 changed files with 67 additions and 48 deletions
  1. +1
    -0
      .gitignore
  2. +20
    -34
      Jenkinsfile
  3. +3
    -3
      amzn/package.sh
  4. +11
    -5
      debian/Dockerfile
  5. +32
    -6
      debian/package.sh

+ 1
- 0
.gitignore View File

@ -4,3 +4,4 @@ emacs-src/
*.tar.xz
\#*
.\#*
*.tar.xz

+ 20
- 34
Jenkinsfile View File

@ -1,12 +1,12 @@
def version = ""
def amzn_prefix = "/home/bkristinsson/.local"
def timer = currentBuild.getBuildCauses()[0]["shortDescription"].matches("Started by timer")
def build_exists = false
def skip_build = false
pipeline {
agent any
triggers {
cron('@weekly')
cron('@daily')
}
options {
timestamps()
@ -65,24 +65,22 @@ pipeline {
sh "git checkout refs/tags/${latest_tag}"
sh "git --no-pager show --oneline -s"
build_exists = fileExists(
def build_exists = fileExists(
"${env.JENKINS_HOME}/artifacts/emacs-${version}.tar.gz"
)
skip_build = (timer && build_exists)
echo "latest tag reachable from master: ${latest_tag}"
echo "build for ${version} exists: ${build_exists}"
echo "started by timer: ${timer}"
echo "skip building: ${skip_build}"
}
}
}
}
stage('amzn') {
when {
anyOf {
expression { timer && !build_exists }
expression { !timer }
}
}
when { expression { skip_build == false } }
steps {
sh "docker build -f amzn/Dockerfile --build-arg PREFIX=${amzn_prefix} --build-arg VERSION=${version} -t emacs-amzn:${version}-amzn ."
sh "docker container create --name emacs_amzn_builder emacs-amzn:${version}-amzn "
@ -91,12 +89,7 @@ pipeline {
}
stage ('deb: build emacs') {
when {
anyOf {
expression { timer && !build_exists }
expression { !timer }
}
}
when { expression { skip_build == false } }
steps {
sh "docker build -f debian/Dockerfile --build-arg PREFIX=/emacs/target --build-arg VERSION=${version} --target builder -t benediktkr/emacs:builder-${version} ."
sh "docker container create --name emacs_debian_builder benediktkr/emacs:builder-${version}"
@ -107,27 +100,11 @@ pipeline {
}
}
stage('deb: container') {
when {
anyOf {
expression { timer && !build_exists }
expression { !timer }
}
}
when { expression { skip_build == false } }
steps {
sh "docker build -f debian/Dockerfile -t benediktkr/emacs:${version} ."
}
}
stage('deb: dockerhub') {
when {
anyOf {
expression { timer && !build_exists }
expression { !timer }
}
}
steps {
sh "docker push benediktkr/emacs:${version}"
}
}
}
post {
@ -139,10 +116,19 @@ pipeline {
sh "cp dist/*/*.tar.gz ${env.JENKINS_HOME}/artifacts"
sh "cp dist/debian/*.deb ${env.JENKINS_HOME}/artifacts"
script {
if ( !skip_build ) {
sh "docker push benediktkr/emacs:${version}"
}
}
}
cleanup {
sh "docker container rm emacs_debian_builder || true"
sh "docker container rm emacs_amzn_builder || true"
script {
if (! skip_build ) {
sh "docker container rm emacs_debian_builder || true"
sh "docker container rm emacs_amzn_builder || true"
}
}
}
// always {


+ 3
- 3
amzn/package.sh View File

@ -11,13 +11,13 @@ BUILDS=/emacs/amzn
# 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/
#
# copying some lib files
cp /lib64/librt.so.1 $TARGET/lib/
cp /usr/lib64/libgnutls.so.26 $TARGET/lib/
cp /lib64/librt.so.1 $PREFIX/lib/
cp /usr/lib64/libgnutls.so.26 $PREFIX/lib/
# in the output we see that the binary is dynamically linking the
# files we copied


+ 11
- 5
debian/Dockerfile View File

@ -20,19 +20,25 @@ FROM base as builder
ADD emacs-src/ /emacs/emacs-${VERSION}
WORKDIR /emacs/emacs-${VERSION}
# --exec-prefix=$PREFIX
# --prefix=$PREFIX
RUN ./autogen.sh \
&& ./configure --prefix=$PREFIX --with-x=no CFLAGS="-I$ORIGIN/include" LDFLAGS="-L$ORIGIN/lib -Wl,-rpath=\\\$\$ORIGIN/../lib"
&& ./configure --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}
RUN make install prefix=$PREFIX -j${CPU_COUNT}
ADD debian/package.sh /usr/local/bin/package.sh
RUN chmod +x /usr/local/bin/package.sh
RUN /usr/local/bin/package.sh
RUN rm -rf /emacs/emacs-${VERSION}
FROM builder as final
WORKDIR /emacs
RUN rm -rf /emacs/emacs-${VERSION} #&& rm -rf /emacs/target
# enable when everything is included
RUN dpkg -i /emacs/debian/emacs_27.1_amd64.deb \
&& rm -rf /emacs/debian
RUN /usr/bin/emacs --version
RUN /usr/local/bin/emacs --version
CMD ["/usr/bin/emacs"]
CMD ["/usr/local/bin/emacs"]

+ 32
- 6
debian/package.sh View File

@ -8,7 +8,6 @@ if [ -z "$VERSION" ]; then
exit 1
fi
CPU_COUNT=$(grep "processor" -c /proc/cpuinfo)
BUILDS=/emacs/debian
# we compiled emacs with runpath set to '$ORIGIN/../lib' ($ORIGIN is a
@ -20,10 +19,35 @@ BUILDS=/emacs/debian
#
# https://www.reddit.com/r/emacs/comments/6nnd6x/selfcontainedrelocatableportable_emacs24_for_linux/dkbbs6h/
#
echo $PREFIX
# copying some lib files
cp /lib/x86_64-linux-gnu/librt.so.1 $EMACSROOT/lib/
cp /lib/x86_64-linux-gnu/libtinfo.so.6 $EMACSROOT/lib/
cp /usr/lib/x86_64-linux-gnu/libgnutls.so.30 $EMACSROOT/lib/
cp /lib/x86_64-linux-gnu/librt.so.1 $PREFIX/lib/
cp /lib/x86_64-linux-gnu/libtinfo.so.6 $PREFIX/lib/
cp /usr/lib/x86_64-linux-gnu/libgnutls.so.30 $PREFIX/lib/
# this doesnt seem to work on ubuntu, nettle-dev should be installed
# as dependency
cp /usr/lib/x86_64-linux-gnu/libnettle.so.8 $PREFIX/lib/
cp /usr/lib/x86_64-linux-gnu/libhogweed.so.6 $PREFIX/lib/
# shown as inlcuded by ldd but havent been needed so far
# cp /lib/x86_64-linux-gnu/libanl.so.1 $PREFIX/lib/
# cp /lib/x86_64-linux-gnu/libm.so.6 $PREFIX/lib/
# cp /lib/x86_64-linux-gnu/libdl.so.2 $PREFIX/lib/
# cp /usr/lib/x86_64-linux-gnu/libgmp.so.10 $PREFIX/lib/
# cp /lib/x86_64-linux-gnu/libc.so.6 $PREFIX/lib/
# cp /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 $PREFIX/lib/
# cp /usr/lib/x86_64-linux-gnu/libidn2.so.0 $PREFIX/lib/
# cp /usr/lib/x86_64-linux-gnu/libunistring.so.2 $PREFIX/lib/
# cp /usr/lib/x86_64-linux-gnu/libtasn1.so.6 $PREFIX/lib/
# cp /usr/lib/x86_64-linux-gnu/libnettle.so.8 $PREFIX/lib/
# pretty this one isnt needed since it should def be anywhere
# but included here because its show in the output of ldd
# /lib/x86_64-linux-gnu/libpthread.so.0
# in the output we see that the binary is dynamically linking the
# files we copied
@ -33,7 +57,6 @@ mkdir -p $BUILDS
# make a tarball
(
rm $BUILDS/emacs-${VERSION}.tar.gz || true
cd $PREFIX
tar czf $BUILDS/emacs-${VERSION}.tar.gz *
@ -42,7 +65,10 @@ mkdir -p $BUILDS
# make a .deb with fpm
(
# set dependencies (check with apt)
fpm -t deb -v $VERSION -n emacs -s dir $PREFIX/=/usr
#DEPENDS="-d nettle-dev"
DEPENDS=""
fpm -t deb -v $VERSION -n emacs $DEPENDS -s dir $PREFIX/=/usr/local
cp *.deb $BUILDS
)


Loading…
Cancel
Save