Can't protoc with relative paths from a script - protoc

Been wrestling with this for a while. I have a protoc command that runs fine in terminal, but fails in a script. The issue seems to be with the recursive protos.
The folder structure is:
ledger-models % ls
Cargo.lock README.md gen.rs ledger-models-protos target
Cargo.toml compile.sh ledger-models-java ledger-models-rust
in ledger-models-protos there are several folders with protos:
ledger-models-protos % ls
models requests services
In the root directory I can sucessfully run the protoc command interactively:
ledger-models % protoc --java_out=ledger-models-java/generated-src --proto_path=ledger-models-protos **/*.proto
However when I run the same line in the script it fails:
echo "generating java protos"
rm -rf ledger-models-java/generated-src
mkdir ledger-models-java/generated-src
protoc --java_out=ledger-models-java/generated-src --proto_path=ledger-models-protos **/*.proto
ledger-models % ./compile.sh
working directory
/Users/davidjdoherty/Dev/ledger-models
generating java protos
Could not make proto path relative: **/*.proto: No such file or directory
I am stumped as to why I'm getting the error **Could not make proto path relative: /*.proto: No such file or directory.
This is an open source project so the code is: https://github.com/FinTekkers/ledger-models/blob/main/compile.sh

Related

Output A tar archive into a specific path in a bash script

I have a part in my script that uses tar to archive some folders. It should output the archived result to a specified folder.
The following tar command outputs the file to the right folder but makes the resulted archive nested with the full path leading to it.
e.g.
Inside my tar file I have the following folders:
full/path/to/file
The folder structure shouldn't look like that it should be relative to the parent folder not the root folder.
Here is the code:
...
local PROJECTS=(~/path/to/folder/*)
...
local PROJECT_PATH="${PROJECTS[$i]}"
local BACKUP_NAME=`date +%d%b%y`.tar.gz
echo Making folder "${PROJECT_PATH}"/backups
tar -czvf $PROJECT_PATH/backups/$BACKUP_NAME $PROJECT_PATH --exclude="${PROJECT_PATH}"/node_modules --exclude="${PROJECT_PATH}"/backups
If you want tar to save paths relative to some directory, use -C to change to that directory and provide relative paths:
tar -czvf "$PROJECT_PATH/backups/$BACKUP_NAME" -C "$PROJECT_PATH" . --exclude=./node_modules --exclude=./backups
-C "$PROJECT_PATH" tells tar to change to the $PROJECT_PATH directory, and the following . tells it to archive its current directory.

qmake generated target_wrapper.sh fails on make check

I have a qmake project with a subdirs template and two child projects.
The subdir projects are two testcases. The project is built with on mingw64.
When I run "mingw32-make check", the process fails when the first testcase is called by the target_wrapper.sh:
cd && /C/JENKINS/workspace/MyProject/tests/test1/target_wrapper.sh release/test1.exe
/C/JENKINS/workspace/MyProject/tests/test1/target_wrapper.sh: Zeile 6: /home/jenluelokal/release/test1.exe: No such file or directory
mingw32-make[2]: *** [Makefile.Release:82: check] Error 127
The Makefile.Release calls the following line for the check target:
check: first
cd && /C/JENKINS/workspace/MyProject/tests/test1/target_wrapper.sh $(TESTRUNNER) release/$(TARGET) $(TESTARGS)
By request the target_wrapper.sh:
#!/bin/sh
PATH=/C/Qt/Qt5.9.2/5.9/mingw64/bin:$PATH
export PATH
QT_PLUGIN_PATH=/C/Qt/Qt5.9.2/5.9/mingw64/share/qt5/plugins${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}
export QT_PLUGIN_PATH
exec "$#"
The first cd changes into the homedir of the current user and calls target_wrapper.sh. The target_wrapper.sh script tries to execute the
test1 binary - which is not inside the home directory.
What am I doing wrong?
DESTDIR needs be set, so the make check target knows where to look for the test executables. The "cd" changes into this directory before trying to run the target_wrapper.sh.

Cygwin program compiled but not runnable

I just installed CD-HIT and followed these instructions:
Installation
Most CD-HIT programs were written in C++. Installing CD-HIT package is very simple:
download current CD-HIT at http://bioinformatics.org/cd-hit, for example cd-hit-2006-0215.tar.gz
unpack the file with ” tar xvf cd-hit-2006-0215.tar.gz --gunzip”
change dir by “cd cd-hit-2006”
compile the programs by “make”
you will have all cd-hit programs compiled
I followed these steps and indeed .exe files were made:
cdhit.c++ cdhit-est-2d.c++ clstr_select_rep.pl
cd-hit.exe cd-hit-est-2d.exe clstr_size_histogram.pl
cdhit.o cdhit-est-2d.o clstr_size_stat.pl
cdhit-2d.c++ cd-hit-para.pl clstr_sort_by.pl
cd-hit-2d.exe cdhit-utility.c++ clstr_sort_prot_by.pl
cdhit-2d.o cdhit-utility.h clstr_sql_tbl.pl
cd-hit-2d-para.pl cdhit-utility.o clstr_sql_tbl_sort.pl
cdhit-454.c++ ChangeLog clstr2tree.pl
cd-hit-454.exe clstr_cut.pl clstr2txt.pl
cdhit-454.o clstr_list.pl clstr2xml.pl
cd-hit-auxtools clstr_list_sort.pl doc
cdhit-common.c++ clstr_merge.pl FET.pl
cdhit-common.h clstr_merge_noorder.pl license.txt
cdhit-common.o clstr_quality_eval.pl make_multi_seq.pl
cdhit-div.c++ clstr_quality_eval_by_link.pl Makefile
cd-hit-div.exe clstr_reduce.pl plot_2d.pl
cdhit-div.o clstr_renumber.pl plot_len1.pl
cd-hit-div.pl clstr_rep.pl psi-cd-hit
cdhit-est.c++ clstr_reps_faa_rev.pl README
cd-hit-est.exe clstr_rev.pl usecases
cdhit-est.o clstr_select.pl
However when I typ: cd-hit-est in the cygwin command line, it will say: -bash: cd-hit.exe: command not found. I'm not able to figure out why this is happening. Even when I'm in the folder were the .exe files are located it still will give the same error.
When you try to run command without a path, bash tries to find the command name in each directory from the PATH environment variable.
Usually current directory "." is not in the PATH so you have to run command adding absolute or relative path before command name:
./cd-hit.exe
or
/absolute/path/to/your/cd-hit/program/cd-hit.exe
If you want to permanently run command cd-hit.exe from anywhere, just add the directory where cd-hit was compiled to any existing auto-loaded bash profile files:
.profile
.bashrc
.bash_profile
like
PATH=$PATH:/absolute/path/to/your/cd-hit/program
export PATH

Install entire folder and files in it, RPM spec file

I have a spec file to build an rpm package, in my %install section I have this:
%install
install -m 700 foo/bar/filesToCopy/. $RPM_BUILD_ROOT/
The filesToCopy folder is a tree exactly how the package file tree should look like. It has all the sub directories a package has such as etc/..., /usr/bin, /usr/share ..., and subsquent files in those.
When building it gives me
install: omitting directory 'foo/bar/filesToCopy/'
error: Bad exit status from /var/tmp/rpm-tmp.sea6XO (%install)
Is there a way I dont have to copy each file individuallly like this:
install -m 700 foo/bar/filesToCopy/usr/bin/file1.ex $RPM_BUILD_ROOT/usr/bin/
...
As everything in filesToCopy/ is the structure as in $RPM_BUILD_ROOT/
UPDATE
I found a solution, I changed the "install -m 700" to a "cp -a"

Run a command with relative path from symlink directory

I've got a directory structure like this:
bin
drush
build -> vendor/drupal/core
vendor
drupal
core
So as you see, build is a symlink to the core directory.
drush is an executable file. I need to be able to cd into build and call drush from there.
But if I do this:
cd build
../bin/drush
This doesn't work, because .. points to vendor/drupal directory, because when I cd into build, it in fact goes to vendor/drupal/core, of course.
I know I can call it this way: ../../../bin/drush, but is there some kind of workaround to make .. point to the root, not the actual parent?
You can create an another symlink in the folder "drupal" on the executable drush. So with this way, you can call it from "build".
$ cd vendor/drupal/
$ ln -s absolute_path/bin/drush dummy-drush
$ cd build
$ ./dummy-drush
Solution 1 :
If you don't want to create anything in vendor, maybe it's better to create an alias which allows to you to execute drush (be careful to give the good path).
Solution 2 :
If the directory bin in your example is not the folder "/bin" from the root, you can add it in your PATH in order to execute every executable .
$ export PATH=$PATH:/personal_bin/
$ cd bin
$ ln -s drush dummy-drush

Resources