summaryrefslogtreecommitdiffstats
path: root/makeself
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2017-09-16 23:53:34 +0300
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2017-09-16 23:53:34 +0300
commitf5a751e82e71eaa8533cda3700face2025c712ce (patch)
tree760ea5ff6736b02626e4c149f5601e6e2160c8b2 /makeself
parentb1522345c3449bbd6c63f2d2b24475f0662b45d8 (diff)
allow netdata binaries to be compiled with debugging info
Diffstat (limited to 'makeself')
-rw-r--r--makeself/Makefile.am2
-rw-r--r--makeself/README.md46
-rwxr-xr-xmakeself/build-x86_64-static.sh14
-rwxr-xr-xmakeself/build.sh24
-rwxr-xr-xmakeself/functions.sh1
-rwxr-xr-xmakeself/install-alpine-packages.sh (renamed from makeself/setup-x86_64-static.sh)0
-rwxr-xr-xmakeself/jobs/50-bash-4.4.install.sh5
-rwxr-xr-xmakeself/jobs/50-curl-7.53.1.install.sh5
-rwxr-xr-xmakeself/jobs/50-fping-4.0.install.sh5
-rwxr-xr-xmakeself/jobs/70-netdata-git.install.sh15
10 files changed, 102 insertions, 15 deletions
diff --git a/makeself/Makefile.am b/makeself/Makefile.am
index 6287938686..923f3cefba 100644
--- a/makeself/Makefile.am
+++ b/makeself/Makefile.am
@@ -7,7 +7,7 @@ dist_noinst_SCRIPTS = \
build.sh \
makeself.sh \
makeself-license.txt \
- setup-x86_64-static.sh \
+ install-alpine-packages.sh \
post-installer.sh \
jobs/10-prepare-destination.install.sh \
jobs/50-curl-7.53.1.install.sh \
diff --git a/makeself/README.md b/makeself/README.md
new file mode 100644
index 0000000000..de54eb349e
--- /dev/null
+++ b/makeself/README.md
@@ -0,0 +1,46 @@
+# netdata static binary build
+
+To build the static binary 64bit distribution package, run:
+
+```bash
+$ cd /path/to/netdata.git
+$ ./makeself/build-x86_64-static.sh
+```
+
+The program will:
+
+1. setup a new docker container with Alpine Linux
+2. install the required alpine packages (the build environment, needed libraries, etc)
+3. download and compile third party apps that are packaged with netdata (`bash`, `curl`, etc)
+4. compile netdata
+
+Once finished, a file named `netdata-vX.X.X-gGITHASH-x86_64-DATE-TIME.run` will be created in the current directory. This is the netdata binary package that can be run to install netdata on any other computer.
+
+---
+
+## building binaries with debug info
+
+To build netdata binaries with debugging / tracing information in them, use:
+
+```bash
+$ cd /path/to/netdata.git
+$ ./makeself/build-x86_64-static.sh debug
+```
+
+These binaries are not optimized (they are a bit slower), they have certain features disables (like log flood protection), other features enables (like `debug flags`) and are not stripped (the binary files are bigger, since they now include source code tracing information).
+
+#### debugging netdata binaries
+
+Once you have installed a binary package with debugging info, you will need to install `valgrind` and run this command to start netdata:
+
+```bash
+PATH="/opt/netdata/bin:${PATH}" valgrind --undef-value-errors=no /opt/netdata/bin/srv/netdata -D
+```
+
+The above command, will run netdata under `valgrind`. While netdata runs under `valgrind` it will be 10x slower and use a lot more memory.
+
+If netdata crashes, `valgrind` will print a stack trace of the issue. Open a github issue to let us know.
+
+To stop netdata while it runs under `valgrind`, press Control-C on the console.
+
+> If you ommit the parameter `--undef-value-errors=no` to valgrind, you will get hundreds of errors about conditional jumps that depend on unitialized values. This is normal. Valgrind has heuristics to prevent it from printing such errors for system libraries, but for the static netdata binary, all the required libraries are built into netdata. So, valgrind cannot appply its heuristics and prints them.
diff --git a/makeself/build-x86_64-static.sh b/makeself/build-x86_64-static.sh
index 0516beae2c..f3d33b276a 100755
--- a/makeself/build-x86_64-static.sh
+++ b/makeself/build-x86_64-static.sh
@@ -1,5 +1,7 @@
#!/usr/bin/env sh
+. $(dirname "$0")/../installer/functions.sh || exit 1
+
set -e
DOCKER_CONTAINER_NAME="netdata-package-x86_64-static"
@@ -16,22 +18,22 @@ then
#
# This command maps the current directory to
# /usr/src/netdata.git
- # inside the container and runs the script setup-x86_64-static.sh
+ # inside the container and runs the script install-alpine-packages.sh
# (also inside the container)
#
- sudo docker run -v $(pwd):/usr/src/netdata.git:rw alpine:3.5 \
- /bin/sh /usr/src/netdata.git/makeself/setup-x86_64-static.sh
+ run sudo docker run -v $(pwd):/usr/src/netdata.git:rw alpine:3.6 \
+ /bin/sh /usr/src/netdata.git/makeself/install-alpine-packages.sh
# save the changes made permanently
id=$(sudo docker ps -l -q)
- sudo docker commit ${id} "${DOCKER_CONTAINER_NAME}"
+ run sudo docker commit ${id} "${DOCKER_CONTAINER_NAME}"
fi
# Run the build script inside the container
-sudo docker run -a stdin -a stdout -a stderr -i -t -v \
+run sudo docker run -a stdin -a stdout -a stderr -i -t -v \
$(pwd):/usr/src/netdata.git:rw \
"${DOCKER_CONTAINER_NAME}" \
- /bin/sh /usr/src/netdata.git/makeself/build.sh
+ /bin/sh /usr/src/netdata.git/makeself/build.sh "${@}"
if [ "${USER}" ]
then
diff --git a/makeself/build.sh b/makeself/build.sh
index 7896425d7e..afa4f545e5 100755
--- a/makeself/build.sh
+++ b/makeself/build.sh
@@ -1,6 +1,28 @@
#!/usr/bin/env sh
-# First run setup-x86_64-static.sh under alpine linux to install
+# -----------------------------------------------------------------------------
+# parse command line arguments
+
+export NETDATA_BUILD_WITH_DEBUG=0
+
+while [ ! -z "${1}" ]
+do
+ case "${1}" in
+ debug)
+ export NETDATA_BUILD_WITH_DEBUG=1
+ ;;
+
+ *)
+ ;;
+ esac
+
+ shift
+done
+
+
+# -----------------------------------------------------------------------------
+
+# First run install-alpine-packages.sh under alpine linux to install
# the required packages. build-x86_64-static.sh will do this for you
# using docker.
diff --git a/makeself/functions.sh b/makeself/functions.sh
index c015a97da4..a72a1f4110 100755
--- a/makeself/functions.sh
+++ b/makeself/functions.sh
@@ -3,6 +3,7 @@
# -----------------------------------------------------------------------------
# allow running the jobs by hand
+[ -z "${NETDATA_BUILD_WITH_DEBUG}" ] && export NETDATA_BUILD_WITH_DEBUG=0
[ -z "${NETDATA_INSTALL_PATH}" ] && export NETDATA_INSTALL_PATH="${1-/opt/netdata}"
[ -z "${NETDATA_MAKESELF_PATH}" ] && export NETDATA_MAKESELF_PATH="$(dirname "${0}")/.."
[ "${NETDATA_MAKESELF_PATH:0:1}" != "/" ] && export NETDATA_MAKESELF_PATH="$(pwd)/${NETDATA_MAKESELF_PATH}"
diff --git a/makeself/setup-x86_64-static.sh b/makeself/install-alpine-packages.sh
index 87cd29669d..87cd29669d 100755
--- a/makeself/setup-x86_64-static.sh
+++ b/makeself/install-alpine-packages.sh
diff --git a/makeself/jobs/50-bash-4.4.install.sh b/makeself/jobs/50-bash-4.4.install.sh
index 07c84b6d76..8019cefb7b 100755
--- a/makeself/jobs/50-bash-4.4.install.sh
+++ b/makeself/jobs/50-bash-4.4.install.sh
@@ -44,4 +44,7 @@ EOF
run make install
-run strip ${NETDATA_INSTALL_PATH}/bin/bash
+if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]
+then
+ run strip ${NETDATA_INSTALL_PATH}/bin/bash
+fi
diff --git a/makeself/jobs/50-curl-7.53.1.install.sh b/makeself/jobs/50-curl-7.53.1.install.sh
index 0e375a9180..038fb2ac9f 100755
--- a/makeself/jobs/50-curl-7.53.1.install.sh
+++ b/makeself/jobs/50-curl-7.53.1.install.sh
@@ -27,4 +27,7 @@ run make clean
run make -j${PROCESSORS}
run make install
-run strip ${NETDATA_INSTALL_PATH}/bin/curl
+if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]
+then
+ run strip ${NETDATA_INSTALL_PATH}/bin/curl
+fi
diff --git a/makeself/jobs/50-fping-4.0.install.sh b/makeself/jobs/50-fping-4.0.install.sh
index dbc91c51d0..ce6cb270e3 100755
--- a/makeself/jobs/50-fping-4.0.install.sh
+++ b/makeself/jobs/50-fping-4.0.install.sh
@@ -22,4 +22,7 @@ run make clean
run make -j${PROCESSORS}
run make install
-run strip ${NETDATA_INSTALL_PATH}/bin/fping
+if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]
+then
+ run strip ${NETDATA_INSTALL_PATH}/bin/fping
+fi
diff --git a/makeself/jobs/70-netdata-git.install.sh b/makeself/jobs/70-netdata-git.install.sh
index 873830f9ff..0486ce11a8 100755
--- a/makeself/jobs/70-netdata-git.install.sh
+++ b/makeself/jobs/70-netdata-git.install.sh
@@ -4,13 +4,20 @@
cd "${NETDATA_SOURCE_PATH}" || exit 1
-export CFLAGS="-O3 -static"
+if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]
+then
+ export CFLAGS="-static -O3"
+else
+ export CFLAGS="-static -O1 -ggdb -Wall -Wextra -Wformat-signedness -fstack-protector-all -D_FORTIFY_SOURCE=2 -DNETDATA_INTERNAL_CHECKS=1"
+fi
run ./netdata-installer.sh --install "${NETDATA_INSTALL_PARENT}" \
--dont-wait \
--dont-start-it \
${NULL}
-run strip ${NETDATA_INSTALL_PATH}/bin/netdata
-run strip ${NETDATA_INSTALL_PATH}/usr/libexec/netdata/plugins.d/apps.plugin
-
+if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]
+then
+ run strip ${NETDATA_INSTALL_PATH}/bin/netdata
+ run strip ${NETDATA_INSTALL_PATH}/usr/libexec/netdata/plugins.d/apps.plugin
+fi