echo base_path/{subfolder1,subfolder2} | xargs -n 1 make clean -C
2010-04-12
Multiple make
To clean multiple folders at once:
2010-03-26
RPM atomated building
If your are providing sources or binaries of your software as RPMs you should be aware of a smart way of automating RPM creation.
To create RPM building environment:
In your RPM generation script use constructions like
Following this recommendation you will never need to force your packagers to use a harcoded SOURCES folder or to do configuration of your package with their RPM settings.
Again, thanks to comrade Buzykaev, for his tar command idea
To create RPM building environment:
- create ~/.rpmmacros with the following content:
%_topdir .../rpm #Arbitrary
%_tmppath /tmp/rpm #Optional
Three dots here denote your favorite RPM building directory infrastructure root. (/home/username will do) - use the following script:
#!/bin/sh
for d in _topdir _sourcedir _rpmdir _srcrpmdir _specdir _builddir _tmppath; do
mkdir -p `rpm --eval %{$d}`
done
In your RPM generation script use constructions like
# Doesn't override previously set value. See Parameter Expansion
SOURCES=${SOURCES:-`rpm --eval %{_sourcedir}`}
#Assumes your sources are in $PROJECTS/$PROJECT directory
tar --wildcards --exclude \*\.svn\* --exclude \*\~ \ -C "$PROJECTS" -zcf "$SOURCES/$PROJECT.tar.gz" $PROJECT
rpmbuild -ba "$PROJECTS/$PROJECT/$PROJECT.spec"
Following this recommendation you will never need to force your packagers to use a harcoded SOURCES folder or to do configuration of your package with their RPM settings.
2010-02-12
Bash versioning
Here is the bash command:
This expands to
This feature of bash is called Brace Expansion and can ease versioning of files based on filesystem. If you have a sequence of files with versions assigned to them as incremented part of the name, you can easily create one more with the given command:
Even nicer usage:
cp -i aaa/bbb/ccc/ddd/xxxx_{6,7}.tpl
This expands to
cp -i aaa/bbb/ccc/ddd/xxxx_6.tpl aaa/bbb/ccc/ddd/xxxx_7.tpl
This feature of bash is called Brace Expansion and can ease versioning of files based on filesystem. If you have a sequence of files with versions assigned to them as incremented part of the name, you can easily create one more with the given command:
> ls
aaa/bbb/ccc/ddd/xxxx_4.tpl
aaa/bbb/ccc/ddd/xxxx_5.tpl
aaa/bbb/ccc/ddd/xxxx_6.tpl
> cp -i aaa/bbb/ccc/ddd/xxxx_{6,7}.tpl
> ls
aaa/bbb/ccc/ddd/xxxx_4.tpl
aaa/bbb/ccc/ddd/xxxx_5.tpl
aaa/bbb/ccc/ddd/xxxx_6.tpl
aaa/bbb/ccc/ddd/xxxx_7.tpl
Even nicer usage:
cp filename{,_`date '+%F'`}
2009-12-15
A floating point and C++ templates
Find a bug in the following line:
double sum = std::accumulate(V.begin(), V.end(), 0);
Think more...
This bug can't be easiliy avoided as the connection between internal accumulator variable, return value and third argument types is not obvious and is very well incapsulated by implementation.
The right answer is:
double sum = std::accumulate(V.begin(), V.end(), double(0)); //0.L gives off the same effect
Here is GNU implementation of template function in question:
double sum = std::accumulate(V.begin(), V.end(), 0);
Think more...
This bug can't be easiliy avoided as the connection between internal accumulator variable, return value and third argument types is not obvious and is very well incapsulated by implementation.
The right answer is:
double sum = std::accumulate(V.begin(), V.end(), double(0)); //0.L gives off the same effect
Here is GNU implementation of template function in question:
/**
* @brief Accumulate values in a range.
*
* Accumulates the values in the range [first,last) using operator+(). The
* initial value is @a init. The values are processed in order.
*
* @param first Start of range.
* @param last End of range.
* @param init Starting value to add other values to.
* @return The final sum.
*/
template
inline _Tp
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_requires_valid_range(__first, __last);
for (; __first != __last; ++__first)
__init = __init + *__first;
return __init;
}
2009-11-12
Empty structures in C and C++
//test.c
#include <stdio.h>
struct Temp0{};
struct Temp1{char a;};
int main() {
printf("Temp0 size: %d\n", sizeof(struct Temp0));
printf("Temp1 size: %d\n", sizeof(struct Temp1));
return 0;
}
This code being compiled with GNU toolchain gives the following results:
$ gcc test.c -o test && ./test
Temp0 size: 0
Temp1 size: 1
$ g++ test.c -o test && ./test
Temp0 size: 1
Temp1 size: 1
The reasons explained
I wonder are other toolchains give the same results...
2009-07-10
Gnome-terminal and gconf
Recently there was a usual problem with gnome-terminal in Debian testing. As gconf is updated, gnome-terminal won't start gconf by itself.
Manual update of gnome-terminal (to version 2.26) from unstable release solves the problem.
Manual update of gnome-terminal (to version 2.26) from unstable release solves the problem.
Подписаться на:
Сообщения (Atom)