Bug 498588

Summary: rpmdev-newspec -o perl-test.spec falls back to generic template (incl. patch)
Product: [Fedora] Fedora Reporter: Edwin ten Brink <fedora>
Component: rpmdevtoolsAssignee: Ville Skyttä <ville.skytta>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: 10CC: ville.skytta
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 7.3-1.fc10 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-06-16 01:57:13 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:
Attachments:
Description Flags
Possible solution to guess the appname from the -o parameter
none
Alternative patch none

Description Edwin ten Brink 2009-05-01 10:50:49 UTC
Created attachment 342073 [details]
Possible solution to guess the appname from the -o parameter

Description of problem:
When a user only supplies "-o foo.spec" but does not state package "foo", the appname is not set. This has the consequence that no template guessing can be performed.
Of course, the user who has read the help the right way, does not do such things. :-) The script however should be able to tolerate such users.

Version-Release number of selected component (if applicable):
$ rpm -q --file /usr/bin/rpmdev-newspec 
rpmdevtools-7.0-1.fc10.noarch

How reproducible:
Always

Steps to Reproduce:
1. rpmdev-newspec -o perl-test.spec

Actual results:
Skeleton specfile (minimal) has been created to "perl-test.spec".

Expected results:
Skeleton specfile (perl) has been created to "perl-test.spec".

Additional info:
See attached patch for possible solution. If the user only supplied the "-o" parameter, guess the appname from that value. If the appname is given too, that one prevails to actually set the appname.

Comment 1 Ville Skyttä 2009-05-01 11:30:13 UTC
Created attachment 342078 [details]
Alternative patch

Agreed, but I think your patch isn't quite optimal in "-o -" or "-o /dev/stdout" cases.  Also, did you intend to set the value of $appname_guessed (not $appname) in the -o only case?  It seems to me that the value of $appname_guessed is never set.

How about the attached alternative patch, do you see any drawbacks in it?

Comment 2 Edwin ten Brink 2009-05-01 11:59:08 UTC
I didn't have any stdout cases in mind with the patch, so the alternative handles such cases much better. A strange appname could be set, though it doesn't seem to harm anything.

$appname_guessed in my patch was set as soon as the "-o" option was detected. Only at the end it would be written in $appname when it was not set already.

This last case you handled effectively by unconditionally assigning $appname as soon as a ".spec" is seen and conditionally when "-o" is parsed (which were my greatest concerns).

In summary: your patch handles /dev/stdout better and behaves otherwise the same, so please incorporate your patch.

Will you close this bug when you have committed the patch?

Comment 3 Ville Skyttä 2009-05-02 09:10:49 UTC
(In reply to comment #2)

> $appname_guessed in my patch was set as soon as the "-o" option was detected.

Hmm...

> +            [ -z "$appname_guessed"  ] && appname="$(basename $1 .spec)"

...note "appname=...", not "appname_guessed=...".  But nevermind, now I at least know what the intention was ;)

> In summary: your patch handles /dev/stdout better and behaves otherwise the
> same, so please incorporate your patch.

Done in git: https://fedorahosted.org/rpmdevtools/changeset/0f00df9ce9a9ef96dbeefaeb3b06e12b1de4be7d

> Will you close this bug when you have committed the patch?  

If it's fine with you, I'd rather not close it until we have a package release in Fedora repos that contain the change.

Comment 4 Fedora Update System 2009-05-21 17:55:41 UTC
rpmdevtools-7.2-1.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/rpmdevtools-7.2-1.fc11

Comment 5 Fedora Update System 2009-05-21 17:56:42 UTC
rpmdevtools-7.2-1.fc10 has been submitted as an update for Fedora 10.
http://admin.fedoraproject.org/updates/rpmdevtools-7.2-1.fc10

Comment 6 Fedora Update System 2009-05-24 21:41:26 UTC
rpmdevtools-7.3-1.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/rpmdevtools-7.3-1.fc11

Comment 7 Fedora Update System 2009-05-24 21:42:11 UTC
rpmdevtools-7.3-1.fc10 has been submitted as an update for Fedora 10.
http://admin.fedoraproject.org/updates/rpmdevtools-7.3-1.fc10

Comment 8 Fedora Update System 2009-05-25 21:14:38 UTC
rpmdevtools-7.2-1.fc10 has been pushed to the Fedora 10 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update rpmdevtools'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F10/FEDORA-2009-5334

Comment 9 Fedora Update System 2009-05-26 07:56:23 UTC
rpmdevtools-7.3-1.fc10 has been pushed to the Fedora 10 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update rpmdevtools'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F10/FEDORA-2009-5511

Comment 10 Fedora Update System 2009-06-16 01:57:08 UTC
rpmdevtools-7.3-1.fc10 has been pushed to the Fedora 10 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 11 Fedora Update System 2009-06-16 02:06:38 UTC
rpmdevtools-7.3-1.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.