I am trying to get a .tar.gz file name from a new generated folder (one step above).
I tried to use wildcard , but with no luck,
In my makefile, I tried:
...
...
...
other parts
...
deb:
python setup.py sdist --- this step will generate a new folder called dist
cd dist; ls -l --- from here, I see the file is shown.
echo $(wildcard dist/*.tar.gz) (also tried dist/pylink*.tar.gz, dist/*.gz) --fails!
I run it with make -f makefile deb.
I always got nothing from wildcard
But if I leave the folder generated by python, and rerun the file above, I can see the file name is written to the console. Anyone knows why? How should I do to get the file name? I need to use the filename and extend the filename to another one.
many many thanks!
You don't say so explicitly but I assume that, because you're using $(wildcard ...), the lines you provide are part of a GNU make makefile rule. It's best to provide a working example, when asking for help, not just a small bit of one.
The problem you're having is that make expands ALL variables and functions in ALL lines of the recipe, before it starts the first line of the recipe. So even though the $(wildcard ...) doesn't appear until the third line of the recipe, it's expanded before the first line is run. When the $(wildcard ...) function runs, those files don't yet exist so it expands to nothing.
Why don't you just use the shell globbing, since you're in a shell anyway?
python setup.py sdist
cd dist; ls -l
echo dist/*.tar.gz
Related
I've been trying to use fpm to create an rpm, but have ran into a problem. After I install the package, there are files I no longer need which are deleted in a post-install script in order to save space. Unfortunately, when the packages in uninstalled, it complains about the files not being there, as they are still registered by the rpm as part of the package. When I looked into how to fix this via the rpm, I stumbled on the %config(missingok) macro which seems ideal. However, it doesn't seem like there is a way to set this via fpm.
My current options for possible solutions are changing the -edit flag from using vi to edit the spec file to using a script by setting the fpm_editor variable, or touching the file in a pre-remove script to try and trick the rpm into thinking these problematic file still exist. Neither of these option are very appealing.
So my question is this: Is there a way to use fpm to either a: remove the package from the "sight" of the rpm post-install, or b: mark the file as noconfig(missingok) via fpm?
Without utilizing the two solutions above of course.
The usual way of doing this is rm -f these files at the end of the %install section, instead of doing this in the post-install scriptlet.
This way the useless files will not be packaged in the final rpm.
I never packaged an rpm with fpm, but looking at the source code I see the command-line switches --exclude and --exclude-file that should be the ones you're looking for:
option ["-x", "--exclude"], "EXCLUDE_PATTERN",
"Exclude paths matching pattern (shell wildcard globs valid here). " \
"If you have multiple file patterns to exclude, specify this flag " \
"multiple times.", :attribute_name => :excludes do |val|
excludes << val
next excludes
end # -x / --exclude
option "--exclude-file", "EXCLUDE_PATH",
"The path to a file containing a newline-sparated list of "\
"patterns to exclude from input."
Right now I have a makefile that build the .tex file (latex) in the same directory as it and spits out a pdf version of that file and also a bunch of baggage with it. I was wondering how to specify in the make file where to send the result. I want to send the results to my desktop directory. Is this at all possible? Also I used the clean function to get rid of the auto-generated garbage files but it still spits them out. any help on that?
PDFLATEX=/usr/texbin/pdflatex
SOURCE=report_Template.tex
RESULT=report_Template.pdf
$(RESULT): $(SOURCE)
$(PDFLATEX) $(SOURCE)
$(PDFLATEX) $(SOURCE)
clean:
rm -f $(RESULT) *.aux *.log *.toc *.out *~
This isn't something make has anything to do with. The commands you run put their output where you tell them to.
It appears that pdflatex creates the output next to the input so in whatever directory you run it (and the makefile) from.
You can add a cp to the end of that rule to copy the file wherever you want and/or see if pdflatex has an argument that can be given for output filename.
That being said if your make target rule doesn't create the target filename exactly that's a poor rule and might cause you trouble in larger make setups. (This is what .PHONY rules are for in part.)
clean is not magic. It is simply a target like any other. You need to run it for it to do anything.
I am building a source file with some alias to executable files (these are working just fine) and assigning directories to variables in order to get to the directory quicker, with less typing. For example, if I source example.source:
#!/usr/bin/bash
mydir="/path/to/some/dir"
I can get to /path/to/some/dir with
cd $mydir
However, I am not being able to use tab complete to navigate through other sub-directories like I would do by typing the complete path. I mean, if I use the tab key to complete the variable I get cd $mydir but not cd $mydir/ (I have to delete the last space character and manually type the slash / to see the next sub-directories). Hope this is an understandable question. Is there any workaround for this?
EDIT: the linux distribution I'm using is Slackware Linux 3.2.31.c x86_64 GenuineIntel GNU/Linux
EDIT2: GNU bash, version 4.2.37(2)-release
Apparently this feature is starting to be implemented in bash 4.3, release 26-Feb-2014 09:25.
Reading the NEWS file in bash 4.3 I found this:
i. The word completion code checks whether or not a filename
containing a
shell variable expands to a directory name and appends `/' to the word
as appropriate. The same code expands shell variables in command names
when performing command completion.
Unfortunately I cannot do a de novo installation of bash (because I'm working on a server) but I hope this can help others.
If I understand your question, then I believe it can be solved by putting this at the top of your example.source. This will list your contents every-time that you cd.
#!/usr/bin/bash
# Make cd change directories and then list the contents
function cd() {
builtin cd $*;
ls;
}
mydir="/path/to/some/dir"
cd $mydir
My other suggestion is to try to put cd within your alias. Something like this:
mydir="cd /path/to/some/dir"
$mydir
I have a project where there are several helper scripts that call the main executable with different command-line options. Right now, the scripts assume the executable is in the same directory, so the calls to the executable in the script look like ./my_program. This, however, is not very flexible. What if the program is installed in the /usr/bin directory, and is not in the current directory?
Is there a way, using automake or autoconf, to generate these scripts, and substitute the calls to the executable with either ./my_program or just my_program, depending on whether or not the executable is already installed?
Sure. IMO the simplest solution with autotools would be:
create new m4 macro under m4/ folder that finds a path of your program, and sets it to a variable.
For example, you created a macro:
MY_PROGRAM_PATH_CHECK([action-if-found], [action-if-not-found])
This macro creates MY_PROGRAM_PATH variable if path is found.
configure.ac
MY_PROGRAM_PATH_CHECK(,[AC_MSG_ERROR([my_program path not found, woot?])
AC_SUBST(MY_PROGRAM_PATH)
AC_CONFIG_FILES([src/script1.sh], [chmod +x src/script1.sh])
AC_CONFIG_FILES([src/script2.sh], [chmod +x src/script2.sh])
convert your scripts to .in files, so the substitution would happen:
src/Makefile.am
bin_SCRIPTS = script1.sh script2.sh
src/script1.sh
#MY_PROGRAM_PATH#/my_program --option1
src/script2.sh
#MY_PROGRAM_PATH#/my_program --option2
I have a program written in C, which is named computeWeight.c and to compile it i use the following code
chaitu#ubuntu:~$ gcc -Wall -o computeWeight computeWeight.c
//to execute it:
chaitu#ubuntu:~$ ./computeWeight
Do i have any mechansim where i can directly use as mentioned below,
chaitu#ubuntu:~$ computeWeight
Should i be changing any permissions on the executable to get this?
You need to add "." to your path. Some people regard this as dangerous, though. See for instance http://www.arsc.edu/support/policy/dotinpath.html .
The $PATH variable define the places where linux would look for executables (try typing echo $PATH in a terminal). You need to put that file in one of those places. One way is to add a bin folder in your home directory, put the executable file there, and add this line (which adds the bin directory in your home folder to the search path) to your .cshrc file so that it'd be executed for every shell:
set PATH = ($PATH $HOME/bin)
With that said I don't think typing ./ is that bad.
export PATH=$PATH:.