Bug 1762469

Summary: RFE: fedpkg import SRPM handles <package_name>.rpmlintrc
Product: [Fedora] Fedora Reporter: Gerald Cox <gbcox>
Component: fedpkgAssignee: Ondřej Nosek <onosek>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: cqi, dennis, jkeating, lsedlar, onosek, s
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-01-15 00:39:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Gerald Cox 2019-10-16 20:01:49 UTC
Description of problem:
Discussion here:

https://discussion.fedoraproject.org/t/how-to-add-package-name-rpmlintrc-to-fedora-dist-git-repository/

I would like to add an rpmlintrc file to filter out spelling errors to the fedora dist git repository.

I tried: git add <package_name>.rpmlintrc

but when I imported the sources using:
fedpkg import source_rpm

fedpkg deleted the file and issued the following message:
Removing no longer used file: <package_name>.rpmlintrc

I regularly use fedpkg import source_rpm to input source files.  Easy and works prefect... but I don't want it deleting the rpmlintrc file every time I import a new source file.

Comment 1 Gerald Cox 2019-10-21 01:29:09 UTC
Changed title to make this into an RFE to request fedpkg import handle processing for <package_name>.rpmlintrc
if it exists.

Comment 2 Gerald Cox 2019-10-21 19:41:55 UTC
I found a method that appears to work.  I'm just wondering if that is what 
the creators of fedpkg intended.

1.  Add an additional source statement in the spec file:  Source1:  <package.name>.rpmlintrc
2.  Place the <package.name>.rpmlintrc file in the local fedpkg <package.name> directory
3.  Create srpm:  fedpkg srpm
4.  $ git add -u
5.  $ fedpkg clog
6.  $ git commit -F clog
7.  $ fedpkg import updated.srpm
    fedpkg responds:
    diff --git a/<package.name>.rpmlintrc b/<package.name>.rpmlintrc
    new file mode 100644
    index 0000000..ea84abe
    --- /dev/null
    +++ b/<package.name>.rpmlintrc
    @@ -0,0 +1,3 @@
    +# SPELLING ERRORS
    +addFilter(r" spelling-error .* (word")
    +addFilter(r" no-manual-page-for-binary <package.name>")
    --------------------------------------------
    New content staged and new sources uploaded.
    Commit if happy or revert with: 'git reset --hard HEAD' (warning: it reverts also eventual user changes).
8.  $ git commit --am

Comment 3 Fedora Admin XMLRPC Client 2020-03-23 16:40:20 UTC
This package has changed maintainer in the Fedora.
Reassigning to the new maintainer of this component.

Comment 4 Ondřej Nosek 2021-01-15 00:36:03 UTC
Hello.

I wonder why every time to use 'import' command for one repository. Maybe I didn't understand the purpose. I am not the author of the concept. But I suppose the "typical" use is: Create a new project by importing the srpm. And then, iteratively, just update tarball (manually, spectool, ...) and/or other files(s) containing sources (not srpm), bump the version of the specfile, do other eventual changes and build.
But your scenario might be different, of course.

During import command, all unneeded committed files are removed. Which files are needed is specified in srpm. Therefore .rpmlintrc file is removed. There are more approaches to go:

1) Use 'import' and then add .rpmlintrc and commit it. But after another import, .rpmlintrc will be removed again.

2) Your method listed in your comment can be used. Generally, make the .rpmlintrc part of the srpm.

3) You can also try the method I found: Just add .rpmlintrc file and list the filename in .gitignore. Commit both of them. Next 'import' command should not remove the .rpmlintrc.

4) There is a possibility to patch the code itself. But I am quite cautious to add this kind of exception for everyone.

diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py
index 52dcee3..35bc99c 100644
--- a/pyrpkg/__init__.py
+++ b/pyrpkg/__init__.py
@@ -1795,7 +1795,7 @@ class Commands(object):
         # while importing a SRPM.
         # The list also contains files, that are important and should
         # not be removed by import command.
-        reserved_ourfiles = ['README.md', 'gating.yaml', 'tests/*']
+        reserved_ourfiles = ['README.md', 'gating.yaml', 'tests/*', '*.rpmlintrc']
 
         # Get a list of files we're currently tracking
         ourfiles = self.repo.git.ls_files().split('\n')

Comment 5 Ondřej Nosek 2021-01-15 00:39:49 UTC
I am not going to change the code now. I hope other listed methods might be sufficient. If there is a demand for it, please, reopen.

Comment 6 Gerald Cox 2021-01-15 04:04:21 UTC
(In reply to Ondřej Nosek from comment #4)
> Hello.
> 
> I wonder why every time to use 'import' command for one repository. Maybe I
> didn't understand the purpose. I am not the author of the concept. But I
> suppose the "typical" use is: Create a new project by importing the srpm.
> And then, iteratively, just update tarball (manually, spectool, ...) and/or
> other files(s) containing sources (not srpm), bump the version of the
> specfile, do other eventual changes and build.
> But your scenario might be different, of course.
> 
> During import command, all unneeded committed files are removed. Which files
> are needed is specified in srpm. Therefore .rpmlintrc file is removed. There
> are more approaches to go:
> 
> 1) Use 'import' and then add .rpmlintrc and commit it. But after another
> import, .rpmlintrc will be removed again.
> 
> 2) Your method listed in your comment can be used. Generally, make the
> .rpmlintrc part of the srpm.
> 
> 3) You can also try the method I found: Just add .rpmlintrc file and list
> the filename in .gitignore. Commit both of them. Next 'import' command
> should not remove the .rpmlintrc.
> 
> 4) There is a possibility to patch the code itself. But I am quite cautious
> to add this kind of exception for everyone.
> 
> diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py
> index 52dcee3..35bc99c 100644
> --- a/pyrpkg/__init__.py
> +++ b/pyrpkg/__init__.py
> @@ -1795,7 +1795,7 @@ class Commands(object):
>          # while importing a SRPM.
>          # The list also contains files, that are important and should
>          # not be removed by import command.
> -        reserved_ourfiles = ['README.md', 'gating.yaml', 'tests/*']
> +        reserved_ourfiles = ['README.md', 'gating.yaml', 'tests/*',
> '*.rpmlintrc']
>  
>          # Get a list of files we're currently tracking
>          ourfiles = self.repo.git.ls_files().split('\n')


Thanks for taking the time to reply.  I've been using the method in comment #2.  It seems to be working fine, although
it seems to be a bit of a hack.  The reason for using fedpkg import srpm is explained in the following thread, in case you are interested.

From what I gather, it was created to automate and error-proof the process as much as possible.  Since that was the case, I was hoping
something could be done to automagically handle rpmlintrc, if it exists.

https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/2ZZYKYDD24LCFO6ST6O6RQBCEGKE6WAS/#BC65GAULZEJFR4O5HRT2EPRASESCLBU6