Error Packaging a Shell script with Autotools - sh

I'm trying to write a simple Autotool package that just packages a single script. This might seem like overkill, but the script is to be added into the build-system for an embedded system and the build-system is designed to play nicely with Autotools.
I have a shell-script called wifi_query.sh. To package this I've followed the following steps:
Created Makefile.am which contains the following -
bin_SCRIPTS = wifi_query.sh
CLEANFILES = $(bin_SCRIPTS)
I also created wifi_query.sh.in which contains the line exec wifi_query.sh. I'm not sure I understand the purpose of the .in file.
I then run autoscan.
Then I run:
sed -e 's/FULL-PACKAGE-NAME/wifi_query/' \
-e 's/VERSION/1/' \
-e 's|BUG-REPORT-ADDRESS|/dev/null|' \
-e '10i\
AM_INIT_AUTOMAKE' \
< configure.scan > configure.ac
Run touch NEWS README AUTHORS ChangeLog.
Run autoreconf -iv
./configure
make distcheck
When I run make distcheck I get an error saying: "* No rule to make target 'wifi_query.sh', needed by 'all-am'. Stop.".
I don't understand this error, if anyone could give me any pointers that would be good. My suspicion is that the error may be due to wifi_query.sh.in, but I have very limited autotools experience.

It seems I needed to replace the line bin_SCRIPTS = wifi_query.sh with dist_bin_SCRIPTS = wifi_query.sh in Makefile.am. Having done that everything seems to work.

Related

Trying to pass too many includes to QA-C fail

I have a problem to add a source file to my QAC configuration. After many tries, I found out that the problem is with too many includes defined as an argument while calling QAC. If I will reduce the number of includes the QAC configuration will pass.
I tried this over the makefile:
#for f in $(filter-out $(QAC_EXCLUDE_FILES),$(QAC_SRC)); do \
echo " - $$f" 1>&2; \
$(QAC) admin -P $(QAC_DIR) -a -- $(QAC_DEF) $(QAC_D_PROJ) $(QAC_INC) $$f >/dev/null; \
done
I also tried to run a single command to add just one file in Command Prompt:
D:/Tools/PRQA_Framework_2.4.0/common/bin/qacli.exe admin -P D:/Output/qac -a -- -Itoo -Imany -Iincludes D:/Src/import.c
I'm pretty sure that the whole command line is not exceeding the limit 8191 characters (it is something about 5500 characters).
I'm using our common company QAC configuration like many of my colleagues without any problem. In the last few days I just add some new includes.
The result is always the same:
Calling from makefile: /usr/bin/sh: -c: line 3: syntax error:
unexpected end of file
Calling from CMD: CreateProcess error=3, the system cannot find
the path specified
But again, if I will just reduce the includes, everything goes nice and smooth.
Also, I would not say it is a problem of CMD because I'm using the same list of includes for my build process without any problem! It is only a problem for QAC.
My setup is Windows 10, MSYS2 tools.
At the and I contact the QAC support and better way how to provide all information to QAC is to generate list file (one line = line source file) with all defines and includes. This way is also much quicker than passing source files one by one.
So the file list qac_sources.txt (generated by makefile) may look like this:
D:/Project/a1.c -D__far_func= -IToo -Imany -Iincludes
D:/Project/a2.c -D__far_func= -IToo -Imany -Iincludes
D:/Project/a3.c -D__far_func= -IToo -Imany -Iincludes
D:/Project/a4.c -D__far_func= -IToo -Imany -Iincludes
And:
D:/Tools/qacli.exe admin -P D:/Project/Output/qac -F D:/Project/Output/qac/qac_sources.txt
Hope this will help somebody.

scons: how to define command/target that only takes place during 'scons -c'?

