refactor: make source-script with common fn, cleanup code -> trap
This commit is contained in:
parent
478659e4bc
commit
5a11c6cad0
4 changed files with 38 additions and 27 deletions
25
.build.sh
Normal file
25
.build.sh
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/echo Must be sourced from a bash script **
|
||||
|
||||
# strict mode
|
||||
export IFS=$'\n'
|
||||
set -eu -o pipefail
|
||||
|
||||
# git clone wrapper
|
||||
clone () {
|
||||
if ! [ -e "$2" ]; then
|
||||
git clone \
|
||||
--single-branch --depth 1 \
|
||||
--recurse-submodules \
|
||||
"$1" \
|
||||
"$2"
|
||||
else
|
||||
echo " ** '$2/' already exists"
|
||||
fi
|
||||
}
|
||||
|
||||
# make -j12
|
||||
make_maxthreads() {
|
||||
[ -v JOBS ] || JOBS=$(nproc || echo 4)
|
||||
JOBS="${JOBS//[^0-9]/}"
|
||||
make -j"$JOBS"
|
||||
}
|
15
build_dig.sh
15
build_dig.sh
|
@ -1,7 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
IFS=$'\n'
|
||||
set -eu -o pipefail
|
||||
source .build.sh
|
||||
|
||||
echo
|
||||
echo '==> Checking deps'
|
||||
|
@ -12,13 +11,10 @@ which gcc || which clang
|
|||
|
||||
echo
|
||||
echo '==> Cloning repo'
|
||||
if ! [ -e bind9 ]; then
|
||||
git clone --single-branch --depth 1 https://gitlab.isc.org/isc-projects/bind9.git bind9
|
||||
else
|
||||
echo ' ** bind9/ already exists'
|
||||
fi
|
||||
clone https://gitlab.isc.org/isc-projects/bind9.git bind9
|
||||
|
||||
cd bind9
|
||||
trap 'cd ..' EXIT
|
||||
export CFLAGS="-O3" CPPFLAGS="-O3"
|
||||
|
||||
echo
|
||||
|
@ -38,10 +34,7 @@ echo '==> ./configure (check deps, generate config)'
|
|||
|
||||
echo
|
||||
echo '==> make'
|
||||
make -j$(nproc)
|
||||
|
||||
unset CFLAGS CPPFLAGS
|
||||
cd ..
|
||||
make_maxthreads
|
||||
|
||||
echo
|
||||
echo '==> Done'
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
IFS=$'\n'
|
||||
set -eu -o pipefail
|
||||
source .build.sh
|
||||
|
||||
echo
|
||||
echo '==> Checking deps'
|
||||
|
@ -13,13 +12,10 @@ which gcc || which clang
|
|||
|
||||
echo
|
||||
echo '==> Cloning repo'
|
||||
if ! [ -e ldns ]; then
|
||||
git clone --single-branch --depth 1 --recurse-submodules https://github.com/NLnetLabs/ldns.git ldns
|
||||
else
|
||||
echo ' ** ldns/ already exists'
|
||||
fi
|
||||
clone https://github.com/NLnetLabs/ldns.git ldns
|
||||
|
||||
cd ldns
|
||||
trap 'cd ..' EXIT
|
||||
export CFLAGS="-O3"
|
||||
|
||||
echo
|
||||
|
@ -42,10 +38,7 @@ echo '==> ./configure (check deps, generate config)'
|
|||
|
||||
echo
|
||||
echo '==> make'
|
||||
make -j$(nproc || echo 4)
|
||||
|
||||
unset CFLAGS
|
||||
cd ..
|
||||
make_maxthreads
|
||||
|
||||
echo
|
||||
echo '==> Done'
|
||||
|
|
10
build_hr.sh
10
build_hr.sh
|
@ -1,7 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
IFS=$'\n'
|
||||
set -eu -o pipefail
|
||||
source .build.sh
|
||||
|
||||
echo
|
||||
echo '==> Checking deps'
|
||||
|
@ -10,18 +9,19 @@ which cargo
|
|||
|
||||
echo
|
||||
echo '==> Cloning repo'
|
||||
git clone --single-branch --depth 1 https://github.com/hickory-dns/hickory-dns.git hickory-dns
|
||||
clone https://github.com/hickory-dns/hickory-dns.git hickory-dns
|
||||
|
||||
cd hickory-dns
|
||||
trap 'cd ..' EXIT
|
||||
|
||||
echo
|
||||
echo '==> Building resolve'
|
||||
cd hickory-dns
|
||||
cargo build \
|
||||
--release \
|
||||
--bin resolve \
|
||||
--features dnssec-ring \
|
||||
--config 'panic="abort"' \
|
||||
--config 'lto="fat"'
|
||||
cd ..
|
||||
|
||||
echo
|
||||
echo '==> Done'
|
||||
|
|
Loading…
Add table
Reference in a new issue