extraneous end if in .dep.inc file - jenkins

I am giving a job to Jenkins to build binaries for my code through make file . It is showing error of extraneous end if in .dep.inc file,I tried to change the configuration of net beans.
This file is getting generated from auto generated make file in net beans. In net beans it is compiling but in Jenkins it is showing error.*
# dependency checking support
.depcheck-impl:
#echo "# This code depends on make tool being used" >.dep.inc
#if [ -n "${MAKE_VERSION}" ]; then \
echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \
echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
echo "include \$${DEPFILES}" >>.dep.inc; \
echo "endif" >>.dep.inc; \
else \
echo ".KEEP_STATE:" >>.dep.inc; \
echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
fi

you are using BASH syntax instead of Makefile. One option could be to use the conditional structure of Makefile:
Conditional Parts of Makefiles
Another way is to define the whole BASH instruction in the same line, like that:
if [ <condition>]; then <action1>; else <action2>; fi
In Makefile, each line of a target could be a SHELL, but you should not split them.
Finally, you can use the "define" environment to insert BASH code:
define <name>=
<BASH code>
<...>
<name>: ; #$(value <name>)
.ONESHELL
I hope you find it useful!

Related

Tool for edit lvm.conf file

is there any lvm.conf editor?
I'm trying to set global_filter, use_lvmtad and some other options, currently using sed:
sed -i /etc/lvm/lvm.conf \
-e "s/use_lvmetad = 1/use_lvmetad = 0/" \
-e "/^ *[^#] *global_filter/d" \
-e "/^devices {/a\ global_filter = [ \"r|/dev/drbd.*|\", \"r|/dev/dm-.*|\", \"r|/dev/zd.*|\" ]"
but I don't like this too much, is there any better way?
I found only lvmconfig tool, but it can only display certain configuration sections, and can't edit them.
If you using Ubuntu variant then you can use the LVM GUI to configure and manage the LVM. Refer this link
It seems that augtool is exactly what I was looking for.
These two packages should be enough to proper processing lvm.conf file:
apt install augeas-tools augeas-lenses
Example usage:
augtool print /files/etc/lvm/lvm.conf
And you should get the whole parse tree on stdout.
If the parser fails you won’t get any output, print the error message using:
augtool print /files/etc/lvm/lvm.conf/error
The augtool equivalent for the sed command from the original question:
augtool -s <<EOT
set /files/etc/lvm/lvm.conf/global/dict/use_lvmetad/int "0"
rm /files/etc/lvm/lvm.conf/devices/dict/global_filter
set /files/etc/lvm/lvm.conf/devices/dict/global_filter/list/0/str "r|^/dev/drbd.*|"
set /files/etc/lvm/lvm.conf/devices/dict/global_filter/list/1/str "r|/dev/dm-.*|"
set /files/etc/lvm/lvm.conf/devices/dict/global_filter/list/2/str "r|/dev/zd.*|"
EOT

Override scripts in nix derivations

Is there a way to override scripts and/or configs in an existing derivation without having to recompile the whole package?
I'd like to create a new version of gnome-session with modified $out/share/gnome-session/sessions/gnome.session modified. Using overridePackage I can change the preFixup phase, but this causes the whole gnome-session package to be recompiled.
A simple solution to problem is creating a new derivation without any sources. The trick is to create links to every file and directory in the base derivation, except for any file(s) in need of modification. These files are handled explicitly according to needs.
The snippet below shows how to create a new gnome-session with xmonad instead of gnome-shell.
{ nixpkgs ? import <nixpkgs> {} }:
let
inherit (nixpkgs) pkgs;
in
pkgs.stdenv.mkDerivation {
name = "gnome-session";
builder = pkgs.writeText "builder.sh" ''
# source standard environment
. $stdenv/setup
# shorthands
refpkg=${pkgs.gnome3.gnome_session}
file=share/gnome-session/sessions/gnome.session
# create output dirs for new derivation
mkdir -p $out/share
mkdir -p $out/share/gnome-session/sessions
# link unchanged files from the original gnome-session
ln -sf $refpkg/bin $out
ln -sf $refpkg/libexec $out
find $refpkg/share -maxdepth 1 \
-not -name gnome-session -exec ln -sf {} $out/share \;
# change gnome-shell to xmonad
sed 's/org.gnome.Shell/xmonad/' $refpkg/$file > $out/$file
'';
# make sure gnome-session is installed before deriving it!
buildInputs = [ pkgs.gnome3.gnome_session ];
}

ROS how to find all executables of a package?

I want to ask how to find all the executable names of a package in ROS (Robot Operating System)? For example, find spawn_model in gazebo_ros package. When I inspect the package in my system, it just shows some .xml, .cmake files, without any executables. But I can run it, such as: rosrun gazebo_ros spawn_model.
Thank you!
An easy way to do this is to type: "rosrun name_of_package " and then press tab two times, it should show you all the executables built.
After looking in the bash autocompletion script for rosrun, it looks like the command catkin_find is used to find the location of the executables for a package, and the executables are filtered with a find command.
If you want to create a script to give you a list of the executables follow the instructions below:
Save the following script in a file called rospack-list-executables:
#!/bin/bash
if [[ $# -lt 1 ]]; then
echo "usage: $(basename $0) <pkg_name>"
echo ""
echo " To get a list of all package names use the command"
echo " 'rospack list-names'"
exit
fi
pkgname=${1}
pkgdir="$(catkin_find --first-only --without-underlays --libexec ${pkgname})"
if [[ -n "${pkgdir}" ]]; then
find -L "${pkgdir}" -executable -type f ! -regex ".*/[.].*" ! -regex ".*${pkgdir}\/build\/.*" -print0 | tr '\000' '\n' | sed -e "s/.*\/\(.*\)/\1/g" | sort
else
echo "Cannot find executables for package '${pkgname}'." >&2
exit 1
fi
Then make the rospack-list-executables script executable (chmod +x rospack-list-executables) and place it in a directory that can be found in your $PATH environment variable.
Run the script:
$ rospack-list-executables gazebo_ros
debug
gazebo
gdbrun
gzclient
gzserver
libcommon.sh
perf
spawn_model
You should get the same result that you get when you type the rosrun <pkgname> command and press Tab:
$ rosrun gazebo_ros
debug gazebo gdbrun gzclient gzserver libcommon.sh perf spawn_model
You can check the executables for all packages with the following bash code:
rospack list-names | while read pkgname; do
echo "Executables for package '${pkgname}':";
rospack-list-executables $pkgname; echo "";
done
To enable package autocompletion for your newly created command, type the following:
complete -F _roscomplete rospack-list-executables
If you do not want to have to type the complete command every time you login, you can append it to your .bashrc file:
echo "complete -F _roscomplete rospack-list-executables" >> ~/.bashrc
Now when you type the command rospack-list-executables and press the Tab key, you should get a list of all the available packages to choose from.
catkin_find --first-only --without-underlays --libexec <your package name>)
should give you the folder where the executables are

clang: Remove comments in preprocessed files?

is there a way to tell clang to remove comment lines when generating preprocessed output?
Apparently, this is a difference between gcc and clang, and I have not found an option to do so
Thanks
Alex
To be more precise: It seems that I have an issue with input from file, please see this sample:
CONTENT="// \$REMOVE BEFORE FLIGHT\$\r\nprintf(\"HelloWorld!\");"
echo "Original:\n$CONTENT"
echo "-------------------------"
echo "From stdin"
echo $CONTENT | cpp -P -E -nostdinc -xc++ -
echo "-------------------------"
echo "From file"
echo $CONTENT > foo.sample
cpp -P -E -nostdinc -xc++ foo.sample
echo "\n What gives?"
Addition: It appears, that the -x Argument is changed. Using -v, I can see that on the command line, actually -x c++ is passed, whereas when using a file as input, it is changed to -x c.
Any idea why?

Show and execute

In this makefile
dirs = $(shell ls)
clean:
$(foreach dir,$(dirs),echo $(dir);)
The output is
$ make clean
echo bin; echo install.sh; echo Makefile; echo README.md; echo utils;
bin
install.sh
Makefile
README.md
utils
Why does it first show the command, then execute it?
How I can omit the first line?
Prepend the command with the # character. Example:
dirs = $(shell ls)
clean:
#$(foreach dir,$(dirs),echo $(dir);)
From the manual (5.2 Recipe Echoing, bold emphasis mine):
Normally make prints each line of the recipe before it is executed. We call this echoing because it gives the appearance that you are typing the lines yourself.
When a line starts with #, the echoing of that line is suppressed. The # is discarded before the line is passed to the shell. [...]
Alternatively:
The -s or --silent flag to make prevents all echoing, as if all recipes started with #.

Resources