From d9b7e189d37dc0f07dcabdbf56c78a937ee48c19 Mon Sep 17 00:00:00 2001 From: Tine Jozelj Date: Sat, 26 Dec 2020 12:54:01 +0100 Subject: [PATCH] feat(packages:mosh): build mosh on alpine --- packages/Dockerfile.mosh | 68 +++++++++++---------------------- packages/mosh/APKBUILD | 81 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 47 deletions(-) create mode 100644 packages/mosh/APKBUILD diff --git a/packages/Dockerfile.mosh b/packages/Dockerfile.mosh index 2cb8e9b..ffd6e40 100644 --- a/packages/Dockerfile.mosh +++ b/packages/Dockerfile.mosh @@ -1,54 +1,28 @@ -FROM debian:10.7 as build +FROM sgerrand/alpine-abuild:3.12 as build -WORKDIR /usr/src/mosh - -SHELL ["/bin/bash", "-c"] - -RUN set -ueox pipefail \ -&& DEBIAN_FRONTEND=noninteractive \ -&& apt-get -yqq update \ -&& apt-get -yqq --no-install-recommends --no-install-suggests install \ - ca-certificates \ - git \ - autotools-dev \ - perl \ - protobuf-compiler \ - libprotobuf-dev \ - dh-autoreconf \ - pkg-config \ - libutempter-dev \ - zlib1g-dev \ - libncurses5-dev \ - libssl-dev \ - locales \ - tmux \ - less \ - bash-completion \ - g++ \ -&& apt-get -yqq clean all \ -&& rm -rf /var/lib/apt/lists/* \ - /tmp/* \ - /var/tmp/* - -ARG VERSION=master - -RUN git clone https://github.com/mobile-shell/mosh.git \ - --branch $VERSION \ - --depth 1 . -RUN ./autogen.sh -RUN ./configure --enable-compile-warnings=error -RUN make -RUN make install - -FROM alpine:3 LABEL maintainer="Tine Jozelj " LABEL org.opencontainers.image.source https://github.com/mentos1386/workspace -RUN apk --no-cache add perl +COPY --chown=builder mosh /home/builder/package +RUN sudo chown builder -R /home/builder/package -COPY --from=build /usr/local/bin/mosh /usr/local/bin/mosh -COPY --from=build /usr/local/bin/mosh-server /usr/local/bin/mosh-server -COPY --from=build /usr/local/bin/mosh-client /usr/local/bin/mosh-client +ARG VERSION=master -ENTRYPOINT /usr/local/bin/mosh +RUN sed -i 's/pkgver=master/pkgver=${VERSION}/g' /home/builder/package/APKBUILD + +RUN abuild -r deps +RUN abuild fetch +RUN abuild unpack +RUN abuild prepare +RUN abuild build +RUN abuild package + +FROM alpine:3 + +# Install mosh, so we get the dependencies +RUN apk --update --no-cache add mosh + +COPY --from=build /home/builder/package/pkg/mosh/usr/bin/mosh-server /usr/bin/mosh-server +COPY --from=build /home/builder/package/pkg/mosh/usr/bin/mosh-client /usr/bin/mosh-client +COPY --from=build /home/builder/package/pkg/mosh/usr/bin/mosh /usr/bin/mosh diff --git a/packages/mosh/APKBUILD b/packages/mosh/APKBUILD new file mode 100644 index 0000000..c878cde --- /dev/null +++ b/packages/mosh/APKBUILD @@ -0,0 +1,81 @@ +# Contributor: Francesco Colista +# Maintainer: Francesco Colista +pkgname=mosh +pkgver=master +pkgrel=17 +pkgdesc="Mobile shell surviving disconnects with local echo and line editing" +options="!check" # emulation-cursor-motion.test fails +url="https://mosh.org" +arch="all !mips64" +license="GPL-3.0-or-later" +depends="$pkgname-client $pkgname-server" +checkdepends="tmux perl" +makedepends="ncurses-dev zlib-dev openssl-dev perl-dev perl-doc perl-io-tty + protobuf-dev automake autoconf libtool gzip" +subpackages="$pkgname-doc $pkgname-client $pkgname-server + $pkgname-bash-completion:bashcomp:noarch" +source="https://github.com/mobile-shell/mosh/archive/$pkgver.zip" + +builddir="$srcdir"/$pkgname-$pkgver + +prepare() { + default_prepare + # Test unicode-later-combining is failing. Ideally we want to fix it. + sed -i '/unicode-later-combining.test/d' "$builddir"/src/tests/Makefile.am + cd "$builddir" + ./autogen.sh +} + +build() { + cd "$builddir" + ./configure \ + --build=$CBUILD \ + --host=$CHOST \ + --prefix=/usr \ + --sysconfdir=/etc \ + --mandir=/usr/share/man \ + --localstatedir=/var \ + --enable-compile-warnings=error \ + --enable-examples + make +} + +check() { + cd "$builddir" + make distcheck VERBOSE=1 V=1 +} + +package() { + cd "$builddir" + make DESTDIR="$pkgdir" install +} + +bashcomp() { + depends="" + pkgdesc="Bash completions for $pkgname" + install_if="$pkgname=$pkgver-r$pkgrel bash-completion" + + install -Dm644 "$builddir"/conf/bash-completion/completions/mosh \ + "$subpkgdir"/usr/share/bash-completion/completions/$pkgname +} + +server() { + replaces="mosh" + pkgdesc="Mosh server" + depends="" + mkdir -p "$subpkgdir"/usr/bin + mv "$pkgdir"/usr/bin/mosh-server \ + "$subpkgdir"/usr/bin/ +} + +client() { + replaces="mosh" + pkgdesc="Mosh client" + depends="openssh-client perl-io-tty" + mkdir -p "$subpkgdir"/usr/bin + mv "$pkgdir"/usr/bin/mosh-client \ + "$subpkgdir"/usr/bin/ +} + +sha512sums="1aca55646667ce937da329d3dcc31c124f7a60b975c732cba4290fa7782ac75f17341d9690c811417420269393c415908177c0450dc7d3b6fbfbb9f6ac4cd744 master.zip" +