Before building the targets I wish to create some directory structures, I know I can use:
env = Environment()
env.Execute('mkdir -p xxx')
But this will cause "mkdir -p' to be executed even when I do clean up:
scons -c
And the "env.Execute" will gets called.
I wish there's some command or target that's only taking place when I execute 'scons -c'
How to achieve that?
Thanks.
The -c option is a built in scons option and you can check if it was set with GetOption('clean').
You could then call the commands conditionally based off the value of the 'clean' option. Here is an example:
env = Environment()
if not GetOption('clean'):
env.Execute('mkdir -p xxx')
else:
env.Execute('echo "Cleaning up..."')
More info on the other built in options can be found here:
https://scons.org/doc/production/HTML/scons-user.html#sect-command-line-option-strings
https://scons.org/doc/production/HTML/scons-man.html#options

tcsh autocompletion for modulefiles

I found this piece of code, which does auto-completion for module files in tcsh at
https://opensource.apple.com/source/tcsh/tcsh-66/tcsh/complete.tcsh.
Could somebody help me understand how the 'alias Compl_module' works?
#from Dan Nicolaescu <dann#ics.uci.edu>
if ( $?MODULESHOME ) then
alias Compl_module 'find ${MODULEPATH:as/:/ /} -name .version -o -name .modulea\* -prune -o -print | sed `echo "-e s#${MODULEPATH:as%:%/\*##g -e s#%}/\*##g"`'
complete module 'p%1%(add load unload switch display avail use unuse update purge list clear help initadd initrm initswitch initlist initclear)%' \
'n%{unl*,sw*,inits*}%`echo "$LOADEDMODULES:as/:/ /"`%' \
'n%{lo*,di*,he*,inita*,initr*}%`eval Compl_module`%' \
'N%{sw*,initsw*}%`eval Compl_module`%' 'C%-%(-append)%' 'n%{use,unu*,av*}%d%' 'n%-append%d%' \
'C%[^-]*%`eval Compl_module`%'
endif
Thanks a lot.
Not sure this Compl_module alias is performing well as it tries to determine all existing modulefiles in modulepaths by just looking at existing files. Modulefiles can also be aliases, symbolic versions and virtual (in newer Modules versions >=4.1), so the Compl_module alias will miss that.
You will find a full completion script for the module command in the source repository of the Modules project.
This completion script calls module avail to correctly get all existing modulefiles in enabled modulepaths.
TCSH completion script is automatically enabled starting Modules version 4.0.

Ctools do not show up in pentaho UI

