Skip to content

Commit

Permalink
change version and adds scripts for building tmux
Browse files Browse the repository at this point in the history
  • Loading branch information
prog-supdex committed Mar 19, 2024
1 parent fc66254 commit 25c99fb
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packaging/rubygems/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ libexec/*

tmp/*
!tmp/.gitkeep

data/*
!data/.gitkeep
!data/Dockerfile
22 changes: 21 additions & 1 deletion packaging/rubygems/RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## Prepare gems
## Releasing

### Requirements
It assumes that there are already `overmind` and `tmux` binaries in the Github [release](https://github.com/DarthSim/overmind/releases/tag/v2.4.0).

## Build gem

To build gems for specific platforms, your Ruby version must be at least 3.0.
This requirement exists because Ruby 3.0 introduced enhancements in RubyGems, including support for the `--platform` argument,
Expand Down Expand Up @@ -26,3 +31,18 @@ To build a gem for a specific platform:
rake "overmind:build:linux[amd64]" # linux x86_64
rake "overmind:build:macos[arm64]" # macos arm64
```

## Prepare tmux
We can build tmux binaries for Linux platforms (amd64/arm64/arm/386) via `Docker buildx' using
```bash
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7,linux/386 -t tmux-multiarch:latest --output type=local,dest=./dist data
```

Run into `segfaults`? See this [GitHub issue for solutions] (https://github.com/docker/buildx/issues/314#issuecomment-1043156006).

For MacOS, the `tmux` binaries can be prepared by running `scripts/generate_tmux.sh` on a MacOS machine:
```bash
./scripts/generate_tmux.sh
```

This script will also work on Linux, generating `tmux` binaries for that platform.
Empty file.
38 changes: 38 additions & 0 deletions packaging/rubygems/data/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM alpine:latest AS builder

RUN apk update && apk add --no-cache \
build-base \
pkgconf \
curl \
autoconf \
automake \
libtool \
bison \
openssl-dev

# THe place for libraries
ENV TARGETDIR=/usr/local

WORKDIR /tmp

# Build libevent
RUN curl -LO https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz \
&& tar -zxvf libevent-2.1.12-stable.tar.gz \
&& cd libevent-2.1.12-stable \
&& ./configure --prefix=$TARGETDIR --enable-shared && make && make install

# Build ncurses
RUN curl -LO https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.4.tar.gz \
&& tar zxvf ncurses-6.4.tar.gz \
&& cd ncurses-6.4 \
&& ./configure --prefix=$TARGETDIR --with-default-terminfo-dir=/usr/share/terminfo --with-shared --with-terminfo-dirs="/etc/terminfo:/lib/terminfo:/usr/share/terminfo" --enable-pc-files --with-pkg-config-libdir=$TARGETDIR/lib/pkgconfig \
&& make && make install

# Download and build tmux
RUN curl -LO https://github.com/tmux/tmux/releases/download/3.4/tmux-3.4.tar.gz \
&& tar zxvf tmux-3.4.tar.gz \
&& cd tmux-3.4 \
&& PKG_CONFIG_PATH=$TARGETDIR/lib/pkgconfig ./configure --enable-static --prefix=$TARGETDIR && make && make install

FROM scratch AS export-stage
COPY --from=builder /usr/local/bin/tmux /bin/tmux
2 changes: 1 addition & 1 deletion packaging/rubygems/lib/overmind/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Overmind
VERSION = "0.1.2"
VERSION = "2.4.0"
end
69 changes: 69 additions & 0 deletions packaging/rubygems/scripts/generate_tmux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

if [ -z "$TMUX_INSTALL_DIR" ]; then
TMUX_INSTALL_DIR="/usr/local"
fi

TMUX_LIB_DIR="$TMUX_INSTALL_DIR/lib"

OS=$(uname)
echo "Detected OS: $OS"

mkdir -p "$TMUX_INSTALL_DIR/bin"
mkdir -p "$TMUX_LIB_DIR"
LDFLAGS="-L$TMUX_LIB_DIR"
CPPFLAGS="-I$TMUX_LIB_DIR/include"
LIBS="-lresolv"
TMUX_FLAGS="--enable-static"

if [ "$OS" == "Darwin" ]; then
TMUX_FLAGS="--enable-utf8proc"
fi

TARGETDIR="$TMUX_INSTALL_DIR"

# Build libevent
curl -LO https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz \
&& tar -zxvf libevent-2.1.12-stable.tar.gz \
&& cd libevent-2.1.12-stable \
&& LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS" ./configure --prefix=$TARGETDIR --enable-shared && make && make install \
&& cd ..

# Build ncurses
curl -LO https://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz \
&& tar zxvf ncurses-5.9.tar.gz \
&& cd ncurses-5.9 \
&& LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS" ./configure --prefix=$TARGETDIR --with-shared --with-termlib --enable-pc-files && make && make install \
&& cd ..

# utf8proc for macos
curl -LO https://github.com/JuliaStrings/utf8proc/releases/download/v2.9.0/utf8proc-2.9.0.tar.gz \
&& tar zxvf utf8proc-2.9.0.tar.gz \
&& cd utf8proc-2.9.0 \
&& LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS" make prefix=$TARGETDIR && make install prefix=$TARGETDIR \
&& cd ..

# Download and build tmux
curl -LO https://github.com/tmux/tmux/releases/download/3.4/tmux-3.4.tar.gz \
&& tar zxvf tmux-3.4.tar.gz \
&& cd tmux-3.4 \
&& PKG_CONFIG_PATH="$TMUX_LIB_DIR/pkgconfig" LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS" LIBS="-lresolv -lutf8proc" ./configure $TMUX_FLAGS --prefix=$TARGETDIR && make && make install \
&& cd ..

if [ "$OS" == "Linux" ]; then
find "$TARGETDIR/lib" -name "libutf8proc*.so*" -exec cp {} "$TMUX_LIB_DIR" \;
fi

# Copy all libraries to TMUX_LIB_DIR and refresh dependencies` paths for MacOS using install_name_tool
if [ "$OS" == "Darwin" ]; then
find "$TARGETDIR/lib" -name "*.dylib" -exec cp {} "$TMUX_LIB_DIR" \;

for lib in "$TMUX_LIB_DIR"/*.dylib; do
libname=$(basename "$lib")
install_name_tool -change "$TARGETDIR/lib/$libname" "@executable_path/../lib/$libname" "$TARGETDIR/bin/tmux"
done
fi

mv "$TARGETDIR/bin/tmux" "$TMUX_INSTALL_DIR/bin/tmux"

echo "tmux has been installed to $TMUX_INSTALL_DIR/bin/tmux with dependencies in $TMUX_LIB_DIR"
3 changes: 2 additions & 1 deletion packaging/rubygems/support/downloader/overmind_downloader.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# frozen_string_literal: true

require_relative "base_downloader"
require_relative "../../lib/overmind/version"

module Overmind
module Downloader
# Class for downloading Overmind binaries.
class OvermindDownloader < BaseDownloader
NAME = "overmind"
DEFAULT_VERSION = "2.4.0"
DEFAULT_VERSION = ::Overmind::VERSION
BASE_URL = "https://github.com/DarthSim/overmind/releases/download/v%s/%s"
TARGET_PATH = "libexec/overmind"
ALLOWED_PLATFORMS = %w[
Expand Down

0 comments on commit 25c99fb

Please sign in to comment.