Skip to content

Instantly share code, notes, and snippets.

@idvorkin
Forked from eminence/build-mosh-and-tmux.sh
Last active June 1, 2019 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idvorkin/bd8b273024d5b596ab4703d2481dc491 to your computer and use it in GitHub Desktop.
Save idvorkin/bd8b273024d5b596ab4703d2481dc491 to your computer and use it in GitHub Desktop.
#!/bin/sh
## https://gist.github.com/eminence/85961d47244a140fde89314837d0db0a
set -e
PWD=`pwd`
DD=$PWD/downloads/ # Download Directory
function download {
BASE=`basename $1`
mkdir -p $DD
if [ -e $DD/$BASE ]; then
echo "$BASE is already downloaded, skipping."
return 0
fi
curl -o $DD/$BASE -L $1
}
echo -n "Do you want to download packages into $DD/ ? [y/N] "
read do_download
if [ "$do_download" == "y" ]; then
download https://github.com/tmux/tmux/releases/download/2.6/tmux-2.6.tar.gz
download https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
download http://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz
download https://github.com/google/protobuf/releases/download/v3.4.1/protobuf-cpp-3.4.1.tar.gz
git clone https://github.com/mobile-shell/mosh $DD/mosh
download https://www.openssl.org/source/openssl-1.0.2l.tar.gz
download https://github.com/telmich/gpm/archive/1.20.7.tar.gz
file downloads/*
echo ""
echo "Unpacking all the tarballs"
(cd downloads; ls *.tar.gz | xargs -n1 tar -zxf)
else
echo "You are expected to manually put the necessary files into $DD/"
fi
TMUX_SRC_DIR=$DD/tmux-2.6
LIBEVENT_SRC_DIR=$DD/libevent-2.1.8-stable
NCURSES_SRC_DIR=$DD/ncurses-6.0
PROTOBUF_SRC_DIR=$DD/protobuf-3.4.1
MOSH_SRC_DIR=$DD/mosh
OPENSSL_SRC_DIR=$DD/openssl-1.0.2l
GPM_SRC_DIR=$DD/gpm-1.20.7
#INSTALL_DIR=$PWD/prefix/
INSTALL_DIR=/rd/gen/lxd/do_not_delete/$PLATIDENT/prefix
echo ""
echo "========================================"
echo "About to build the following packages:"
(cd $DD; ls -1 *.tar.gz)
echo ""
echo "Everything will be installed to ${INSTALL_DIR}"
echo "Temporary build dir: ${PWD}"
echo "Press enter to continue or ctrl-c to exit"
read c
export CFLAGS="-I${INSTALL_DIR}/include -fPIC"
export CXXFLAGS=$CFLAGS
export PATH="${INSTALL_DIR}/bin:${PATH}"
export LDFLAGS="-L${INSTALL_DIR}/lib -Wl,-rpath,${INSTALL_DIR}/lib"
export PKG_CONFIG_PATH="${INSTALL_DIR}/lib/pkgconfig"
export LD_LIBRARY_PATH="${INSTALL_DIR}/lib"
MAKEOPTS=-j4
cd $LIBEVENT_SRC_DIR
make clean || echo
./configure --enable-static=yes --enable-shared=yes --prefix=${INSTALL_DIR} && make $MAKEOPTS && make install
echo "libevent done. Press enter to continue"
read c
cd $OPENSSL_SRC_DIR
make clean || echo
./config no-shared -fPIC --prefix=${INSTALL_DIR} && make $MAKEOPTS && make install
echo "Openssl done. Press enter to continue"
read c
echo "Building protobuf..."
cd $PROTOBUF_SRC_DIR
make clean || echo
./configure --disable-shared --prefix=${INSTALL_DIR}; make $MAKEOPTS && make install
echo "protobuf done. Press enter to continue"
read c
echo "Building ncursesw..."
cd $NCURSES_SRC_DIR
make clean || echo
./configure --enable-pc-files --enable-widec --without-gpm --with-pkg-config-libdir=${PKG_CONFIG_PATH} --prefix=${INSTALL_DIR} && make $MAKEOPTS && make install
echo "Ncursesw done. Press enter to continue"
read c
echo "Building ncurses..."
cd $NCURSES_SRC_DIR
make clean || echo
./configure --enable-pc-files --without-gpm --with-pkg-config-libdir=${PKG_CONFIG_PATH} --prefix=${INSTALL_DIR} && make $MAKEOPTS && make install
echo "Ncurses done. Press enter to continue"
read c
echo "Building tmux..."
cd $TMUX_SRC_DIR
make clean || echo
./configure --prefix=${INSTALL_DIR} && make $MAKEOPTS && make install
echo "tmux done. Press enter to continue"
read c
echo "Building mosh..."
cd $MOSH_SRC_DIR
make clean || echo
./autogen.sh
./configure --prefix=${INSTALL_DIR} && make $MAKEOPTS && make install
echo "Mosh done"
echo "Everything done"
echo "Installed to ${INSTALL_DIR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment