Last active
December 22, 2017 07:10
-
-
Save mdaniel/fd08b8675fd55ab886535fe1a132b8b5 to your computer and use it in GitHub Desktop.
Build [asuswrt-merlin](https://github.com/RMerl/asuswrt-merlin#readme) using Vagrant. This is just works-for-me, and not an officially supported mechanism
This file contains hidden or 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 | |
set -e | |
if [[ -z "$GIT_DIR" ]]; then | |
echo 'You will want $GIT_DIR' >&2 | |
exit 1 | |
elif [[ ! -d "$GIT_DIR" ]]; then | |
echo "It seems git-dir \"$GIT_DIR\" is 404" >&2 | |
exit 1 | |
fi | |
dir=`dirname $0` | |
dir=`cd $dir && pwd` | |
build_dir=$dir/release/src-rt-6.x | |
cd $build_dir | |
PATH=$dir/tools/brcm/hndtools-mipsel-uclibc/bin:$PATH | |
if [[ -z "$MAKE_JOBS" ]]; then | |
MAKE_JOBS=$(nproc) | |
fi | |
# just documenting the reason | |
rc4_h_err=<<'RC4ERR' | |
make[6]: *** No rule to make target `../../include/openssl/rc4.h', needed by `eng_openssl.o'. Stop. | |
make[6]: Leaving directory `/home/vagrant/asuswrt-merlin/release/src/router/openssl/crypto/engine' | |
make[5]: *** [subdirs] Error 1 | |
RC4ERR | |
if [[ ! -e ../src/router/openssl/include/openssl/rc4.h ]]; then | |
echo 'I am fixing up an ssl include dumbness' >&2 | |
sleep 2 | |
ln -s ../../crypto/rc4/rc4.h ../src/router/openssl/include/openssl/rc4.h | |
fi | |
# just a comment showing what we are working around | |
bogus_err=<<'ERR' | |
make -C tor -j`grep -c '^processor' /proc/cpuinfo` | |
make[4]: Entering directory `/home/vagrant/asuswrt-merlin/release/src/router/tor' | |
CDPATH="${ZSH_VERSION+.}:" && cd . && aclocal-1.15 -I m4 | |
/bin/bash: aclocal-1.15: command not found | |
ERR | |
# :point_up: :point_down: | |
for i in libogg tor wget; do | |
cd ../src/router/${i} | |
if grep -iq gettext configure.??; then | |
gettextize --force | |
fi | |
autoreconf -fvis | |
cd $OLDPWD | |
done | |
rc=0 | |
# using a function makes the || syntax less wonky in the if | |
make_rt_n66u() { | |
make V=1 VERBOSE=1 -j${MAKE_JOBS} rt-n66u || rc=$? | |
} | |
t0=`date +%s` | |
if ! make_rt_n66u; then | |
echo "MAKE.RC=$rc" >&2 | |
fi | |
t1=`date +%s` | |
tt=$(( $t1 - $t0 )) | |
mv -iv $build_dir/image/*.trx /vagrant/ | |
if [[ -f nohup.out ]] && [[ ! -s nohup.out ]]; then | |
mv -iv nohup.out /vagrant/build-`date +%s`.log | |
else | |
logf=`/bin/ls -1 build-*.out` | |
fi | |
if [[ "$logf" ]] && [[ -f "$logf" ]]; then | |
mv -iv $logf /vagrant/ | |
fi | |
echo "OK: $rc in $tt seconds" | |
exit $rc |
This file contains hidden or 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
# the resulting image won't be 64 bit, | |
# so adding that into the mix just makes life painful | |
config.vm.box = "ubuntu/trusty32" | |
config.vm.boot_timeout = 3600 | |
config.vm.provider "virtualbox" do |vb| | |
vb.cpus = 8 | |
vb.memory = 4 * 1024 | |
end | |
# this needs to be a file on the machine so we can re-exec | |
# into it as "vagrant" after the priviledged operations are over | |
config.vm.provision :file, | |
:source => "Vagrantfile.sh", | |
:destination => "/tmp/provision.sh" | |
config.vm.provision :shell, | |
:inline => "/tmp/provision.sh", | |
:privileged => true | |
end |
This file contains hidden or 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 | |
set -e | |
if [[ 0 == `id -u` ]]; then | |
# set -x | |
export DEBIAN_FRONTEND=noninteractive | |
apt_cache_tar=/vagrant/var_cache_apt.tar | |
tar_cmd=c | |
if [[ -f $apt_cache_tar ]]; then | |
tar -xvf $apt_cache_tar -C / | |
tar_cmd=u | |
fi | |
apt-get update | |
_apt_get() { | |
for i in 1 2 3; do | |
apt-get "$@" && return 0 | |
done | |
return 1 | |
} | |
# set them to download first, then install them | |
apt_extra='-d' | |
for x in 1 2; do | |
if [[ $x == 2 ]]; then | |
cd / | |
tar -${tar_cmd}vf $apt_cache_tar var/cache/apt var/lib/dpkg var/lib/apt | |
fi | |
_apt_get --no-install-recommends install -y \ | |
$apt_extra \ | |
autoconf automake bash bison bzip2 diffutils file flex g++ gawk \ | |
gcc-multilib gettext gperf groff-base libncurses-dev libexpat1-dev \ | |
libslang2 libssl-dev libtool libxml-parser-perl make patch perl pkg-config \ | |
python sed shtool tar texinfo unzip zlib1g zlib1g-dev \ | |
git-core \ | |
libstdc++6 automake1.11 intltool autopoint \ | |
libelf-dev:i386 libelf1:i386 | |
apt_extra='' | |
done | |
echo '===' | |
echo '=== Switching to the vagrant user for the build...' | |
echo '===' | |
exec sudo -i -u vagrant bash -x "$0" "$@" | |
fi | |
VER="${1:-380.69}" | |
cd ~vagrant | |
# set this so the git info will be available to "make" | |
export GIT_DIR=/vagrant/.git | |
if [[ ! -d "$GIT_DIR" ]]; then | |
echo "EGAD, git-dir \"$GIT_DIR\" is 404" >&2 | |
exit 1 | |
fi | |
mkdir -p asuswrt-merlin | |
cd asuswrt-merlin | |
cp /vagrant/build.sh . | |
git checkout --force $VER | |
git reset --hard $VER | |
ls -la | |
# we have to disown this since this script is running in :provision | |
nohup bash -xc "./build.sh &>build-${VER}.out" & | |
ls -la | |
ps -efw | |
disown |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment