Bug 676383 - Running `fedpkg local' parses spec file uselessly
Summary: Running `fedpkg local' parses spec file uselessly
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: fedora-packager
Version: 14
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: David Cantrell
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-02-09 17:07 UTC by Vojtech Vitek
Modified: 2015-03-04 23:57 UTC (History)
3 users (show)

Fixed In Version: fedora-packager-0.5.5.0-2.fc15
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-02-22 18:49:56 UTC


Attachments (Terms of Use)
Fix error message while `_name_from_spec' can't parse spec file (473 bytes, patch)
2011-02-09 17:07 UTC, Vojtech Vitek
no flags Details | Diff

Description Vojtech Vitek 2011-02-09 17:07:10 UTC
Created attachment 477865 [details]
Fix error message while `_name_from_spec' can't parse spec file

I have encountered following error, while running
$ fedpkg local
on branch with "broken" .spec file which was missing first date line.

$ fedpkg local
Traceback (most recent call last):
  File "/usr/bin/fedpkg", line 1259, in <module>
    args.command(args)
  File "/usr/bin/fedpkg", line 569, in local
    mymodule = pyfedpkg.PackageModule(args.path, args.dist)
  File "/usr/lib/python2.7/site-packages/pyfedpkg/__init__.py", line 1083, in __init__
    self.module = _name_from_spec(os.path.join(self.path, self.spec))
  File "/usr/lib/python2.7/site-packages/pyfedpkg/__init__.py", line 111, in _name_from_spec
    return output.split()[0]
IndexError: list index out of range


With the provided patch I get following output (it actually tells what to do):

$ fedpkg local
error: %changelog entries must start with *
error: query of specfile /home/vvitek/work/less/master/less.spec failed, can't parse
Could not build locally: Could not parse spec file.


But anyway, I find very annoying that
$ fedpkg local
parses spec file just for the name of module (def _name_from_spec), that could be actually parsed from the filename itself (convention of <module>.spec).

In other words, there is no need of spec file to make local build from archive, is it?

Comment 1 Jesse Keating 2011-02-09 19:19:22 UTC
There have been a few cases where the spec file doesn't match the name of the package.  I wanted to make fedpkg work in this scenario.  RPM is going to parse the specfile when it builds, so if the specfile is broken, the build is going to fail too.  The parsing is very quick, so I don't really see why it is a problem to parse it.

I'll be looking into the patch today, thanks!

Comment 2 Jesse Keating 2011-02-10 01:22:05 UTC
Just committed something upstream that fixes this in the coding style we use.

Comment 3 Vojtech Vitek 2011-02-10 09:25:56 UTC
Thank you, Jesse!

> There have been a few cases where the spec file doesn't match the name
> of the package.

I didn't know there could be such files. I thought we had strict policy without any exceptions.
http://fedoraproject.org/wiki/Packaging:NamingGuidelines#Spec_file_name

Actually, if we could rely on the package name, the patch could be even simpler:

--- __init__.py.orig    2011-02-09 17:37:10.660506442 +0100
+++ __init__.py 2011-02-10 10:14:23.891256705 +0100
@@ -765,7 +765,7 @@ def sources(path, outdir=None):
             break
     if not spec:
         raise FedpkgError('%s is not a valid repo' % path)
-    module = _name_from_spec(os.path.join(path, spec))
+    module = spec[0:-5] # Strip ".spec" suffix
     try:
         archives = open(os.path.join(path, 'sources'),
                         'r').readlines()

Comment 4 Jesse Keating 2011-02-10 17:49:12 UTC
We have the policy yes, but that doesn't mean the policy is always followed.  It is better to be flexible in what input is accepted.  Getting the name via parsing the spec is the proper way to do this, and it takes a fraction of a second, I really don't understand why you have a problem with this.

