Bug 198706 - php-pear spec template
php-pear spec template
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: fedora-rpmdevtools (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Ville Skyttä
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-07-12 19:24 EDT by Christopher Stone
Modified: 2007-11-30 17:11 EST (History)
4 users (show)

See Also:
Fixed In Version: 5.1-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-09-12 17:08:54 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
The patch (749 bytes, patch)
2006-07-12 19:24 EDT, Christopher Stone
no flags Details | Diff
The template (1.40 KB, text/plain)
2006-07-12 19:25 EDT, Christopher Stone
no flags Details
Patch eliminating need of macros.pear stuff (3.09 KB, patch)
2006-07-18 13:38 EDT, Ville Skyttä
no flags Details | Diff
The "unmacroize" changes against the original submitted template (2.07 KB, patch)
2006-07-20 15:35 EDT, Ville Skyttä
no flags Details | Diff
Changes between the submitted and the first committed one (1.49 KB, patch)
2006-07-20 15:37 EDT, Ville Skyttä
no flags Details | Diff
New Template Incorporating some of Ville's changes (1.41 KB, patch)
2006-09-03 00:00 EDT, Christopher Stone
no flags Details | Diff
Patch to fix Requires (434 bytes, patch)
2006-09-03 00:25 EDT, Christopher Stone
no flags Details | Diff
New Template with __pear defined (1.47 KB, patch)
2006-09-03 20:22 EDT, Christopher Stone
no flags Details | Diff
Update to CVS version 1.3 (792 bytes, patch)
2006-09-06 01:33 EDT, Christopher Stone
no flags Details | Diff
New patch incorporating latest comments (1.07 KB, patch)
2006-09-06 02:12 EDT, Christopher Stone
no flags Details | Diff
Latest Patch with %{ClassName} (2.15 KB, patch)
2006-09-06 17:07 EDT, Christopher Stone
no flags Details | Diff
Forgot one (364 bytes, patch)
2006-09-06 21:29 EDT, Christopher Stone
no flags Details | Diff

  None (edit)
Description Christopher Stone 2006-07-12 19:24:51 EDT
Here is the php-pear-* spec template stuff
Comment 1 Christopher Stone 2006-07-12 19:24:51 EDT
Created attachment 132340 [details]
The patch
Comment 2 Christopher Stone 2006-07-12 19:25:22 EDT
Created attachment 132341 [details]
The template
Comment 3 Ville Skyttä 2006-07-18 13:04:02 EDT
Ok, I've added a slightly modified version to CVS (fedora-rpmdevtools in the
"fedora" root [0]).  Changes to the template:

