Bug 498588 - rpmdev-newspec -o perl-test.spec falls back to generic template (incl. patch)
rpmdev-newspec -o perl-test.spec falls back to generic template (incl. patch)
Status: CLOSED NEXTRELEASE
Product: Fedora
Classification: Fedora
Component: rpmdevtools (Show other bugs)
10
All Linux
low Severity low
: ---
: ---
Assigned To: Ville Skyttä
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-05-01 06:50 EDT by Edwin ten Brink
Modified: 2009-06-15 22:06 EDT (History)
1 user (show)

See Also:
Fixed In Version: 7.3-1.fc10
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-06-15 21:57:13 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Possible solution to guess the appname from the -o parameter (652 bytes, patch)
2009-05-01 06:50 EDT, Edwin ten Brink
no flags Details | Diff
Alternative patch (741 bytes, patch)
2009-05-01 07:30 EDT, Ville Skyttä
no flags Details | Diff

  None (edit)
Description Edwin ten Brink 2009-05-01 06:50:49 EDT
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 07:30:13 EDT
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 07:59:08 EDT
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 05:10:49 EDT
(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 13:55:41 EDT
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 13:56:42 EDT
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 17:41:26 EDT
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 17:42:11 EDT
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 17:14:38 EDT
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 03:56:23 EDT
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-15 21:57:08 EDT
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-15 22:06:38 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.