Comment 5 Dennis Gilmore 2011-02-10 18:58:48 UTC
fedpkg local does a (In reply to comment #0)

> 
> But anyway, I find very annoying that
> $ fedpkg local
> parses spec file just for the name of module (def _name_from_spec), that could
> be actually parsed from the filename itself (convention of <module>.spec).
> 
> In other words, there is no need of spec file to make local build from archive,
> is it?

fedpkg local 

should be doing a rpmbuild -ba <spec>  not unpacking the tarball and building in it. it does it locally on the system using rpm not from the archive  so yes there is a need to parse the spec file.

Dennis

Comment 6 Fedora Update System 2011-02-10 21:40:20 UTC
fedora-packager-0.5.5.0-1.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/fedora-packager-0.5.5.0-1.fc14

Comment 7 Fedora Update System 2011-02-10 22:02:57 UTC
fedora-packager-0.5.5.0-1.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/fedora-packager-0.5.5.0-1.fc13

Comment 8 Fedora Update System 2011-02-10 22:22:19 UTC
fedora-packager-0.5.5.0-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/fedora-packager-0.5.5.0-1.el5

Comment 9 Fedora Update System 2011-02-10 22:40:22 UTC
fedora-packager-0.5.5.0-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/fedora-packager-0.5.5.0-1.el6

Comment 10 Fedora Update System 2011-02-10 22:44:08 UTC
fedora-packager-0.5.5.0-1.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/fedora-packager-0.5.5.0-1.fc15

Comment 11 Fedora Update System 2011-02-10 23:12:17 UTC
fedora-packager-0.5.5.0-1.fc15 has been pushed to the Fedora 15 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 fedora-packager'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/fedora-packager-0.5.5.0-1.fc15

Comment 12 Vojtech Vitek 2011-02-11 11:39:48 UTC
(In reply to comment #4)
> I really don't understand why you have a problem with this.

It's all about git workflow. I always do separate changes in separate commits, which means "broken" %changelog section until the final commit with "name-modify-line" and increased release version.

(In reply to comment #5)
> fedpkg local 
> 
> should be doing a rpmbuild -ba <spec>  not unpacking the tarball and building
> in it. it does it locally on the system using rpm not from the archive so yes
> there is a need to parse the spec file.

Well, this probably killed my arguments..
Seems like I have to add the line every time (or use git stash).

Comment 13 Jesse Keating 2011-02-11 19:31:38 UTC
There are some projects around that can create rpm changelog lines based on git commit messages from a previous point.  I'll be looking at moving something like that into fedpkg itself, so that you can avoid doing the spec changelog entries until you're ready to bump n-v-r and build.

Comment 14 Fedora Update System 2011-02-12 21:33:40 UTC
fedora-packager-0.5.5.0-2.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/fedora-packager-0.5.5.0-2.fc15

Comment 15 Fedora Update System 2011-02-21 22:46:29 UTC
fedora-packager-0.5.5.0-2.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/fedora-packager-0.5.5.0-2.fc14

Comment 16 Fedora Update System 2011-02-21 22:46:58 UTC
fedora-packager-0.5.5.0-2.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/fedora-packager-0.5.5.0-2.fc14

Comment 17 Fedora Update System 2011-02-21 22:49:02 UTC
fedora-packager-0.5.5.0-2.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/fedora-packager-0.5.5.0-2.fc13

Comment 18 Fedora Update System 2011-02-21 22:53:20 UTC
fedora-packager-0.5.5.0-2.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/fedora-packager-0.5.5.0-2.el6

Comment 19 Fedora Update System 2011-02-21 23:01:20 UTC
fedora-packager-0.5.5.0-2.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/fedora-packager-0.5.5.0-2.el5

Comment 20 Fedora Update System 2011-02-22 18:49:27 UTC
fedora-packager-0.5.5.0-2.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 21 Fedora Update System 2011-02-22 18:50:40 UTC
fedora-packager-0.5.5.0-2.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 22 Fedora Update System 2011-02-23 21:51:38 UTC
fedora-packager-0.5.5.0-2.el5 has been pushed to the Fedora EPEL 5 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 23 Fedora Update System 2011-02-28 23:56:52 UTC
fedora-packager-0.5.5.0-2.el6 has been pushed to the Fedora EPEL 6 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 24 Fedora Update System 2011-03-03 03:23:44 UTC
fedora-packager-0.5.5.0-2.fc15 has been pushed to the Fedora 15 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.