-
-
Save eminence/85961d47244a140fde89314837d0db0a 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 | |
| download https://github.com/mobile-shell/mosh/releases/download/mosh-1.3.2/mosh-1.3.2.tar.gz | |
| 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-1.3.2 | |
| 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 | |
| ./configure --prefix=${INSTALL_DIR} && make $MAKEOPTS && make install | |
| echo "Mosh done" | |
| echo "Everything done" | |
| echo "Installed to ${INSTALL_DIR}" |
Also, because POSIX doesn’t believe in first-order logic, set -e is not tripped by the failure of the first command in an && chain. Use separate commands instead. I got this error (which is puzzling in its own right, but should have at least triggered a script failure).
gcc -DHAVE_CONFIG_H -I. -I../include -D_GNU_SOURCE -DNDEBUG -I/tmp/m/prefix//include -fPIC --param max-inline-insns-single=1200 -c ../ncurses/./base/lib_hline.c -o ../objects/lib_hline.o
In file included from ./curses.priv.h:325:0,
from ../ncurses/lib_gen.c:19:
_30028.c:1372:15: error: expected ‘)’ before ‘int’
../include/curses.h:1943:56: note: in definition of macro ‘mouse_trafo’
#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
^
Makefile:1022: recipe for target '../objects/lib_gen.o' failed
make[1]: *** [../objects/lib_gen.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/tmp/m/downloads/ncurses-6.0/ncurses'
Makefile:113: recipe for target 'all' failed
make: *** [all] Error 2
Ncursesw done. Press enter to continue
Maybe add -O2 to CFLAGS unless you meant to disable optimization? (Typical configure scripts default to -O2 only if CFLAGS is unset.)
-I${INSTALL_DIR}/include should be unnecessary if pkg-config is installed (and I don’t think this works if it isn’t).
@andersk Thanks for the notes. Curiously I did not see that ncurses error - I'm building in a Docker based on latest Fedora (because I am looking for a portable build for a RH-ish OS) - I guess the compilers differ.
What I am looking at now is a different set of ncurses configure options to try and get a typical binary output i.e. matching what you would see in a dist with ncurses installed.
@andersk @javabrett the ncurses build failure is fixed by exporting CPPFLAGS="-P"
Bashism nits:
function download {is a bashism, usedownload () {instead.==is a bashism, use=instead.export CXXFLAGS=$CFLAGSneeds to be quoted asexport CXXFLAGS="$CFLAGS".Consider running
shellcheckto see some other bugs, but these ones break the script on/bin/sh -> dashsystems even without, e.g., unusual characters in the directory name.Also, ftp.gnu.org encourages the use of https.