Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: freitas-renato/mosh-static-multiarch
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: run-1
Choose a base ref
...
head repository: freitas-renato/mosh-static-multiarch
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 7 commits
  • 5 files changed
  • 1 contributor

Commits on Oct 27, 2023

  1. Copy the full SHA
    57b8d90 View commit details
  2. Update readme

    freitas-renato committed Oct 27, 2023
    Copy the full SHA
    27a4247 View commit details

Commits on Oct 31, 2023

  1. Copy the full SHA
    02526ea View commit details
  2. Copy the full SHA
    65c2bf4 View commit details
  3. Copy the full SHA
    13e0cb2 View commit details

Commits on Nov 1, 2023

  1. Copy the full SHA
    3f47511 View commit details

Commits on Nov 3, 2023

  1. Copy the full SHA
    e56bf03 View commit details
Showing with 216 additions and 24 deletions.
  1. +143 −18 .github/workflows/autobuild.yml
  2. +4 −6 README.md
  3. +61 −0 macOS/build.sh
  4. +2 −0 macOS/gtar
  5. +6 −0 macOS/port-deps.sh
161 changes: 143 additions & 18 deletions .github/workflows/autobuild.yml
Original file line number Diff line number Diff line change
@@ -2,13 +2,44 @@ on:
workflow_dispatch:
name: Auto-Build
jobs:
build:
name: Build
macports-cache:
runs-on: macos-12
steps:
- uses: actions/checkout@v3

- name: Install gtar sudo wrapper
run: |
sudo mv /usr/local/bin/gtar /usr/local/bin/gtar.orig
sudo cp macOS/gtar /usr/local/bin/gtar
sudo chmod +x /usr/local/bin/gtar
- name: Cache macports
id: cache-macports
uses: actions/cache@v3
env:
cache-name: cache-macports
with:
path: /opt/local
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('macOS/port-deps.sh') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Setup macports dependencies
if: steps.cache-macports.outputs.cache-hit != 'true'
run: |
curl -L "https://github.com/macports/macports-base/releases/download/v2.8.1/MacPorts-2.8.1-12-Monterey.pkg" --output macports.pkg
sudo installer -pkg macports.pkg -target /
chmod +x macOS/port-deps.sh && ./macOS/port-deps.sh
linux-build:
name: Linux Build
runs-on: ubuntu-20.04

strategy:
matrix:
architecture: [amd64]
architecture: [amd64, arm64, armv7]

steps:
- name: Checkout code
@@ -21,26 +52,94 @@ jobs:
run: |
docker build -t builder --build-arg TARGET_ARCH=${{ matrix.architecture }} .
- run: git clone --depth=1 --branch mosh-1.3.2 https://github.com/mobile-shell/mosh.git
- run: git clone --depth=1 --branch mosh-1.4.0 https://github.com/mobile-shell/mosh.git

- name: Build binaries for ${{ matrix.architecture }}
run: docker run -v $PWD/mosh:/mosh -w /mosh --name=builder builder sh -c './autogen.sh && LDFLAGS=-static ./configure && make'

- name: Test run mosh-server
run: docker run -v $PWD/mosh:/mosh -w /mosh/src/frontend builder sh -c 'chmod +x mosh-server && ./mosh-server'

- name: Rename binaries
run: |
mv mosh/src/frontend/mosh-server mosh/src/frontend/mosh-server-linux-${{ matrix.architecture }}
mv mosh/src/frontend/mosh-client mosh/src/frontend/mosh-client-linux-${{ matrix.architecture }}
- uses: actions/upload-artifact@v3
with:
name: mosh-server-${{ matrix.architecture }}
path: mosh/src/frontend/mosh-server
name: mosh-server-linux-${{ matrix.architecture }}
path: mosh/src/frontend/mosh-server-linux-${{ matrix.architecture }}
if-no-files-found: error

- uses: actions/upload-artifact@v3
with:
name: mosh-client-${{ matrix.architecture }}
path: mosh/src/frontend/mosh-client
name: mosh-client-linux-${{ matrix.architecture }}
path: mosh/src/frontend/mosh-client-linux-${{ matrix.architecture }}
if-no-files-found: error

macos-build:
name: macOS Build (x86_64, arm64)
needs: macports-cache
runs-on: macos-12

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install gtar sudo wrapper
run: |
sudo mv /usr/local/bin/gtar /usr/local/bin/gtar.orig
sudo cp macOS/gtar /usr/local/bin/gtar
sudo chmod +x /usr/local/bin/gtar
- name: Restore macports cache
id: cache-macports
uses: actions/cache@v3
env:
cache-name: cache-macports
with:
path: /opt/local
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('macOS/port-deps.sh') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: git clone --depth=1 --branch mosh-1.4.0 https://github.com/mobile-shell/mosh.git

- run: PATH=/opt/local/bin:$PATH ./autogen.sh
working-directory: ./mosh

- run: |
chmod +x build.sh
env ZERO_AR_DATE=1 MACOSX_DEPLOYMENT_TARGET=11.0 PATH=/opt/local/bin:$PATH ./build.sh
working-directory: ./macOS
- uses: actions/upload-artifact@v3
with:
name: mosh-client-darwin-x86_64
path: ./macOS/prefix_x86_64/local/bin/mosh-client-darwin-x86_64

- uses: actions/upload-artifact@v3
with:
name: mosh-server-darwin-x86_64
path: ./macOS/prefix_x86_64/local/bin/mosh-server-darwin-x86_64

- uses: actions/upload-artifact@v3
with:
name: mosh-client-darwin-arm64
path: ./macOS/prefix_arm64/local/bin/mosh-client-darwin-arm64

- uses: actions/upload-artifact@v3
with:
name: mosh-server-darwin-arm64
path: ./macOS/prefix_arm64/local/bin/mosh-server-darwin-arm64



release:
name: Release
needs: [build]
needs: [linux-build, macos-build]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
@@ -55,13 +154,43 @@ jobs:
echo '- [Workflow file](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/.github/workflows/autobuild.yml)'
echo
echo '## Files'
echo '### Linux'
echo '```'
(
for dir in mosh-client-linux* mosh-server-linux*; do
cd "$dir"
for prog in mosh*; do
file "$prog"
done
cd ..
done
)
echo '```'
echo
echo '### macOS'
echo '```'
(file mosh-client-*/mosh-client mosh-server-*/mosh-server)
(
for dir in mosh-client-darwin* mosh-server-darwin*; do
cd "$dir"
for prog in mosh*; do
file "$prog"
done
cd ..
done
)
echo '```'
echo
echo '## SHA256 Checksums'
echo '```'
(sha256sum mosh-client-*/mosh-client mosh-server-*/mosh-server)
(
for dir in mosh-client* mosh-server*; do
cd "$dir"
for prog in mosh*; do
sha256sum "$prog"
done
cd ..
done
)
echo '```'
) | tee release.md
@@ -72,13 +201,8 @@ jobs:
path: release.md
if-no-files-found: error

- run: |
for i in mosh-client-*/; do zip -r "${i%/}.zip" "$i"; done
- run: |
for i in mosh-server-*/; do zip -r "${i%/}.zip" $i; done
- name: Create release
id: create_release
uses: softprops/action-gh-release@v1
with:
name: "Build #${{ github.run_number }}"
@@ -87,5 +211,6 @@ jobs:
draft: false
body_path: release.md
files: |
*.zip
mosh-client-*/mosh-client*
mosh-server-*/mosh-server*
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# mosh-static

