Here is a compilation of arangodb errors - configure

What's the problem with the configure code?
ERROR INFO:
./configure: line 9746: syntax error near unexpected token `else'
./configure: line 9746: `else'
CONFIGURE CODE:
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
OPENSSL_WARNING=" WARNING: OpenSSL version should be 1.0.1g or higher"
{ $as_echo "$as_me:$LINENO: WARNING: OpenSSL version should be 1.0.1g or higher." >&5
$as_echo "$as_me: WARNING: OpenSSL version should be 1.0.1g or higher." >&2;}
fi

There's something wrong with your configure script it seems. In the version on Github I see this code:
if ac_fn_c_try_compile "$LINENO"; then :
else
OPENSSL_WARNING=" WARNING: OpenSSL version should be 1.0.1g or higher"
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: OpenSSL version should be 1.0.1g or higher." >&5
$as_echo "$as_me: WARNING: OpenSSL version should be 1.0.1g or higher." >&2;}
fi
The breaking difference with yours is that yours lacks the colon after then.
For a more detailed explanation about the colon operator in bash, see What is the purpose of the : (colon) GNU Bash builtin? . The short version, here it acts like some kind of "no-op".

Related

"command not found" when calling function in bash [duplicate]

This question already has answers here:
How to call a function in shell Scripting?
(7 answers)
Bash - writing function definition in script after first call (as a GOTO/jump problematics)
(3 answers)
How can i check if no arguments are given [duplicate]
(1 answer)
Closed 4 years ago.
I am trying to set up a simple script to compile my project that takes the name of the module(s) to compile, or if no arguments, compile them all.
None of the other answers on StackOverflow have worked for me.
When I try the below script I get this error:
$ ./build.sh updater
Creating the build path: build/0.1.4-master
./build.sh: line 21: updater: command not found
I don't like the ambiguity of the language, it could be a function or a command. But it is what it is. How can I make it execute the function and not try to run a command called updater?
#! /bin/sh -e
# release="0.0.0-$(git rev-parse --abbrev-ref HEAD)"
release="$(git describe --tags --abbrev=0)-$(git rev-parse --abbrev-ref HEAD)"
echo "Creating the build path: build/$release"
mkdir -p "build/$release"
while [ "$#" -gt 0 ]; do
param="$1"
case $param in
s|setup)
setup
shift
;;
l|launcher)
launcher
shift
;;
u|updater)
updater
shift
;;
d|deflector)
deflector
shift
;;
# *)
# setup
# launcher
# updater
# deflector
# shift
# ;;
esac
done
function setup {
echo "Compiling executable: build/$release/setup.exe"
ldc2 "source/setup.d" "source/common.d" -of="build/$release/setup.exe" \
-O3 -ffast-math -release -g
echo "Adding icon to executable: build/$release/setup.exe"
[ -e "build/$release/setup.exe" ] && \
rcedit "build/$release/setup.exe" --set-icon "icons/icon.ico"
}
function launcher {
echo "Compiling executable: build/$release/launcher.exe"
ldc2 "source/launcher.d" "source/common.d" -of="build/$release/launcher.exe" \
-O3 -ffast-math -release -g
echo "Adding icon to executable: build/$release/launcher.exe"
[ -e "build/$release/launcher.exe" ] && \
rcedit "build/$release/launcher.exe" --set-icon "icons/icon.ico"
}
function updater {
echo "Compiling executable: build/$release/updater.exe"
ldc2 "source/updater.d" "source/common.d" -of="build/$release/updater.exe" \
-O3 -ffast-math -release -g
}
function deflector {
echo "Compiling executable: build/$release/deflector.exe"
ldc2 "source/deflector.d" "source/common.d" -of="build/$release/deflector.exe" \
-O3 -ffast-math -release -g
}
echo "Removing residual object files."
find "build/$release" -name "*.obj" -delete
echo "Copying engines file: build/$release/engines.txt"
cp "engines.txt" "build/$release"
echo "Copying libcurl library: build/$release/libcurl.dll"
cp $(which libcurl.dll) "build/$release"
I would also like help making a default case for when there are no arguments passed to the script. My attempt can be seen in the commented block in the switch case.
Appreciate any help.
You need to define the functions before they are called from top-level code.
...
updater () { ... }
...
while [ "$#" -gt 0 ]; do
...
done

Go error while cross compiling Kubernetes