I am using Pentaho CE 5 on windows. I would like to use CTools but I can't make them show up in the File -> New menu to use them.
Being behind a proxy, I can not use the Marketplace plugin, so I have tried a manual installation.
First, I tried to use the ctools-installer.sh. I have run the following command line in cygwin (wget and unzip are installed):
./ctools-installer.sh -s /cygdrive/d/Users/[user]/Mes\ Programmes/pentaho/biserver-ce/pentaho-solutions/ -w /cygdrive/d/Users/[user]/Mes\ programmes/pentaho/biserver-ce/tomcat/webapps/pentaho/
The script starts, asks me what module I want to install, and begins the downloads.
For each module, I get an output like (set -x added to the script) :
echo -n 'Downloading CDF...' Downloading CDF...+ wget -q --no-check-certificate 'http://ci.analytical-labs.com/job/Webdetails-CDF-5-Release/lastSuccessfulBuild/artifact/bi-platform-v2-plugin/dist/zip/dist.zip'
-O .tmp/cdf/dist.zip SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc syswgetrc = C:\Program Files (x86)\GnuWin32/etc/wgetrc
'[' '!' -z '' ']'
rm -f .tmp/dist/marketplace.xml
unzip -o .tmp/cdf/dist.zip -d .tmp End-of-central-directory signature not found. Either this file is not a zipfile, or it
constitutes one disk of a multi-part archive. In the latter case
the central directory and zipfile comment will be found on the last
disk(s) of this archive. unzip: cannot find zipfile directory in
.tmp/cdf/dist.zip,
and cannot find .tmp/cdf/dist.zip.zip, period.
chmod -R u+rwx .tmp
echo Done Done
Then the script ends. I have seen on this page (pentaho-bi-suite) that it is the normal output. Nevertheless, it seems a bit strange to me and when I start my pentaho server (login: admin/password), I cannot see any new tools in the menus.
After a look to a few other tutorials and the script itself, I have downloaded the .zip snapshots for every tool and unzipped them in the system directory of my pentaho server. Same result.
I would like to make the .sh works, what can I try or adjust ?
Thanks
EDIT 05/06/2014
I checked the dist.zip files dowloaded by the script and they are all empty. It seems that wget cannot fetch the zip files, and therefore the installation fails.
When I try to get any webpage through wget, it fails. I think it is because of the proxy.
Here is my .wgetrc file, located in my user's cygwin home folder:
use_proxy=on
http_proxy=http://[url]:[port]
https_proxy=http://[url]:[port]
proxy_user=[user]
proxy_password=[password]
How could I make this work?
EDIT 10/06/2014
In the end, I have changed my network connection settings to bypass the proxy. It seems that there is an offline mode for the installer, so one can download all needed files on a proxy-free environment and then run the script offline.
I guess this is related with the -r option.
I consider this post solved, since it not a CTools issue anymore.
Difficult to identify the issue in the above procedure..
but you can refer this blog he is key member of pentaho itself..
In the end, I have changed my network connection settings to bypass the proxy. It seems that there is an offline mode for the installer, so one can download all needed files on a proxy-free environment and then run the script offline. I guess this is related with the -r option.
I consider this post solved, since it is not a CTools issue anymore.
You can manually install the components from http://www.webdetails.pt/ctools/ or if you have pentaho 5.1 or above, you add the following parameters to CATALINA_OPTS option (in start-pentaho.bat or start-pentaho.sh):
-Dhttp.proxyHost= -Dhttp.proxyPort= -Dhttp.nonProxyHosts="localhost|127.0.0.1|10...*"
http://docs.treasuredata.com/articles/pentaho-dataintegration#tips-how-can-i-use-pentaho-through-a-proxy

How to use Devel::Cover with prove?

I see there are some similar questions here and on http://www.perlmonks.org but I still do not get it.
Imagine I have a project with a 'lib/' and a 't' directories. I run my tests with 'prove':
$ cd $PROJECT_ROOT
$ prove ./*.t
I want to get a report in html for one or more files in the 'lib/' directory. I do not want reports for the files in the 't' directory.
A simple example should be enough. Thanks
perl Makefile.PL or perl Build.PL
cover -test
The proper way is to always start out with Makefile.PL/Build.PL, just as selected answer suggests. However, sometimes you are not the one who started out, so...
I used to make a fake makefile:
% cat Makefile
test:
prove -Ilib -r t
The following also seems to work (w/o touching ANY files on disk):
cover -t -make 'prove -Ilib -r t; exit $?'
This only works because of how perl's system/exec handle an argument with shell metacharacters in it (; in this case) and may break in the future if cover decides to quote it more rigirously. Also it shouldn't work under windows. I wish cover had a -prove option instead.
This one still generates coverage for *.t as well as CPAN modules at nonstandard locations. This behaviour can be fixed using +select/+ignore options (see the Devel::Cover's manpage):
cover -t +select ^lib +ignore ^
So the tl;dr "magic" command is
cover -t +select ^lib +ignore ^ -make 'prove -Ilib -r t; exit $?'
EDIT The following didn't work for me - it only prints short summary:
PERL5OPT="$PERL5OPT -MDevel::Cover" prove -Ilib -r t
cover -t +select ^lib +ignore ^
Note that prove -MSomething applies Something to prove itself and doesn't pass it on (unlike with -I).
Make prove run every test file with Devel::Cover activated:
$ prove --exec 'perl -MDevel::Cover=-silent,1 -Ilib' t/*.t
By default this will print the statistics after each test file. That’s why I added -silent => 1.
To print the complete statistics at the end add:
$ cover -summary