An unofficial static binary distribution of [mobile-shell/mosh](https://github.com/mobile-shell/mosh) which can be dropped into a remote server.
An unofficial static binary distribution of [mobile-shell/mosh](https://github.com/mobile-shell/mosh) which can be dropped into a remote server. Extends [dtinth/mosh-static](https://github.com/dtinth/mosh-static) to add support for arm64 and armv7 architectures on Linux, using QEMU when building, and also support for macOS on arm64 and x86_64.

Releasing is automated by GitHub Actions — [this GitHub Actions workflow](https://github.com/dtinth/mosh-static/blob/main/.github/workflows/autobuild.yml) clones `mosh`’s source code, compiles it inside an Alpine Docker image, and creates [a GitHub release with the binary](https://github.com/dtinth/mosh-static/releases/latest).

> **Note:** Only x86-64 architecture is supported. I do not plan to support other architectures or maintain this repository. Please feel free to fork. If there is an actively maintained fork, please let me know and I will point people there.
Releasing is automated by GitHub Actions on [this GitHub Actions workflow](https://github.com/freitas-renato/mosh-static-multiarch/blob/main/.github/workflows/autobuild.yml). For Linux, it clones `mosh`’s source code, compiles it inside an Alpine Docker image with QEMU for arm64, armv7 and amd64 targets. For macOS, it installs dependencies via Macports and compiles inside a macOS environment, linking protobuf statically. In the end, it creates a [GitHub release](https://github.com/freitas-renato/mosh-static-multiarch/releases/latest) with the binaries.

## Using the binaries

```sh
# On the server
wget https://github.com/dtinth/mosh-static/releases/latest/download/mosh-server
# On the server (ARM64)
wget https://github.com/freitas-renato/mosh-static-multiarch/releases/latest/download/mosh-server-linux-arm64 -O mosh-server
chmod +x mosh-server

# On the client
61 changes: 61 additions & 0 deletions macOS/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

set -e

protobuf_LIBS=$(l=libprotobuf.a; for i in /opt/local/lib /usr/local/lib; do if [ -f $i/$l ]; then echo $i/$l; fi; done)
if [ -z "$protobuf_LIBS" ]; then echo "Can't find libprotobuf.a"; exit 1; fi
export protobuf_LIBS
if ! pkg-config --cflags protobuf > /dev/null 2>&1; then
protobuf_CFLAGS=-I$(for i in /opt /usr; do d=$i/local/include; if [ -d $d/google/protobuf ]; then echo $d; fi; done)
if [ "$protobuf_CFLAGS" = "-I" ]; then echo "Can't find protobuf includes"; exit 1; fi
export protobuf_CFLAGS
fi
export CXXFLAGS=-std=gnu++17
# XXX This script abuses Configure's --prefix argument badly. It uses
# it as a $DESTDIR, but --prefix can also affect paths in generated
# objects. That is not *currently* a problem in mosh.
#
PREFIX="$(pwd)/prefix"
HOST="x86_64-apple-macosx${MACOSX_DEPLOYMENT_TARGET}"
ARCH_TRIPLES="x86_64-apple-macosx arm64-apple-macos"
pushd ../mosh > /dev/null
if [ ! -f configure ];
then
echo "Running autogen."
PATH=/opt/local/bin:$PATH ./autogen.sh
fi
#
# Build archs one by one.
#
for triple in $ARCH_TRIPLES; do
arch=$(echo $triple | cut -d- -f1)
echo "Building for ${arch}..."
prefix="${PREFIX}_${arch}"
rm -rf "${prefix}"
mkdir "${prefix}"
if ./configure --prefix="${prefix}/local" --build="${triple}${MACOSX_DEPLOYMENT_TARGET}"\
--host="${HOST}" \
CC="cc -arch ${arch}" CPP="cc -arch ${arch} -E" CXX="c++ -arch ${arch}" \
TINFO_LIBS=-lncurses &&
make clean &&
make install -j8 V=1 &&
rm -f "${prefix}/etc"
then
mv "${prefix}/local/bin/mosh-client" "${prefix}/local/bin/mosh-client-darwin-${arch}"
mv "${prefix}/local/bin/mosh-server" "${prefix}/local/bin/mosh-server-darwin-${arch}"
BUILT_ARCHS="$BUILT_ARCHS $arch"
fi
done
if [ -z "$BUILT_ARCHS" ]; then
echo "No architectures built successfully"
exit 1
fi
popd > /dev/null
2 changes: 2 additions & 0 deletions macOS/gtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec sudo /usr/local/bin/gtar.orig "$@"
6 changes: 6 additions & 0 deletions macOS/port-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

sudo /opt/local/bin/port install protobuf-cpp +universal
sudo /opt/local/bin/port install ncurses +universal
sudo /opt/local/bin/port install pkgconfig
sudo /opt/local/bin/port install autoconf automake