I have been trying to cross-compile K8s running ./hack/build-cross.sh. I am getting this error, while building targets for arm64:
Go version: go version go1.6.2 linux/amd64
+++ [0701 13:27:22] Building the toolchain targets:
k8s.io/kubernetes/hack/cmd/teststale
+++ [0701 13:27:22] Building go targets for linux/arm64:
cmd/kube-dns
cmd/kube-proxy
cmd/kube-apiserver
cmd/kube-controller-manager
cmd/kubelet
cmd/kubemark
cmd/hyperkube
federation/cmd/federation-apiserver
federation/cmd/federation-controller-manager
plugin/cmd/kube-scheduler
# runtime/cgo
/usr/local/go/src/runtime/cgo/cgo.go:54:19: fatal error: errno.h: No such file or directory
compilation terminated.
!!! Error in /home/peeyush/work/kubernetes/hack/lib/golang.sh:500
'go install "${goflags[#]:+${goflags[#]}}" -ldflags "${goldflags}" "${nonstatics[#]:+${nonstatics[#]}}"' exited with status 2
Call stack:
1: /home/peeyush/work/kubernetes/hack/lib/golang.sh:500 kube::golang::build_binaries_for_platform(...)
2: /home/peeyush/work/kubernetes/hack/lib/golang.sh:669 kube::golang::build_binaries(...)
3: ./hack/build-cross.sh:28 main(...)
Exiting with status 1
!!! Error in /home/peeyush/work/kubernetes/hack/lib/golang.sh:586
'( kube::golang::setup_env; echo "Go version: $(go version)"; local host_platform; host_platform=$(kube::golang::host_platform); local goflags goldflags; eval "goflags=(${KUBE_GOFLAGS:-})"; goldflags="${KUBE_GOLDFLAGS:-} $(kube::version::ldflags)"; local use_go_build; local -a targets=(); local arg; for arg in "$#";
do
if [[ "${arg}" == "--use_go_build" ]]; then
use_go_build=true;
else
if [[ "${arg}" == -* ]]; then
goflags+=("${arg}");
else
targets+=("${arg}");
fi;
fi;
done; if [[ ${#targets[#]} -eq 0 ]]; then
targets=("${KUBE_ALL_TARGETS[#]}");
fi; local -a platforms=("${KUBE_BUILD_PLATFORMS[#]:+${KUBE_BUILD_PLATFORMS[#]}}"); if [[ ${#platforms[#]} -eq 0 ]]; then
platforms=("${host_platform}");
fi; local binaries; binaries=($(kube::golang::binaries_from_targets "${targets[#]}")); local parallel=false; if [[ ${#platforms[#]} -gt 1 ]]; then
local gigs; gigs=$(kube::golang::get_physmem); if [[ ${gigs} -ge ${KUBE_PARALLEL_BUILD_MEMORY} ]]; then
kube::log::status "Multiple platforms requested and available ${gigs}G >= threshold ${KUBE_PARALLEL_BUILD_MEMORY}G, building platforms in parallel"; parallel=true;
else
kube::log::status "Multiple platforms requested, but available ${gigs}G < threshold ${KUBE_PARALLEL_BUILD_MEMORY}G, building platforms in serial"; parallel=false;
fi;
fi; kube::golang::build_kube_toolchain; if [[ "${parallel}" == "true" ]]; then
kube::log::status "Building go targets for ${platforms[#]} in parallel (output will appear in a burst when complete):" "${targets[#]}"; local platform; for platform in "${platforms[#]}";
do
( kube::golang::set_platform_envs "${platform}"; kube::log::status "${platform}: go build started"; kube::golang::build_binaries_for_platform ${platform} ${use_go_build:-}; kube::log::status "${platform}: go build finished" ) &> "/tmp//${platform//\//_}.build" &
done; local fails=0; for job in $(jobs -p);
do
wait ${job} || let "fails+=1";
done; for platform in "${platforms[#]}";
do
cat "/tmp//${platform//\//_}.build";
done; exit ${fails};
else
for platform in "${platforms[#]}";
do
kube::log::status "Building go targets for ${platform}:" "${targets[#]}"; kube::golang::set_platform_envs "${platform}"; kube::golang::build_binaries_for_platform ${platform} ${use_go_build:-};
done;
fi )' exited with status 1
Call stack:
1: /home/peeyush/work/kubernetes/hack/lib/golang.sh:586 kube::golang::build_binaries(...)
2: ./hack/build-cross.sh:28 main(...)
Exiting with status 1
Any idea what could be causing this error? error.h is there on my system:
find / -name "errno.h"
/usr/arm-none-eabi/include/sys/errno.h
/usr/arm-none-eabi/include/errno.h
/usr/src/kernels/4.1.13-100.fc21.x86_64+debug/include/uapi/asm-generic/errno.h
/usr/src/kernels/4.1.13-100.fc21.x86_64+debug/include/uapi/linux/errno.h
/usr/src/kernels/4.1.13-100.fc21.x86_64+debug/include/linux/errno.h
/usr/src/kernels/4.1.13-100.fc21.x86_64+debug/arch/x86/include/uapi/asm/errno.h
/usr/include/asm/errno.h
/usr/include/sys/errno.h
/usr/include/bits/errno.h
/usr/include/errno.h
/usr/include/asm-generic/errno.h
/usr/include/linux/errno.h
Not sure what exactly is the issue, can anyone please help me with it?
I am using following arm packages:
rpm -aq | grep arm
arm-none-eabi-gcc-cs-c++-5.2.0-2.fc21.x86_64
gcc-arm-linux-gnu-4.9.2-5.fc21.x86_64
arm-none-eabi-newlib-2.2.0_1-6.fc21.noarch
binutils-arm-linux-gnu-2.25-4.fc21.x86_64
arm-none-eabi-binutils-cs-2014.05.28-3.fc21.x86_64
gucharmap-3.14.2-1.fc21.x86_64
arm-none-eabi-gcc-cs-5.2.0-2.fc21.x86_64
hdparm-9.48-1.fc21.x86_64
TIA.

Is conditional statement in Makefile valid syntax

I have the following Makefile
~/w/i/craft-api git:develop ❯❯❯ cat Makefile ⏎ ✱ ◼
test:
echo "TODO: write tests"
generate-toc:
if ! [ -x "$(command -v doctoc)" ]; then
echo "Missing doctoc. Run 'npm install doctoc -g' first"
else
doctoc ./README.md
fi
I'm encountering this error
~/w/i/craft-api git:develop ❯❯❯ make generate-toc ✱ ◼
if ! [ -x "" ]; then
/bin/sh: -c: line 1: syntax error: unexpected end of file
make: *** [generate-toc] Error 2
What is incorrect in my Makefile syntax / usage?
edit 1
Adding line-continuing backslashes doesn't appear to fix the issue:
~/w/i/craft-api git:develop ❯❯❯ cat Makefile ⏎ ✱ ◼
test:
echo "TODO: write tests"
generate-toc:
if ! [ -x "$(command -v doctoc)" ]; then \
echo "Missing doctoc. Run 'npm install doctoc -g' first" \
else \
doctoc ./README.md \
fi
~/w/i/craft-api git:develop ❯❯❯ make generate-toc ✱ ◼
if ! [ -x "" ]; then \
echo "Missing doctoc. Run 'npm install doctoc -g' first" \
else \
doctoc ./README.md \
fi
/bin/sh: -c: line 1: syntax error: unexpected end of file
make: *** [generate-toc] Error 2
Every line is treated as a separate command and is passed to a different shell instance. You can use \ continuations to combine all of the lines so make knows to pass them as one long string to a single shell. This removes the newlines so you also need to add ; at the end of each command.
if ! [ -x "$$(command -v doctoc)" ]; then \
echo "Missing doctoc. Run 'npm install doctoc -g' first"; \
else \
doctoc ./README.md; \
fi
You'll also want to escape the $, otherwise make will interpret it rather than the shell.

error sh: 0: not found while converting bash function to sh

The function below was originally a bash function. I need it to run in busybox 1.22 ash shell.
dockerip() {
if (( $# != 1 ))
then
for d in $(docker ps -q)
do
name=$(docker inspect -f {{.Name}} $d)
ip=$(docker inspect -f {{.NetworkSettings.IPAddress}} $d)
printf "%-15s | %15s\n" $name $ip
done
fi
}
When the code above is loaded with source and run as dockerip the busybox shell outputs: sh: 0: not found. Not a very helpful error so my question is what does the error mean and what part(s) of the function above aren't busybox 1.22 compatible?
This arithmetic expression (( $# != 1 )) is bash syntax. In ash, it's launching 2 nested subshells, then executing the program "$#" with arguments "!=" and "1".
Use this instead
if [ $# -ne 1 ]

How to check if gcc has failed, returned a warning, or succeeded in Bash?

How would I go about checking whether gcc has succeeded in compiling a program, failed, or succeeded but with a warning?
#!/bin/sh
string=$(gcc helloworld.c -o helloworld)
if [ string -n ]; then
echo "Failure"
else
echo "Success!"
fi
This only checks whether it has succeeded or (failed or compiled with warnings).
-n means "is not null".
Thanks!
EDIT If it's not clear, this isn't working.
Your condition should be:
if [ $? -ne 0 ]
GCC will return zero on success, or something else on failure. That line says "if the last command returned something other than zero."
if gcc helloworld.c -o helloworld; then
echo "Success!";
else
echo "Failure";
fi
You want bash to test the return code, not the output. Your code captures stdout, but ignores the value returned by GCC (ie the value returned by main()).
To tell the difference between compiling completely cleanly and compiling with errors, first compile normally and test $?. If non-zero, compiling failed. Next, compile with the -Werror (warnings are treated as errors) option. Test $? - if 0, it compiled without warnings. If non-zero, it compiled with warnings.
Ex:
gcc -Wall -o foo foo.c
if [ $? -ne 0 ]
then
echo "Compile failed!"
exit 1
fi
gcc -Wall -Werror -o foo foo.c
if [ $? -ne 0 ]
then
echo "Compile succeeded, but with warnings"
exit 2
else
echo "Compile succeeded without warnings"
fi

Resources