Last active
July 21, 2019 17:44
-
-
Save cisano-arelia/11f206d6c234bd92faf9 to your computer and use it in GitHub Desktop.
Script to build a static tmux for CoreOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#Author: https://groups.google.com/forum/#!topic/coreos-dev/JAeABXnQzuE | |
pushd $(dirname $0) > /dev/null; CURRABSPATH=$(readlink -nf "$(pwd)"); popd > /dev/null; # Get the directory in which the script resides | |
set -x | |
MUSLPKG="musl:musl.tgz:http://www.musl-libc.org/releases/musl-1.1.14.tar.gz" | |
LEVTPKG="libevent:libevent2.tgz:https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz" | |
TMUXPKG="tmux:tmux.tgz:https://github.com/tmux/tmux/releases/download/2.1/tmux-2.1.tar.gz" | |
NCRSPKG="ncurses:ncurses.tgz:http://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz" | |
TEMPDIR="$CURRABSPATH/tmp" | |
TMPLIB="tempinstall/lib" | |
TMPINC="tempinstall/include" | |
MUSLCC="$TEMPDIR/musl/tempinstall/bin/musl-gcc" | |
[[ -d "$TEMPDIR" ]] || mkdir "$TEMPDIR" || { echo "FATAL: Could not create $TEMPDIR."; exit 1; } | |
for i in "$MUSLPKG" "$NCRSPKG" "$LEVTPKG" "$TMUXPKG"; do | |
NAME=${i%%:*} | |
i=${i#*:} | |
TGZ=${i%%:*} | |
URL=${i#*:} | |
[[ -d "$TEMPDIR/$NAME" ]] && rm -rf "$TEMPDIR/$NAME" | |
[[ -d "$TEMPDIR/$NAME" ]] || mkdir "$TEMPDIR/$NAME" || { echo "FATAL: Could not create $TEMPDIR/$NAME."; exit 1; } | |
[[ -f "$CURRABSPATH/$TGZ" ]] || wget -O "$CURRABSPATH/$TGZ" "$URL" || { echo "FATAL: failed to fetch $URL."; exit 1; } | |
echo "Unpacking $NAME" && tar --strip-components=1 -C "$TEMPDIR/$NAME" -xf "$TGZ" && mkdir "$TEMPDIR/$NAME/tempinstall" \ | |
|| { echo "FATAL: Could not unpack one of the required source packages. Check above output for clues."; exit 1; } | |
echo "Building $NAME (this may take some time)" | |
( | |
PREFIX="$TEMPDIR/$NAME/tempinstall" | |
case $NAME in | |
musl ) | |
(cd "$TEMPDIR/$NAME" && ./configure --enable-gcc-wrapper --prefix="$PREFIX") && \ | |
make -C "$TEMPDIR/$NAME" && make -C "$TEMPDIR/$NAME" install | |
;; | |
ncurses ) | |
(cd "$TEMPDIR/$NAME" && ./configure --without-ada --without-cxx --without-progs --without-manpages --disable-db-install --without-tests --with-default-terminfo-dir=/usr/share/terminfo --with-terminfo-dirs="/etc/terminfo:/lib/terminfo:/usr/share/terminfo" --prefix="$PREFIX" CC="$MUSLCC") && \ | |
make -C "$TEMPDIR/$NAME" && make -C "$TEMPDIR/$NAME" install | |
;; | |
libevent ) | |
(cd "$TEMPDIR/$NAME" && ./configure --enable-static --enable-shared --disable-openssl --prefix="$PREFIX" CC="$MUSLCC") && \ | |
make -C "$TEMPDIR/$NAME" && make -C "$TEMPDIR/$NAME" install | |
;; | |
tmux ) | |
(cd "$TEMPDIR/$NAME" && ./configure --enable-static --prefix="$PREFIX" CC="$MUSLCC" CPPFLAGS="-I$TEMPDIR/libevent/$TMPINC -I$TEMPDIR/ncurses/$TMPINC -I$TEMPDIR/ncurses/$TMPINC/ncurses" LDFLAGS="-L$TEMPDIR/libevent/$TMPLIB -L$TEMPDIR/ncurses/$TMPLIB" LIBS=-lncurses) && \ | |
make -C "$TEMPDIR/$NAME" && make -C "$TEMPDIR/$NAME" install | |
strip $PREFIX/bin/tmux | |
;; | |
esac | |
) 2>&1 |tee "$TEMPDIR/${NAME}.log" > /dev/null || { echo "FATAL: failed to build $NAME. Consult $TEMPDIR/${NAME}.log for details."; exit 1; } | |
unset CC | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scp tmp/tmux/tempinstall/bin/tmux [email protected]: | |
ssh [email protected] | |
sudo mv tmux /opt/bin # create this dir if it doesn't exist before moving |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get install g++-multilib build-essential checkinstall wget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo systemd-run --gid=core --uid=core -r /bin/sh -c "/opt/bin/tmux -C" | |
/opt/bin/tmux a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment