I have to perform some necessary steps before installing my package, such as taking back up of previous datastore snapshot. For that purpose I'm using a %pre script as follows.
%pre
#!/bin/sh
--------
--------
stamp=`date +%Y%m%d%H%M%S`
echo ${stamp}
-------------
-------------
The output is as follows: 20161103123325OURCE It is printing some random characters along with date. "OURCE" is not present anywhere in my spec file.
The same script works perfectly as standalone. The platform is CentOS7.
rpmbuild knows a whole set of macros. Apparently a certain macro is defined as:
%S = %SOURCE
I didn't manage to find something that tells rpmbuild not to expand that macro; but there is a way in tricking him not to do so. I know this is a little workaround, but it's the best I could come up with:
stamp=$(date '+%Y%m%d%H%M%''S')
$()
invocation