fix(Archive::Zip): add extractToFileNamed and honor Perl chdir for jcpan -t MP3::Tag#594
Merged
fix(Archive::Zip): add extractToFileNamed and honor Perl chdir for jcpan -t MP3::Tag#594
Conversation
Two issues prevented `jcpan -t MP3::Tag` (and any zip-distributed CPAN module) from being unpacked by CPAN::Tarzip::unzip: 1. Archive::Zip::Member::extractToFileNamed was not implemented, so CPAN::Tarzip::unzip died with "Can't locate object method extractToFileNamed". CPAN reported "Had problems unarchiving." 2. The extraction methods used Paths.get(name) directly, which resolves relative paths against the JVM's working directory. PerlOnJava's chdir only updates System "user.dir", not the JVM cwd, so files were being written to the launch directory instead of the build tmp-$$ directory CPAN had chdir'd into. The build dir ended up empty and CPAN proceeded as if the package had no Makefile.PL. Add a resolvePath helper that resolves relative paths against "user.dir" and use it in extractMember, extractMemberWithoutPaths, extractTree, extractToFileNamed, addFile, read, and writeToFileNamed. After this fix `jcpan -t MP3::Tag` actually configures, builds, and runs the test suite. Some tests still fail due to unrelated regex lookbehind limits and a separate NPE in string handling, but the distribution is no longer dead-on-arrival. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
54402df to
16ccbdb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
jcpan -t MP3::Tag(and any zip-distributed CPAN module) failing withHad problems unarchiving. Please build manually.Two bugs in
Archive::Zip:extractToFileNamed— CPAN'sCPAN::Tarzip::unzipcalls$member->extractToFileNamed($af)for each archive member. PerlOnJava'sArchive::Zip::Memberdid not implement this method, so unzip died and CPAN bailed out before the source was extracted.chdir— Extraction methods usedPaths.get(name)directly. Java resolves relative paths against the JVM'suser.dirfield, while PerlOnJavachdironly updates theuser.dirsystem property. CPANchdirs into a freshtmp-$$directory before unzipping, so files were silently being written to the launch directory and CPAN saw an empty build dir.Added
resolvePath()helper that resolves relative paths againstSystem.getProperty("user.dir"), and applied it inextractMember,extractMemberWithoutPaths,extractTree, the newextractToFileNamed,addFile,read, andwriteToFileNamed.After this fix,
jcpan -t MP3::Tagconfigures, builds, and runs the full test suite (Files=6, Tests=390). The remaining MP3::Tag test failures are pre-existing PerlOnJava limitations (regex lookbehind > 255, a separate NPE in some string handling) and out of scope here.Test plan
make(full unit test suite) passesjcpan -t MP3::Tagno longer reports "Had problems unarchiving";t/interpolate.t,t/parser.t,t/update_tags.t,t/v2_comments.tnow pass~/.cpan/build/ILYAZ-*/now contains the actual unpacked sourcesGenerated with Devin