- Rename to spectemplate-php-pear.spec (so that people not at all
  knowledgeable about PHP get an idea what's it about), other cosmetics.

- Use %{__pear} consistently everywhere.  I see this actually may have broken
  things somewhat, Requires(foo) will need to be converted to something like
  Requires(foo): %{?__pear}%{!?__pear:/usr/bin/pear}
  Thoughts?

- Drop redundant (isn't it?) Requires: php, pulled in by php-pear(PEAR).

- Add empty %build section to avoid nasty surprises.

- Remove "docdir" at start of %install to make sure --short-circuit builds
  are clean.

Remaining issues/questions:

- Are all php-pear-* packages noarch?

- Unpacking "package.xml" to the top-level build dir is not nice, and may
  result in race conditions and inconsistencies when many php-pear-* packages
  are being simultaneously built.  One possible solution: use -c to %setup,
  and cd into Foo_Bar-%{version} at start of %prep and %install (and %build
  for completeness).

- I cannot test the template because nothing in my FC5 setup provides
  %{__pear} and friends.  Should have a versioned build dependency on the
  package providing the macros, or maybe even a file-based one to the actual 
  /etc/rpm/macros.XXX file

- Do PEAR modules usually/often/ever ship with test suites that could be
  added to %check in the template?

- Are %{pear_testdir}/Foo_Bar, %{pear_datadir}/Foo_Bar and %{pear_phpdir}/Foo
  directories?  I'd like to add trailing '/'s to them to signify that.

[0] http://cvs.fedora.redhat.com/viewcvs/fedora-rpmdevtools/?root=fedora
Comment 4 Ville Skyttä 2006-07-18 13:38:10 EDT
Created attachment 132611 [details]
Patch eliminating need of macros.pear stuff

Foor for thought: this patch applied over the current rpmdevtools CVS would get
rid of the need to have any pear macros defined at all.  Even though it adds a
bit to the template, I personally think it would be acceptable.  WDYT?
Comment 5 Ville Skyttä 2006-07-18 13:40:14 EDT
Even better if %post would instead of '-d "$xmldir"' check for '-f
"$xmldir/Foo_Bar.xml"'
Comment 6 Christopher Stone 2006-07-20 01:31:16 EDT
Can you give me a patch for the template against the version I uploaded.  I
think we can eliminate some stuff in the newrpmspec patch that is not needed
with your changes.  But I need a patch that will apply cleanly.
Comment 7 Ville Skyttä 2006-07-20 15:35:01 EDT
Created attachment 132767 [details]
The "unmacroize" changes against the original submitted template

Sure, here goes.  Just out of interest, were there any things you found
controversial in the changes I made before committing my initial slightly
modfied version of the original?  It could be hard to track versions...

In case you're not aware of it, you can grab the rpmdevtools development dir
from CVS, see fedora-rpmdevtools in the fedora root:
:ext:yourusername@cvs.fedora.redhat.com:/cvs/fedora
Comment 8 Ville Skyttä 2006-07-20 15:37:13 EDT
Created attachment 132768 [details]
Changes between the submitted and the first committed one

For completeness, here are the changes I made to the original submission before
committing it.	Sorry about that, I should have either asked first, or at least
committed the original version first and then do the changes in a subsequent
commit for tracking purposes.
Comment 9 Christopher Stone 2006-07-20 19:40:03 EDT
Okay, I can patch both of these new patches against the original, but I cannot
apply both of them to the same file to get your final result.

Some initial comments though:
Yes, all php-pear packages are noarch and the %build is not needed.  I don't
think it should be added because it should never be used.

I do not understand why you are making a .files section.  And I don't understand
why this includes a defattr line in it, as this is repeated twice it seems. 
What is wrong with just listing the files like I orignally had it, I don't
follow your logic here.

I also don't see why we should define all the directories in the spec file when
they can easily be defined in a macros file with php-pear package.
Comment 10 Ville Skyttä 2006-07-21 03:04:23 EDT
(In reply to comment #9)
> Yes, all php-pear packages are noarch and the %build is not needed.  I don't
> think it should be added because it should never be used.

I disagree.  We don't know the side effects of that.  One such unexpected side
effect is eg. bug 192422 which doesn't apply here as things are noarch, but
there's nothing that guarantees other similar ones won't happen as it's a matter
of rpm configuration.

> I do not understand why you are making a .files section.

That's one way of avoiding defining the macros, which is the very purpose of the
patch.  Sure, they could be defined within the specfile, but I think this way
it's cleaner.

> And I don't understand why this includes a defattr line in it, as this is
> repeated twice it seems.

That can perhaps be removed.  It's a matter of when rpmbuild reads the filelist
(before parsing the rest of the %files section including the %defattr or after),
will need to check it.

> I also don't see why we should define all the directories in the spec file
> when they can easily be defined in a macros file with php-pear package.

How easily?  They're still not in FC5 and probably never will be in eg. FC4 and
RHEL4 and derivatives, resulting in incompatibilities without much gain at all.
Comment 11 Christopher Stone 2006-09-03 00:00:51 EDT
Created attachment 135449 [details]
New Template Incorporating some of Ville's changes

Okay here is a new template that has some of Ville's changes in it.  I did not
incorporate all of the unnecessary stuff because we now have the pear/pecl
macros in the php-pear rpm on FC-5.

Please let me know if there is anything left that needs fixing with this, and
if so please provide clean patches! :)
Comment 12 Christopher Stone 2006-09-03 00:25:20 EDT
Created attachment 135451 [details]
Patch to fix Requires

I tested this in mock, and it does not like the %{__pear} in the Requires(post)
and (postun) sections.	This patch reverts back to the original using
/usr/bin/pear

This is the error reported:
error: line 15: Dependency tokens must begin with alpha-numeric, '_' or '/':
Requires(post): %{__pear}
Comment 13 Ville Skyttä 2006-09-03 05:04:30 EDT
With the latest template + the patch we're back in the situation where
/usr/bin/pear is hardcoded in dependencies but %{__pear} used elsewhere in the
template -- eg. /usr/bin/pear is the dependency for %post and friends scriptlets
which use %{__pear}, not /usr/bin/pear.

So, %{__pear} needs to be conditionally defined in the template, something like:
%{!?__pear: %global __pear /usr/bin/pear} (untested)

Additionally, the BR on php-pear should be bumped from >= 1:1.4.9 to >=
1:1.4.9-4 in order to explicitly require one which is known to contain rest of
the required macro definitions.
Comment 14 Christopher Stone 2006-09-03 20:22:18 EDT
Created attachment 135472 [details]
New Template with __pear defined

Okay, here is a new version that has that fixed.
Comment 15 Christopher Stone 2006-09-03 20:34:01 EDT
Tested under mock and works.  I forgot to bump the version number, so can you do
this manually before checking it into cvs?
Comment 16 Christopher Stone 2006-09-03 20:52:21 EDT
Actually Ville, the version number should be php-pear-1.4.9-1.2 since this is
what it currently is on FC5.
Comment 17 Ville Skyttä 2006-09-04 12:22:16 EDT
Done, with the small changes I still insist on (at least as long as there's no
designated co-maintainer who will look after the PHP stuff in rpmdevtools): 
%build section, explicit removal of "docdir" at start of %install, whitespace
http://cvs.fedora.redhat.com/viewcvs/fedora-rpmdevtools/?root=fedora&sortby=date

By the way, the 'Unpacking "package.xml" to the top-level build dir is not nice'
issue from comment 3 is still unaddressed, as is the potential cosmetic addition
of trailing '/'s to things in %files that are dirs.  Comments?
Comment 18 Christopher Stone 2006-09-04 16:32:42 EDT
Instead of using -c and cp, what if we just do something like:
%prep
%setup -q -n MDB2-%{version}
mv ../package.xml ./%{name}-%{version}.xml

If you insist on adding an empty %build, then I think there should be a comment
above the %build indicating why it is there and empty.

Adding / to the directories does not highlight correctly under vim.  Shouldn't
the syntax highlighting be modified if this is how direcotories are preferred to
be indicated?
Comment 19 Ville Skyttä 2006-09-04 17:27:52 EDT
(In reply to comment #18)
> Instead of using -c and cp, what if we just do something like:
> %prep
> %setup -q -n MDB2-%{version}
> mv ../package.xml ./%{name}-%{version}.xml

The problem is that package.xml ends up in "..", eg.
$HOME/rpmbuild/BUILD/package.xml instead of
$HOME/rpmbuild/BUILD/MDB2-%{version}/package.xml when %setup unpacks the tarball
- the above would not help, %setup -c would.

> Adding / to the directories does not highlight correctly under vim.  Shouldn't
> the syntax highlighting be modified if this is how direcotories are preferred
> to be indicated?

I know nothing about vim's support for specfile highlighting, but adding
trailing /'s to the %files section didn't seem to change the highlighting at all
here.  Either way, this is not really an issue, just a personal preference.
Comment 20 Remi Collet 2006-09-05 14:43:40 EDT
> The problem is that package.xml ends up in ".."

Must agree.
Another problem is that newest packages use package2.xml (even if package.xml
still present).

What about this ?

%prep
%setup -q -n Log-%{version}
if tar xf %{SOURCE0} package2.xml
then	mv package2.xml Log.xml
elif tar xf %{SOURCE0} package.xml
then	mv package.xml Log.xml
else	echo XML file not found
	exit 1
fi
...

%install
rm -rf %{buildroot} docdir
%{__pear} install --nodeps --packagingroot %{buildroot} Log.xml
...

%{__install} -pm 644 Log.xml %{buildroot}%{pear_xmldir}

Comment 21 Christopher Stone 2006-09-05 15:02:00 EDT
Is there a standard defined on what the xml package is named?  I was
unaware that some packages use package2.xml
Comment 22 Ville Skyttä 2006-09-05 15:24:21 EDT
Or maybe something simpler like this in %prep and always use package2.xml later
during build: [ -f package2.xml ] || mv package.xml package2.xml
Comment 23 Christopher Stone 2006-09-06 01:08:07 EDT
How about:

tar xf %{SOURCE0} -O package*.xml > %{name}.xml
Comment 24 Remi Collet 2006-09-06 01:17:20 EDT
More information about package.xml (version 1.0) and package2.xml (version 2.0)
can be found at http://pear.php.net/manual/en/guide.developers.package2.php

"pear makerpm" auto detect which file must be use (using the
package@package2xml@.xml macro in the template).
Comment 25 Christopher Stone 2006-09-06 01:33:27 EDT
Created attachment 135621 [details]
Update to CVS version 1.3

This patch is against cvs version 1.3.	It adds a comment to the %build so
users will not get confused wondering if they should put something in there,
and adds the new tar method for extracting the package file.
Comment 26 Remi Collet 2006-09-06 01:36:29 EDT
> tar xf %{SOURCE0} -O package*.xml > %{name}.xml

When package2.xml is present, old package.xml also here.
This merge the 2 files. Not a good thing.
Comment 27 Christopher Stone 2006-09-06 01:44:17 EDT
Oh geez why do they do that?
Comment 28 Christopher Stone 2006-09-06 01:49:21 EDT
If version one is always going to be there, then why dont we just use:

tar xf %{SOURCE0} -O package.xml > Foo_Bar.xml

Is there any reason why we should use version 2?
Comment 29 Christopher Stone 2006-09-06 02:12:00 EDT
Created attachment 135622 [details]
New patch incorporating latest comments

Okay, here is try #2 for a patch against the CVS.  This basically goes back to
Ville's original idea of using -c.
Comment 30 Christopher Stone 2006-09-06 02:17:13 EDT
Also, I guess the cd should come before the rm in the %build section.  Ville,
can you modify that by hand when you check this into CVS?
Comment 31 Remi Collet 2006-09-06 10:54:42 EDT
> Is there any reason why we should use version 2?

We should use package2.xml which is designed for laster pear installer release
and is more robust (md5sum included, for example). package.xml is still provided
to allow installation by (very) older pear release.

> [ -f package2.xml ] || mv package.xml package2.xml
> mv package2.xml Foo_Bar-%{version}/Foo_Bar.xml

I think you mean :
> [ -f package2.xml ] || mv package2.xml package.xml
> mv package.xml Foo_Bar-%{version}/Foo_Bar.xml

And I will prefer
[ -f package2.xml ] && \
  mv package2.xml Foo_Bar-%{version}/Foo_Bar.xml || \
  mv package.xml  Foo_Bar-%{version}/Foo_Bar.xml

And, of course :
cd Foo_Bar-%{version}
rm -rf $RPM_BUILD_ROOT docdir
%{__pear} install --nodeps --packagingroot $RPM_BUILD_ROOT Foo_Bar.xml
Comment 32 Remi Collet 2006-09-06 11:03:11 EDT
What about using a macro to define the "class name" (Foo_bar) ?

%define ClassName   Foo_Bar
%define PackageName Foo-Bar
...
Name:           php-pear-%{PackageName}
...
Provides:       php-pear(%{ClassName}) = %{version}
...
%prep
%setup -q -c -n %{ClassName}-%{version}
[ -f package2.xml ] && \
  mv package2.xml %{ClassName}-%{version}/%{ClassName}.xml || \
  mv package.xml  %{ClassName}-%{version}/%{ClassName}.xml

and so on.



Comment 33 Ville Skyttä 2006-09-06 12:13:09 EDT
I think the idea in comment 32 has some merit -- the fewer times Foo_Bar and
friends occur in the specfile, the better, that way the specfiles between
packages differ less and the template is somewhat easier to use without
rpmdev-newspec (if someone wants to use it that way for whatever reason).

BTW, if -c is used in %setup, there should be no reason to use -n there, patch
from comment 29 applied to CVS as 1.4 with that change and the one from comment
30 (done in both %build and %install for consistency).

I think CVS rev 1.4 looks pretty ok already, but if you think something should
be changed, keep the patches coming.
Comment 34 Christopher Stone 2006-09-06 13:35:58 EDT
Ville if you want to add:

%define ClassName   Foo_Bar

and replace all Foo_Bar's with %{ClassName} that is fine by me too.  I agree it
is a good idea.

Otherwise everything looks okay.  When can we expect a new release?
Comment 35 Christopher Stone 2006-09-06 13:43:50 EDT
Keep in mind,

%{pear_phpdir}/Foo_Bar.php

Must remain the same in order for the following substitution to take place:

s|^\\(%{pear_phpdir}/\\)$pearname\\(.php\\)|\1$peardirpath\2|

Comment 36 Christopher Stone 2006-09-06 17:07:47 EDT
Created attachment 135697 [details]
Latest Patch with %{ClassName}

This is the %{ClassName} patch.  I also added a cd in the %setup section.
Comment 37 Remi Collet 2006-09-06 17:18:26 EDT
Hi

I worked a little on the "template.spec" used by pear to be as close as possible
of this one.

You can have a look at
http://remi.collet.free.fr/rpms/SPEC/php-pear-1.4.11-template.spec

Or even try new it with
http://remi.collet.free.fr/rpms/fc5.i386/php-pear-1.4.11-2.fc5.remi.noarch.rpm

I will file a bug (a RFE) on php-pear core package to include it.
By this way, "pear makerpm" will produce "Extras" ready specfiles.

Next is to wait on php-pear-PEAR-Command-Packaging (bugzilla #185423).
Comment 38 Christopher Stone 2006-09-06 21:29:25 EDT
Created attachment 135708 [details]
Forgot one

Forgot one.
Comment 39 Ville Skyttä 2006-09-08 13:33:23 EDT
Cosmetic note: camelcase %{ClassName} looks unfamiliar in specfiles, I'd use
something like %{pear_name} instead.  Objections?

After the latest patches, there are still these (unmacroized) in %files:
  %{pear_phpdir}/Foo
  %{pear_phpdir}/Foo_Bar.php

Could those be replaced by just this?
  %{pear_phpdir}/*
Comment 40 Ville Skyttä 2006-09-08 13:37:54 EDT
Oh, I missed comment 35.  Anyway, using %{pear_phpdir}/* would allow simplifying
rpmdev-newspec too - needinfo for comment 39 still holds...
Comment 41 Christopher Stone 2006-09-08 13:59:29 EDT
The reason I added those was because in some cases you don't want the package to
own the top level directory.  Like an XML package such as XML_Parser should not
own /usr/share/pear/XML directory since this is clearly owned by php-pear.

However, I see little harm in allowing this because most pear packages behave
this  way anyway (directory ownership is mostly unclear.)  If XML_Parser does
own the XML directory it wont harm anything AFAIK.

So basically the reason I added the top level directory to the spec was for the
purpose of allowing the packager to specify which (if any) directories the
package should own.  However I don't see any harm in allowing all pear packages
to own all the directories.

Comments?
Comment 42 Ville Skyttä 2006-09-09 05:25:22 EDT
Good point.  The guidelines pretty strongly advice against dir ownership bloat,
so I think we should try to steer away from it in the template.

However, I think adding a comment and still using the "*" approach could be the
best way to go; that's basically how it's done in the other templates too
(although perl is a bit different; due to versioned dirs and a mixture of them
being a valid setup, multiply owned dirs are a necessity there).

I mean something like this:
   # Expand this as needed to avoid owning dirs owned by our dependencies
   %{pear_phpdir}/*

This would make the intention more clear (for example, I missed it from the
current implementation) and still allow the simplifications.  If you're fine
with this, I'll commit it and the latest patches (with s/ClassName/pear_name/).

Maybe the ruby and python spec templates should have a similar comment, but OTOH
I believe reusing some of the install dirs in a way similar to perl and pear is
much less common (practically nonexistent?) with them.
Comment 43 Christopher Stone 2006-09-09 11:57:05 EDT
I have no objections to comment #42.
Comment 44 Ville Skyttä 2006-09-09 13:08:41 EDT
Ok, done.  5.1 release candidate packages are at
http://koti.welho.com/vskytta/tmp/ , please test.  Unless something still needs
changing, I'm planning to release these early next week.
Comment 45 Ville Skyttä 2006-09-12 17:08:54 EDT
5.1-1 just finished building for FC5 and devel, it'll hit the repos in the next
push.  Thanks!

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