Bug 872737 - brp-java-repack-jars fails on jar names with spaces
Summary: brp-java-repack-jars fails on jar names with spaces
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: redhat-rpm-config
Version: 17
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Panu Matilainen
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-11-02 20:44 UTC by Jerry James
Modified: 2012-12-20 15:15 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-12-20 15:15:13 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Candidate patch to fix the problem (2.18 KB, patch)
2012-11-02 20:44 UTC, Jerry James
no flags Details | Diff
Alternate fix that avoids bash-specifics (2.05 KB, patch)
2012-11-09 19:34 UTC, Toshio Ernie Kuratomi
no flags Details | Diff

Description Jerry James 2012-11-02 20:44:46 UTC
Created attachment 637242 [details]
Candidate patch to fix the problem

Description of problem:
I'm attempting to package JHotDraw, which produces jars with names such as "JHotDraw Draw.jar", "JHotDraw Teddy.jar", and "JHotDraw SVG.jar".  The output from rpmbuild shows that brp-java-repack-jars is not handling the spaces well:

+ /usr/lib/rpm/redhat/brp-java-repack-jars
unzip:  cannot find or open /home/jamesjer/rpmbuild/BUILDROOT/jhotdraw-7.6-1.fc17.x86_64/usr/share/java/JHotDraw, /home/jamesjer/rpmbuild/BUILDROOT/jhotdraw-7.6-1.fc17.x86_64/usr/share/java/JHotDraw.zip or /home/jamesjer/rpmbuild/BUILDROOT/jhotdraw-7.6-1.fc17.x86_64/usr/share/java/JHotDraw.ZIP.
unzip:  cannot find or open Draw.jar, Draw.jar.zip or Draw.jar.ZIP.
[/home/jamesjer/rpmbuild/BUILDROOT/jhotdraw-7.6-1.fc17.x86_64/usr/share/java/JHotDraw]
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of /home/jamesjer/rpmbuild/BUILDROOT/jhotdraw-7.6-1.fc17.x86_64/usr/share/java/JHotDraw or
        /home/jamesjer/rpmbuild/BUILDROOT/jhotdraw-7.6-1.fc17.x86_64/usr/share/java/JHotDraw.zip, and cannot find /home/jamesjer/rpmbuild/BUILDROOT/jhotdraw-7.6-1.fc17.x86_64/usr/share/java/JHotDraw.ZIP, period.
unzip:  cannot find or open Teddy.jar, Teddy.jar.zip or Teddy.jar.ZIP.
[/home/jamesjer/rpmbuild/BUILDROOT/jhotdraw-7.6-1.fc17.x86_64/usr/share/java/JHotDraw]
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.

The RPM is still produced successfully, even though the JARs are not repacked.

Version-Release number of selected component (if applicable):
redhat-rpm-config-9.1.0-28.fc17.noarch

How reproducible:
Always

Steps to Reproduce:
1. Build a Java package that produces a JAR with a space in its name
2.
3.
  
Actual results:
brp-java-repack-jars breaks the name at the space and tries to repack the two parts, neither of which is a valid filename.

Expected results:
brp-java-repack-jars should quote its arguments sufficiently to avoid this problem

Additional info:
I have attached a patch that shows one way in which the problem could be addressed.  It makes the script be bash-specific, but given its limited field of use (RPM builds), I don't think that is really a problem.

Comment 1 Toshio Ernie Kuratomi 2012-11-09 19:34:32 UTC
Created attachment 641786 [details]
Alternate fix that avoids bash-specifics

I've not concentrated on honing my shell scripting skills in many, many years so I could be missing something but I think I got this right.  Would this patch work and avoid bash specifics?

Caveats:
* It only fixes embedded spaces.  Your patch handles newlines and tabs as well.  Is this a problem, though?
* Untested -- I figure you have an srpm to try it out on and I'd have to create one from scratch :-)

Notes:
* This patch also double quotes one instance of $j that wasn't caught in yours.
* This patch applies on top of the current patchset in the srpm (which has added one patch to brp-java-repack-jars recently).

Comment 2 Jerry James 2012-11-09 21:04:19 UTC
(In reply to comment #1)
> I've not concentrated on honing my shell scripting skills in many, many
> years so I could be missing something but I think I got this right.  Would
> this patch work and avoid bash specifics?

Yes, this is great.  I tried playing with IFS first and couldn't figure out how to get the right characters into it.  Using printf never occurred to me.  I like it.

> Caveats:
> * It only fixes embedded spaces.  Your patch handles newlines and tabs as
> well.  Is this a problem, though?

If we ever encounter a filename with embedded newlines or tabs, let's just shoot the developer who thought that was a good idea.

> * Untested -- I figure you have an srpm to try it out on and I'd have to
> create one from scratch :-)

Yes, and your patch worked well.  Consider it tested.

Comment 3 Fedora Update System 2012-11-09 22:48:52 UTC
redhat-rpm-config-9.1.0-37.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/redhat-rpm-config-9.1.0-37.fc18

Comment 4 Fedora Update System 2012-11-10 19:40:59 UTC
Package redhat-rpm-config-9.1.0-37.fc18:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing redhat-rpm-config-9.1.0-37.fc18'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-17945/redhat-rpm-config-9.1.0-37.fc18
then log in and leave karma (feedback).

Comment 5 Fedora Update System 2012-12-20 15:15:15 UTC
redhat-rpm-config-9.1.0-37.fc18 has been pushed to the Fedora 18 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.