Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 198706 - php-pear spec template
Summary: php-pear spec template
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: fedora-rpmdevtools
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Ville Skyttä
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-07-12 23:24 UTC by Christopher Stone
Modified: 2007-11-30 22:11 UTC (History)
4 users (show)

Fixed In Version: 5.1-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-09-12 21:08:54 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
The patch (deleted)
2006-07-12 23:24 UTC, Christopher Stone
no flags Details | Diff
The template (deleted)
2006-07-12 23:25 UTC, Christopher Stone
no flags Details
Patch eliminating need of macros.pear stuff (deleted)
2006-07-18 17:38 UTC, Ville Skyttä
no flags Details | Diff
The "unmacroize" changes against the original submitted template (deleted)
2006-07-20 19:35 UTC, Ville Skyttä
no flags Details | Diff
Changes between the submitted and the first committed one (deleted)
2006-07-20 19:37 UTC, Ville Skyttä
no flags Details | Diff
New Template Incorporating some of Ville's changes (deleted)
2006-09-03 04:00 UTC, Christopher Stone
no flags Details | Diff
Patch to fix Requires (deleted)
2006-09-03 04:25 UTC, Christopher Stone
no flags Details | Diff
New Template with __pear defined (deleted)
2006-09-04 00:22 UTC, Christopher Stone
no flags Details | Diff
Update to CVS version 1.3 (deleted)
2006-09-06 05:33 UTC, Christopher Stone
no flags Details | Diff
New patch incorporating latest comments (deleted)
2006-09-06 06:12 UTC, Christopher Stone
no flags Details | Diff
Latest Patch with %{ClassName} (deleted)
2006-09-06 21:07 UTC, Christopher Stone
no flags Details | Diff
Forgot one (deleted)
2006-09-07 01:29 UTC, Christopher Stone
no flags Details | Diff

Description Christopher Stone 2006-07-12 23:24:51 UTC
Here is the php-pear-* spec template stuff

Comment 1 Christopher Stone 2006-07-12 23:24:51 UTC
Created attachment 132340 [details]
The patch

Comment 2 Christopher Stone 2006-07-12 23:25:22 UTC
Created attachment 132341 [details]
The template

Comment 3 Ville Skyttä 2006-07-18 17:04:02 UTC
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 17:38:10 UTC
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 17:40:14 UTC
Even better if %post would instead of '-d "$xmldir"' check for '-f
"$xmldir/Foo_Bar.xml"'

Comment 6 Christopher Stone 2006-07-20 05:31:16 UTC
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 19:35:01 UTC
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.redhat.com:/cvs/fedora

Comment 8 Ville Skyttä 2006-07-20 19:37:13 UTC
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 23:40:03 UTC
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 07:04:23 UTC
(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 04:00:51 UTC
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 04:25:20 UTC
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 09:04:30 UTC
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-04 00:22:18 UTC
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-04 00:34:01 UTC
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-04 00:52:21 UTC
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 16:22:16 UTC
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 20:32:42 UTC
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 21:27:52 UTC
(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 18:43:40 UTC
> 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 19:02:00 UTC
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 19:24:21 UTC
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 05:08:07 UTC
How about:

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

Comment 24 Remi Collet 2006-09-06 05:17:20 UTC
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 05:33:27 UTC
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 05:36:29 UTC
> 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 05:44:17 UTC
Oh geez why do they do that?

Comment 28 Christopher Stone 2006-09-06 05:49:21 UTC
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 06:12:00 UTC
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 06:17:13 UTC
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 14:54:42 UTC
> 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 15:03:11 UTC
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 16:13:09 UTC
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 17:35:58 UTC
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 17:43:50 UTC
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 21:07:47 UTC
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 21:18:26 UTC
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-07 01:29:25 UTC
Created attachment 135708 [details]
Forgot one

Forgot one.

Comment 39 Ville Skyttä 2006-09-08 17:33:23 UTC
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 17:37:54 UTC
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 17:59:29 UTC
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 09:25:22 UTC
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 15:57:05 UTC
I have no objections to comment #42.

Comment 44 Ville Skyttä 2006-09-09 17:08:41 UTC
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 21:08:54 UTC
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.