Sunday, February 14, 2010

Auditing Another Colleagues Package - PART 2

First step from Fedora's Review Guide is to make sure that the packages/spec file passes rpmlint.

So here is the result after running the command on both the source file and the spec file

Source:
[bchao@HongKong ~]$ rpmlint viewsource-1.1-1.fc11.src.rpm
viewsource.src: W: name-repeated-in-summary viewsource
viewsource.src: W: non-standard-group Development/tools
viewsource.src: E: no-changelogname-tag
viewsource.src:25: W: setup-not-quiet
viewsource.src:44: E: files-attr-not-set
viewsource.src:45: E: files-attr-not-set
viewsource.src:46: E: files-attr-not-set
viewsource.src:47: E: files-attr-not-set
viewsource.src:48: E: files-attr-not-set
viewsource.src:49: E: files-attr-not-set
viewsource.src:50: E: files-attr-not-set
viewsource.src: W: no-cleaning-of-buildroot %clean
viewsource.src: W: mixed-use-of-spaces-and-tabs (spaces: line 1, tab: line 1)
1 packages and 0 specfiles checked; 8 errors, 5 warnings.

Spec:
[bchao@HongKong SPECS]$ rpmlint viewsource.spec
viewsource.spec:7: W: non-standard-group Development/tools
viewsource.spec:25: W: setup-not-quiet
viewsource.spec:44: E: files-attr-not-set
viewsource.spec:45: E: files-attr-not-set
viewsource.spec:46: E: files-attr-not-set
viewsource.spec:47: E: files-attr-not-set
viewsource.spec:48: E: files-attr-not-set
viewsource.spec:49: E: files-attr-not-set
viewsource.spec:50: E: files-attr-not-set
viewsource.spec: W: no-cleaning-of-buildroot %clean
viewsource.spec: W: mixed-use-of-spaces-and-tabs (spaces: line 1, tab: line 1)
0 packages and 1 specfiles checked; 7 errors, 4 warnings.

To gain more information about these errors and warnings, you would type in "rpmlint -I "

Warnings
Problem;
viewsource.spec:7: W: non-standard-group Development/tools
Fix:
Since Linux is Case sensitive, Fedora did not find the group tools, so in change I renamed it to Tools and it solved the problem.

Spec File Before
Group: Development/tools

Spec File After
Group: Development/Tools

Description
[bchao@HongKong SPECS]$ rpmlint -I non-standard-group
non-standard-group:
The value of the Group tag in the package is not valid. Valid groups are:
"Amusements/Games", "Amusements/Graphics", "Applications/Archiving",
"Applications/Communications", "Applications/Databases",
"Applications/Editors", "Applications/Emulators", "Applications/Engineering",
"Applications/File", "Applications/Internet", "Applications/Multimedia",
"Applications/Productivity", "Applications/Publishing", "Applications/System",
"Applications/Text", "Development/Debug", "Development/Debuggers",
"Development/Languages", "Development/Libraries", "Development/System",
"Development/Tools", "Documentation", "System Environment/Base", "System
Environment/Daemons", "System Environment/Kernel", "System
Environment/Libraries", "System Environment/Shells", "User
Interface/Desktops", "User Interface/X", "User Interface/X Hardware Support".

Problem
viewsource.spec:25: W: setup-not-quiet
Fix: To fix this warning, we just add the option -q (quiet) so during the setup it will not verbose everything.

Spec File Before
%setup -n %{name}

Spec File After
%setup -q -n %{name}

Description
[bchao@HongKong SPECS]$ rpmlint -I setup-not-quiet
setup-not-quiet:
Use the -q option to the %setup macro to avoid useless build output from
unpacking the sources.


Problem
viewsource.src: W: no-cleaning-of-buildroot %clean

Fix
At the beginning of the clean section I need to replace this syntax "rm -rf %{buildroot}" line with this syntax "rm -rf $RPM_BUILD_ROOT"

Description
[bchao@HongKong SPECS]$ rpmlint -I no-cleaning-of-buildroot
no-cleaning-of-buildroot:
You should clean $RPM_BUILD_ROOT in the %clean section and in the beginning of
the %install section. Use "rm -rf $RPM_BUILD_ROOT". Some rpm configurations do
this automatically; if your package is only going to be built in such
configurations, you can ignore this warning for the section(s) where your rpm
takes care of it.

Problem
viewsource.spec: W: mixed-use-of-spaces-and-tabs (spaces: line 1, tab: line 1)

Fix
Replace all the spaces between the words and use tab, there were about 8 of these warnings that follows.

Description
[bchao@HongKong SPECS]$ rpmlint -I mixed-use-of-spaces-and-tabs
mixed-use-of-spaces-and-tabs:
The specfile mixes use of spaces and tabs for indentation, which is a cosmetic
annoyance. Use either spaces or tabs for indentation, not both.


Error
Problem
viewsource.src:44: E: files-attr-not-set

Fix
To fix this problem, in the %files section I need to add attributes to the files that were listed under it.

Spec File Before
%files
/var/www/html/viewsource/viewsource.py
/var/www/html/viewsource/viewsource.config
/var/www/html/viewsource/index.html
/var/www/html/viewsource/viewsource.pyo
/var/www/html/viewsource/viewsource.pyc
/etc/httpd/conf.d/viewsource.conf
/var/www/html/viewsource/README.viewsource.fedora
%defattr(-,root,root,-)
%doc LICENSE

Spec File After
%files
%defattr(-,root,root,-)
/var/www/html/viewsource/viewsource.py
/var/www/html/viewsource/viewsource.config
/var/www/html/viewsource/index.html
/var/www/html/viewsource/viewsource.pyo
/var/www/html/viewsource/viewsource.pyc
/etc/httpd/conf.d/viewsource.conf
/var/www/html/viewsource/README.viewsource.fedora
%defattr(-,root,root,-)
%doc LICENSE


Description
[bchao@HongKong SPECS]$ rpmlint -I files-attr-not-set
files-attr-not-set:
A file or a directory entry in a %files section does not have attributes set
which may result in security issues in the resulting binary package depending
on the system where the package is built. Add default attributes using
%defattr before it in the %files section, or use per line %attr's.

After fixing these problems, all errors and warnings has been fixed. So I rebuilt the RPM file from the fixed spec file.

On the side note a proper description is needed and as well the change log was empty, so I added an entry for the fix

So now after entering information in the change log I build the spec with the following command
rpmbuild -ba viewsource.spec

So now I ran rpmlint on the new source file and was prompted with the following error.

[bchao@HongKong SRPMS]$ rpmlint viewsource-1.1-2.fc11.src.rpm
viewsource.src: W: name-repeated-in-summary viewsource
1 packages and 0 specfiles checked; 0 errors, 1 warnings.

Here is the description of the error

[bchao@HongKong SRPMS]$ rpmlint -I name-repeated-in-summary
name-repeated-in-summary:
The name of the package is repeated in its summary. This is often redundant
information and looks silly in various programs' output. Make the summary
brief and to the point without including redundant information in it.

To fix the problem, in the Summary section, I need to replace the information in there and add something else.

In the description section, I went to the Viewsource site David Humphrey setup and copied part of the description and replaced it in the spec file.

Now after rebuilding the spec file, there aren't any errors any more. So far I haven't gone through the rest of the Fedora review guide, but so far this is a start. The new viewsource files will be up in our repository.

0 comments:

Post a Comment