# Produce standard tools tarballs using linuxbrew
# Customize the variables as desired
# Software depot to archive releases
DEPOT = depot@slice.tundraware.com:/opt/depot/
# Defaults for linuxbrew
LINUXBREWDIR = /home/linuxbrew
LINUXBREWINSTALL = ${LINUXBREWDIR}/.linuxbrew
# Where to store build tarballs
EXPORTDIR = /shared
# Where tools directory lives
INSTALLDIR = /opt/TundraWare
# Name of the tools directory
TOOLS = tools
# Things that have to be built during the bootstrap phase with system tools
BOOTSTRAP = gcc make curl git
# Support and languages to install after bootstrap but before other packages
LANGS = gforth go perl python
# Stuff we want pip to install
PIPMODULES = ansible pew pythonz-bd mutagen docutils
# Set of packages we want to include in the distribution tarball
MYTOOLS = coreutils emacs file-formula findutils gawk gnu-sed gnu-tar grep htop joe nload nmap pyenv screen socat source-highlight ripgrep the_silver_searcher tree vim
# ----------- Nothing below here should need changing ----------- #
TOOLSDIR = ${INSTALLDIR}/${TOOLS}
BREW = ${TOOLSDIR}/bin/brew -v
DATESTAMPBKU = $(shell date +%Y%m%d@%H:%M:%s)
DATESTAMP = $(shell date +%Y%m%d)
FULLDATE = $(shell date)
GITREVISION = $(shell git log -1 | head -n3)
all: clean getbrew bootstrap-build bootstrap-release full-build full-release
#####
# Install from linuxbrew binaries
# You can ignore everything after this stanza
# other than the full release logic
#####
linuxbrew:
-mv ${TOOLSDIR} ${TOOLSDIR}.${DATESTAMPBKU}
mkdir -p ${TOOLSDIR}
sudo mkdir -p ${LINUXBREWDIR}
sudo ln -nfs ${TOOLSDIR} ${LINUXBREWINSTALL}
git clone https://github.com/Homebrew/brew ${TOOLSDIR}
${BREW} install --verbose ${BOOTSTRAP} ${LANGS} ${MYTOOLS}
${BREW} install -s --verbose ${LANGS}
ln -nfs ${TOOLSDIR}/bin/python3 ${TOOLSDIR}/bin/python
ln -nfs ${TOOLSDIR}/bin/pip3 ${TOOLSDIR}/bin/pip
pip install ${PIPMODULES} -U --ignore-installed --break-system-packages
#####
# Build everyting from source
#####
# Get latest linuxbrew
getbrew:
@echo "Make sure you have write permission on the target directory!"
git clone https://github.com/Homebrew/brew ${TOOLSDIR}
# Bootstrapping
bootstrap-build:
ulimit -n 65535
@echo "Make sure you have the OS development tools installed!"
# sudo yum -y install texinfo
${BREW} install --verbose ${BOOTSTRAP}
# ${BREW} reinstall -s --verbose curl
bootstrap-release: tidyup
echo "${FULLDATE}" >> ${TOOLSDIR}/tools-builder.bootstrap.datetime
echo "${GITREVISION}" >> ${TOOLSDIR}/tools-builder.bootstrap.gitrevision
cd ${INSTALLDIR} && mv -v ${TOOLS} ${TOOLS}-bootstrap-${DATESTAMP}
cd ${INSTALLDIR} && tar -czvf ${EXPORTDIR}/${TOOLS}-bootstrap-${DATESTAMP}.tar.gz ${TOOLS}-bootstrap-${DATESTAMP}
cd ${INSTALLDIR} && mv -v ${TOOLS}-bootstrap-${DATESTAMP} ${TOOLS}
# Full tools set
full-build:
# Do some housekeeping
ulimit -n 65535
@echo "Make sure the bootstrap is installed at ${TOOLSDIR}"
# sudo yum -y install autoconf automake patch perl texinfo
brew unlink util-linux
${BREW} install -s --verbose ${LANGS}
ln -nfs ${TOOLSDIR}/bin/python3 ${TOOLSDIR}/bin/python
ln -nfs ${TOOLSDIR}/bin/pip3 ${TOOLSDIR}/bin/pip
pip install ${PIPMODULES} -U --ignore-installed --break-system-packages
brew link util-linux
${BREW} install -s --verbose ${MYTOOLS}
ln -nfs ${TOOLSDIR}/bin/vim ${TOOLSDIR}/bin/vi
${BREW} install -s --verbose the_silver_searcher
full-release: tidyup
echo "${FULLDATE}" >> ${TOOLSDIR}/tools-builder.full.datetime
echo "${GITREVISION}" >> ${TOOLSDIR}/tools-builder.full.gitrevision
cd ${INSTALLDIR} && mv -v ${TOOLS} ${TOOLS}-${DATESTAMP}
cd ${INSTALLDIR} && tar -czvf ${EXPORTDIR}/${TOOLS}-${DATESTAMP}.tar.gz ${TOOLS}-${DATESTAMP}
cd ${INSTALLDIR} && mv -v ${TOOLS}-${DATESTAMP} ${TOOLS}
upgrade:
echo "${FULLDATE}" >> ${TOOLSDIR}/tools-builder.upgrade.datetime
echo "${GITREVISION}" >> ${TOOLSDIR}/tools-builder.upgrade.gitrevision
brew update
brew upgrade
brew unlink python
brew link --overwrite python
pip install ${PIPMODULES} -U --ignore-installed
insecure:
echo insecure >> ~/.curlrc
git config --global http.sslVerify false
# Housekeeping
push-release:
scp ${EXPORTDIR}/${TOOLS}-${DATESTAMP}.tar.gz ${DEPOT}
tidyup:
${BREW} config
${BREW} cleanup
-${BREW} doctor
clean:
cd ${INSTALLDIR} && rm -vrf ${TOOLS} ${TOOLS}-bootstrap-${DATESTAMP} ${TOOLS}-${DATESTAMP}