Bug 90428

Summary: rpm removes '%-...' conversions in scriptlets
Product: [Retired] Red Hat Linux Reporter: Murray Jensen <murray.jensen>
Component: rpmAssignee: Jeff Johnson <jbj>
Status: CLOSED NOTABUG QA Contact: Mike McLean <mikem>
Severity: medium Docs Contact:
Priority: medium    
Version: 9   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-05-08 20:28:28 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Murray Jensen 2003-05-08 02:20:24 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 Galeon/1.0.3 (X11; Linux i686; U;) Gecko/0

Description of problem:
Take the following test spec file (test.spec):

------------------------------------------------------------------
Name: test
Version: 1.0
Release: 1
Summary: A test package
License: GPL
Vendor: CSIRO-MIT
URL: http://www.csiro.au/
Group: none
Packager: Murray.Jensen

# need this because we don't have a build dir
%undefine
__check_files

%description

A simple test package...

%pre

echo "pre: test percent %-14s %14s %+14s % -14s - \$1='$1'"

%post

echo "post: test percent %-14s %14s %+14s % -14s - \$1='$1'"

%preun

echo "preun: test percent %-14s %14s %+14s % -14s - \$1='$1'"

%postun

echo "postun: test percent %-14s %14s %+14s % -14s - \$1='$1'"

%files

%doc /dev/null
------------------------------------------------------------------

Run "rpmbuild -bb test.spec", then run "rpm -q --scripts -p xxx.rpm"
where "xxx.rpm" is the binary rpm resulting from the "rpmbuild".

You will see that the string '%-14s' has been completely removed from
the script. Other percent conversions remain.

I discovered this while trying to use the "printf" command, or printf
in awk, within a scriptlet, and then trying to left justify a string.


Version-Release number of selected component (if applicable):
rpm-4.2-0.69

How reproducible:
Always

Steps to Reproduce:
1. <create the test.spec file from description>
2. rpmbuild -bb test.spec
3. rpm -q --scripts -p test-1.0-1.i386.rpm
    

Actual Results:  The scriptlet stored in the binary rpm file was not identical
to the
scriptlet in the spec file

Expected Results:  I expect the scriptlet stored in the binary rpm to be *exactly*
identical to the scriptlet as written in the spec file

Additional info:

Here's what output from command #3 looks like for me:

------------------------------------------------------------------
preinstall scriptlet (using /bin/sh):

echo "pre: test percent  %14s %+14s % -14s - \$1='$1'"
postinstall scriptlet (using /bin/sh):

echo "post: test percent  %14s %+14s % -14s - \$1='$1'"
preuninstall scriptlet (using /bin/sh):

echo "preun: test percent  %14s %+14s % -14s - \$1='$1'"
postuninstall scriptlet (using /bin/sh):

echo "postun: test percent  %14s %+14s % -14s - \$1='$1'"
------------------------------------------------------------------

You will notice a workaround in the output above. The conversion
"% -14s" is NOT removed, and it will still work the same way in both
the "printf" command, and printf in awk, since the space is a
harmless modifier for string conversions.

Comment 1 Jeff Johnson 2003-05-08 20:28:28 UTC
Escape (by doubling '%%') the per cents.