Archive-Tar-Wrapper-0.42/ 000755 000766 000024 00000000000 14664064025 015453 5 ustar 00gknop staff 000000 000000 Archive-Tar-Wrapper-0.42/LICENSE 000644 000766 000024 00000104741 14664064025 016467 0 ustar 00gknop staff 000000 000000 This software is Copyright (c) 2024 by Mike Schilli.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
Archive-Tar-Wrapper-0.42/Changes 000644 000766 000024 00000021107 14664064025 016747 0 ustar 00gknop staff 000000 000000 Revision history for Perl extension Archive::Tar::Wrapper
0.42 2024-08-29
- Pod formatting improvements
- Packaging updates
- Add missing changelog entries
- Removed outdated maintainer information
0.41 2024-06-10
- Improve various test diagnostic messages
0.40 2024-05-08
- Always output basic diagnostics data during testing
0.39 2024-04-16
- Added Dumbbench to prerequisites
- Add implementation for Solaris
- Skip testing permissions on 'msys' Windows builds
0.38 2020-08-09
- Fixed issue 17
https://github.com/glasswalk3r/archive-tar-wrapper-perl/issues/17
- The fixes were only related to different licenses over the files of the
distribution.
- Small fixes over the documentation as well.
- No changes to the code. :-)
0.37 2019-08-24
- Fixed issue 14
https://github.com/glasswalk3r/archive-tar-wrapper-perl/issues/14
0.36 2019/04/11
- Bug fixes since tests on Windows were failing after latests changes.
- Refactored code due unexpected way bsdtar on Windows and tar on OpenBSD
behave.
- Refactored the tests due the bugs found.
- Small fixes on Pod, specially the section for MS Windows users.
- Added the missing tests to the MANIFEST.
0.35 2019-04-05
- Added _rem_dots method, a improved way to remove '.' and '..' from
readdir(), supposed to be faster than previous implementation with sort()
and shift().
- Added two more tests to increase testing coverage.
- Fixed a small bug regarding Pod, that now covers 100% of the code.
- Small fixes to documentation.
0.34 2019-03-22
- Increased test coverage.
- Refactored code to make it easier for testing.
- Disabled performance-small.t for now.
- Refactored bzip2 tests.
- Adding META.yml "provides" from Makefile.PL
- Covered methods that didn't have Pod.
- Refactored all Pod following best practices.
- Refactored a single method to be "private".
- Slightly changed new() to enable unit testing for OS specific
configurations.
0.33 2018-07-10
- Skipping bzip2 testing if the program is not available
(https://github.com/glasswalk3r/archive-tar-wrapper-perl/issues/11).
- Undeclared dependency of Dumbbench
(https://github.com/glasswalk3r/archive-tar-wrapper-perl/issues/12).
0.32 2018-07-10
- Typo fixed by Mohammad S Anwar
(https://github.com/glasswalk3r/archive-tar-wrapper-perl/pull/10).
- Refactored performance tests, and now they will run as TODO to test the
hypotesis that there is a better algorithm to write() method.
0.31 2018-07-03
- Enabled performance testing to acquire from different setups which scheme
is faster to remove dots when reading directories.
- Disabled Solaris OS until issues are fixed.
- Fixed bug introduced in Makefile.PL due changes of release 0.30 (thanks to
David Cantrell ).
- Updated documentation.
0.30 2018-06-28
- Keeping track of changes per request
https://github.com/glasswalk3r/archive-tar-wrapper-perl/issues/7.
- Fixing proper handling of File::Which when checking on Microsoft Windows.
- Refactored troubleshooting messages on Microsoft Windows.
- Bug fixes provided by Shoichi Kaji (skaji at cpan.org) in PRs
https://github.com/glasswalk3r/archive-tar-wrapper-perl/pull/9
and https://github.com/glasswalk3r/archive-tar-wrapper-perl/pull/8
0.29 2018-06-25
- Added Microsoft Windows support with the help of Ingram Braun M.A.
.
0.28 2018-06-19
- Moving Test::Simple dependency to TEST_REQUIRES per issue
https://github.com/glasswalk3r/archive-tar-wrapper-perl/issues/6.
- Removed the README (completely replaced by README.md).
- Fixed licensing declaration per
https://github.com/glasswalk3r/archive-tar-wrapper-perl/issues/5.
- Refactored more debugging messages with proper use of Log::Log4perl.
- Applied the usage of Test::More is_deeply() whenever possible to improve
tests results in case of errors.
- Small refactorings.
0.27 2018-06-15
- Added Test::Simple 1.302073 as minimum version required to be able to use
is_deeply().
- Getting a logger from Log::Log4perl to be able to improve performance by
avoiding doing expensive string concatenation unless the log level allows
it.
- Reverted changes on list_reset() to go back reading and printing each line
recovered instead of keeping it in memory, instead of following PBP.
- Refactored t/001Basic.t by following PBP, using three arguments for open()
and adding note() to include more information.
0.26 2018-06-09
- Implemented refactoring due warnings from Perl::Critic.
0.25 2018-06-04
- Implemented refactoring due warnings from Perl::Critic.
- Merge pull request #3 from manwar/suggest-code-tidy
0.24 2018-06-02
- Added a LICENSE file (GNU GPL v3).
- Removed MYMETA files (https://rt.cpan.org/Ticket/Display.html?id=108171).
- Improved Kwalitee by adding information to Makefile.PL
- Fixed tests under OpenBSD
- Added some code to check for OpenBSD tar, which is not quite compatible to
the command line options passed by this module.
- Also made the method is_gnu() more robust, testing the return code and
properly handling STDOUT and STDERR when trying "tar --version".
Dependencies added are those already available on standard perl (Config and
IPC::Open3).
- Added a README.md for better formatting in Github project page.
- Small refactorings and code formating with perltidy.
0.23 2015-05-28
- (ms) Mark Gardner added separate skips in the test suite to deal
with the absense of GNU tar:
https://github.com/mschilli/archive-tar-wrapper-perl/pull/7
0.22 2015-03-08
- (ms) Added tar_gnu_write_options option suggested by Csaba Major with
tests and docs.
0.21 2014-10-16
- (ms) [rt.cpan.org 87536] Setting default umask to get predictable test
results regardless of local umask settings.
0.20 2014-09-29
- (ms) Ignore errors on chown/chgrp when files from different owners/groups
are copied into a tarball, accept the limitation that they'll be
owned by the script user unless we're running as superuser.
0.19 2014-02-16
- (ms) RsrchBoy added support for bzip2-compressed tarfiles.
0.18 2013-07-15
- (ms) Moved to tmpdir() in t/002Mult.t because some smoke testers don't
like writing into t/data.
0.17 2013-07-01
- (ms) Sanko Robinson replaced bin_find() by File::Which::which() to allow
for better Win32 portability.
0.16 2012-03-19
- (ms) [rt.cpan.org 75770] Allow add() with directories, and now preserves
directory permissions.
0.15 2011-12-20
- (ms) [RT 73046] Randy Stauner submitted a patch to reset the directory if a
write() fails (e.g. because no files have been added).
https://github.com/mschilli/archive-tar-wrapper-perl/pull/1
0.14 2011-02-12
- (ms) Added 'ramdisk' feature for Linux
- (ms) More search paths for 'tar'
0.13 2010-02-01
- (ms) Added GNU tar check is_gnu()
- (ms) Added tar_gnu_read_options to specify options like --numeric-owner
0.12 2008-07-03
- (ms) Applied modified patch by Daniel Barthel to enable more
files added to a tarball than there are allowed on the command
line.
0.11 2008-03-09
- (ms) Skipping one test case for FreeBSD's tar, which does not complain
if asked to extract non-existent files.
0.10 2007-07-21
- (ms) Skipping unicode tests for perl < 5.8
0.09 2007-07-20
- (ms) Added utf8 support in add($dataref)
- (ms) Fixed bug in add($ref) for adding string data,
patch submitted by Karthik Joshi.
- (ms) Changed tempfile CLEANUP to UNLINK in test suite
0.08 2006-08-21
- (ms) Added tardir() method to obtain the directory the tarball was
unpacked in.
0.07 2006-04-02
- (ms) Fixed list_all() to return a ref to an array of arrayrefs, as
explained in the docs.
- (ms) Added "dirs" option to list directories as well.
0.06 2005-09-22
- (ms) Fixed logging message in tar->read().
- (ms) Additional options can be passed to tar (tar_read/write_options)
- (ms) failed read() no longer chdirs out of the current directory
- (ms) Fixed test suite for different umasks
0.05 2005-09-10
- (ms) 'tar' is now running via IPC::Run
- (ms) read() takes an optional list of files to save space
in case only a limited number of files is needed from the
tarball.
0.04 2005-07-24
- (ms) Added eg/tarflat and more test cases
0.03 2005-05-23
- (ms) tarup() no longer uses "." as a directory, but globs for all
top-level entries
- (ms) critical fix for location of tarred files
- (ms) tmp dir cleanup now handled manually to avoid
File::Temp warnings
0.02 2005-04-20
- (ms) Added lots of documentation.
0.01 2005-04-10
- (ms) Where it all began.
Archive-Tar-Wrapper-0.42/prereqs.yml 000644 000766 000024 00000000321 14664064025 017653 0 ustar 00gknop staff 000000 000000 configure:
requires:
File::Which: 0
runtime:
requires:
perl: '5.008001'
Cwd: 0
File::Temp: 0
File::Which: 0
IPC::Run: 0
Log::Log4perl: 0
develop:
requires:
Dumbbench: 0
Archive-Tar-Wrapper-0.42/MANIFEST 000644 000766 000024 00000001610 14664064025 016602 0 ustar 00gknop staff 000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.032.
.perlcriticrc
CONTRIBUTING.md
Changes
LICENSE
MANIFEST
MANIFEST.SKIP
META.json
META.yml
Makefile.PL
README
dist.ini
eg/tarflat
lib/Archive/Tar/Wrapper.pm
prereqs.yml
t/00-compile.t
t/00-report-prereqs.dd
t/00-report-prereqs.t
t/001Basic.t
t/002Mult.t
t/003Dirs.t
t/004Utf8.t
t/005Cwd.t
t/006DirPerms.t
t/007bzip.t
t/009compressed.t
t/010openbsd.t
t/011remdots.t
t/012tarinfo.t
t/data/bar.tar
t/data/foo.tar.bz2
t/data/foo.tgz
weaver.ini
xt/author/cpan-changes.t
xt/author/critic.t
xt/author/distmeta.t
xt/author/eol.t
xt/author/kwalitee.t
xt/author/minimum-version.t
xt/author/mojibake.t
xt/author/no-tabs.t
xt/author/pod-coverage.t
xt/author/pod-spell.t
xt/author/pod-syntax.t
xt/author/portability.t
xt/author/test-version.t
xt/lib/ATWDumbbench.pm
xt/performance-small.t
xt/performance.t
xt/release/changes_has_content.t
Archive-Tar-Wrapper-0.42/t/ 000755 000766 000024 00000000000 14664064025 015716 5 ustar 00gknop staff 000000 000000 Archive-Tar-Wrapper-0.42/xt/ 000755 000766 000024 00000000000 14664064025 016106 5 ustar 00gknop staff 000000 000000 Archive-Tar-Wrapper-0.42/README 000644 000766 000024 00000040523 14664064025 016337 0 ustar 00gknop staff 000000 000000 NAME
Archive::Tar::Wrapper - API wrapper around the 'tar' utility
SYNOPSIS
use Archive::Tar::Wrapper;
my $arch = Archive::Tar::Wrapper->new();
# Open a tarball, expand it into a temporary directory
$arch->read("archive.tgz");
# Iterate over all entries in the archive
$arch->list_reset(); # Reset Iterator
# Iterate through archive
while(my $entry = $arch->list_next()) {
my($tar_path, $phys_path) = @$entry;
print "$tar_path\n";
}
# Get a huge list with all entries
for my $entry (@{$arch->list_all()}) {
my($tar_path, $real_path) = @$entry;
print "Tarpath: $tar_path Tempfile: $real_path\n";
}
# Add a new entry
$arch->add($logic_path, $file_or_stringref);
# Remove an entry
$arch->remove($logic_path);
# Find the physical location of a temporary file
my($tmp_path) = $arch->locate($tar_path);
# Create a tarball
$arch->write($tarfile, $compress);
DESCRIPTION
Archive::Tar::Wrapper is an API wrapper around the "tar" command line
program. It never stores anything in memory, but works on temporary
directory structures on disk instead. It provides a mapping between the
logical paths in the tarball and the 'real' files in the temporary
directory on disk.
It differs from Archive::Tar in two ways:
* Archive::Tar::Wrapper almost doesn't hold anything in memory (see
"write" method), instead using disk as storage.
* Archive::Tar::Wrapper is 100% compliant with the platform's "tar"
utility because it uses it internally.
METHODS
new
my $arch = Archive::Tar::Wrapper->new();
Constructor for the "tar" wrapper class. Finds the "tar" executable by
searching "PATH" and returning the first hit. In case you want to use a
different tar executable, you can specify it as a parameter:
my $arch = Archive::Tar::Wrapper->new(tar => '/path/to/tar');
Since Archive::Tar::Wrapper creates temporary directories to store "tar"
data, the location of the temporary directory can be specified:
my $arch = Archive::Tar::Wrapper->new(tmpdir => '/path/to/tmpdir');
Tremendous performance increases can be achieved if the temporary
directory is located on a RAM disk. Check the "Using RAM Disks" in
Archive::Tar::Wrapper section for details.
Additional options can be passed to the "tar" command by using the
"tar_read_options" and "tar_write_options" parameters. Example:
my $arch = Archive::Tar::Wrapper->new(
tar_read_options => 'p'
);
will use "tar xfp archive.tgz" to extract the tarball instead of just
"tar xf archive.tgz". GNU tar supports even more options, these can be
passed in via
my $arch = Archive::Tar::Wrapper->new(
tar_gnu_read_options => ["--numeric-owner"],
);
Similarly, "tar_gnu_write_options" can be used to provide additional
options for GNU tar implementations. For example, the tar object
my $tar = Archive::Tar::Wrapper->new(
tar_gnu_write_options => ["--exclude=foo"],
);
will call the "tar" utility internally like
tar cf tarfile --exclude=foo ...
when the "write" method gets called.
By default, the "list_*()" functions will return only file entries:
directories will be suppressed. To have "list_*()" return directories as
well, use
my $arch = Archive::Tar::Wrapper->new(
dirs => 1
);
If more files are added to a tarball than the command line can handle,
Archive::Tar::Wrapper will switch from using the command
tar cfv tarfile file1 file2 file3 ...
to
tar cfv tarfile -T filelist
where "filelist" is a file containing all file to be added. The default
for this switch is 512, but it can be changed by setting the parameter
"max_cmd_line_args":
my $arch = Archive::Tar::Wrapper->new(
max_cmd_line_args => 1024
);
The allowable parameters are:
* "tar"
* "tmpdir"
* "tar_read_options"
* "tar_write_options"
* "tar_gnu_read_options"
* "tar_gnu_write_options"
* "max_cmd_line_args": defaults to 512
* "ramdisk"
Returns a new instance of the class.
read
$arch->read("archive.tgz");
read() opens the given tarball, expands it into a temporary directory
and returns 1 on success or "undef" on failure. The temporary directory
holding the tar data gets cleaned up when $arch goes out of scope.
"read" handles both compressed and uncompressed files. To find out if a
file is compressed or uncompressed, it tries to guess by extension, then
by checking the first couple of bytes in the tar file.
If only a limited number of files is needed from a tarball, they can be
specified after the tarball name:
$arch->read("archive.tgz", "path/file.dat", "path/sub/another.txt");
The file names are passed unmodified to the "tar" command, make sure
that the file paths match exactly what's in the tarball, otherwise
read() will fail.
list_reset
$arch->list_reset()
Resets the list iterator. To be used before the first call to
list_next().
tardir
$arch->tardir();
Return the directory the tarball was unpacked in. This is sometimes
useful to play dirty tricks on Archive::Tar::Wrapper by
mass-manipulating unpacked files before wrapping them back up into the
tarball.
is_compressed
Returns a string to identify if the tarball is compressed or not.
Expect as parameter a string with the path to the tarball.
Returns:
* a "z" character if the file is compressed with "gzip".
* a "j" character if the file is compressed with "bzip2".
* a "" character if the file is not compressed at all.
locate
$arch->locate($logic_path);
Finds the physical location of a file, specified by $logic_path, which
is the virtual path of the file within the tarball. Returns a path to
the temporary file Archive::Tar::Wrapper created to manipulate the
tarball on disk.
add
$arch->add($logic_path, $file_or_stringref, [$options]);
Add a new file to the tarball. $logic_path is the virtual path of the
file within the tarball. $file_or_stringref is either a scalar, in which
case it holds the physical path of a file on disk to be transferred
(i.e. copied) to the tarball, or it is a reference to a scalar, in which
case its content is interpreted to be the data of the file.
If no additional parameters are given, permissions and user/group id
settings of a file to be added are copied. If you want different
settings, specify them in the options hash:
$arch->add($logic_path, $stringref,
{ perm => 0755, uid => 123, gid => 10 });
If $file_or_stringref is a reference to a Unicode string, the "binmode"
option has to be set to make sure the string gets written as proper
UTF-8 into the tar file:
$arch->add($logic_path, $stringref, { binmode => ":utf8" });
perm_cp
Copies the permissions from a file to another.
Expects as parameters:
1. string of the path to the file which permissions will be copied
from.
2. string of the path to the file which permissions will be copied to.
Returns 1 if everything works as expected.
perm_get
Gets the permissions from a file.
Expects as parameter the path to the source file.
Returns an array reference with only the permissions values, as returned
by "stat".
perm_set
Sets the permission on a file.
Expects as parameters:
1. The path to the file where the permissions should be applied to.
2. An array reference with the permissions (see "perm_set")
Returns 1 if everything goes fine.
Ignore errors here, as we can't change uid/gid unless we're the
superuser (see LIMITATIONS section).
remove
$arch->remove($logic_path);
Removes a file from the tarball. $logic_path is the virtual path of the
file within the tarball.
list_all
my $items = $arch->list_all();
Returns a reference to a (possibly huge) array of items in the tar file.
Each item is a reference to an array, containing two elements: the
relative path of the item in the tar file and the physical path to the
unpacked file or directory on disk.
To iterate over the list, the following construct can be used:
# Get a huge list with all entries
for my $entry (@{$arch->list_all()}) {
my($tar_path, $real_path) = @$entry;
print "Tarpath: $tar_path Tempfile: $real_path\n";
}
If the list of items in the tar file is big, use list_reset() and
list_next() instead of "list_all".
list_next
my ($tar_path, $phys_path, $type) = $arch->list_next();
Returns the next item in the tar file. It returns a list of three
scalars: the relative path of the item in the tar file, the physical
path to the unpacked file or directory on disk, and the type of the
entry (f=file, d=directory, l=symlink). Note that by default,
Archive::Tar::Wrapper won't display directories, unless the "dirs"
parameter is set when running the constructor.
write
$arch->write($tarfile, $compress);
Write out the tarball by tarring up all temporary files and directories
and store it in $tarfile on disk. If $compress holds a true value,
compression is used.
is_gnu
$arch->is_gnu();
Checks if the tar executable is a GNU tar by running 'tar --version' and
parsing the output for "GNU".
Returns true or false (in Perl terms).
is_bsd
$arch->is_bsd();
Same as is_gnu(), but for BSD.
ramdisk_mount
Mounts a RAM disk.
It executes the "mount" program under the hood to mount a RAM disk.
Expects as parameter a hash with options to mount the RAM disk, like:
* "size"
* "type" (most probably "tmpfs")
* "tmpdir"
Returns 1 if everything goes fine.
Be sure to check the "Using RAM Disks" in Archive::Tar::Wrapper for full
details on using RAM disks.
ramdisk_unmount
Unmounts the RAM disk already mounted with "ramdisk_mount".
Don't expect parameters and returns 1 if everything goes fine.
Be sure to check the "Using RAM Disks" in Archive::Tar::Wrapper for full
details on using RAM disks.
Using RAM Disks
On Linux, it's quite easy to create a RAM disk and achieve tremendous
speedups while untarring or modifying a tarball. You can either create
the RAM disk by hand by running
# mkdir -p /mnt/myramdisk
# mount -t tmpfs -o size=20m tmpfs /mnt/myramdisk
and then feeding the RAM disk as a temporary directory to
Archive::Tar::Wrapper, like
my $tar = Archive::Tar::Wrapper->new( tmpdir => '/mnt/myramdisk' );
or using Archive::Tar::Wrapper's built-in option "ramdisk":
my $tar = Archive::Tar::Wrapper->new(
ramdisk => {
type => 'tmpfs',
size => '20m', # 20 MB
},
);
Only drawback with the latter option is that creating the RAM disk needs
to be performed as root, which often isn't desirable for security
reasons. For this reason, Archive::Tar::Wrapper offers a utility
functions that mounts the RAM disk and returns the temporary directory
it's located in:
# Create new ramdisk (as root):
my $tmpdir = Archive::Tar::Wrapper->ramdisk_mount(
type => 'tmpfs',
size => '20m', # 20 MB
);
# Delete a ramdisk (as root):
Archive::Tar::Wrapper->ramdisk_unmount();
Optionally, the ramdisk_mount() command accepts a "tmpdir" parameter
pointing to a temporary directory for the RAM disk if you wish to set it
yourself instead of letting Archive::Tar::Wrapper create it
automatically.
KNOWN LIMITATIONS
* Currently, only "tar" programs supporting the "z" option (for
compressing/decompressing) are supported. Future version will use
"gzip" alternatively.
* Currently, you can't add empty directories to a tarball directly.
You could add a temporary file within a directory, and then remove()
the file.
* If you delete a file, the empty directories it was located in stay
in the tarball. You could try to locate() them and delete them. This
will be fixed, though.
* Filenames containing newlines are causing problems with the list
iterators. To be fixed.
* If you ask Archive::Tar::Wrapper to add a file to a tarball, it
copies it into a temporary directory and then calls the system tar
to wrap up that directory into a tarball.
This approach has limitations when it comes to file permissions: If
the file to be added belongs to a different user/group,
Archive::Tar::Wrapper will adjust the uid/gid/permissions of the
target file in the temporary directory to reflect the original
file's settings, to make sure the system tar will add it like that
to the tarball, just like a regular tar run on the original file
would. But this will fail of course if the original file's uid is
different from the current user's, unless the script is running with
superuser rights. The tar program by itself (without
Archive::Tar::Wrapper) works differently: It'll just make a note of
a file's uid/gid/permissions in the tarball (which it can do without
superuser rights) and upon extraction, it'll adjust the permissions
of newly generated files if the -p option is given (default for
superuser).
BUGS
Archive::Tar::Wrapper doesn't currently handle filenames with embedded
newlines.
Microsoft Windows support
Support on Microsoft Windows is limited.
Versions below Windows 10 will not be supported for desktops, and for
servers only Windows 2012 and above.
The GNU "tar.exe" program doesn't work properly with the current
interface of Archive::Tar::Wrapper.
You must use the "bsdtar.exe" and make sure it appears first in the
"PATH" environment variable than the GNU tar (if it is installed). See
for details about how to download and install
"bsdtar.exe", or go to
for a direct download. Be sure to look for the "bzip2" program package
to install it as well.
Windows 10 might come already with "bsdtar" program already installed.
Please search for that on the appropriate page (Microsoft keeps changing
the link to keep track of it here).
Having spaces in the path string to the tar program might be an issue
too. Although there is some effort in terms of workaround it, you best
might avoid it completely by installing in a different path than
"C:\Program Files". Installing both "bsdtar" and "bzip2" in
"C:\GnuWin32" will probably be enough when running the installers.
SEE ALSO
* Linux Gazette article from Ben Okopnik, issue 87
.
BUGS
Please report any bugs or feature requests on the bugtracker website
When submitting a bug or request, please include a test-file or a patch
to an existing test-file that illustrates the bug or desired feature.
AUTHORS
* Mike Schilli
* Alceu Rodrigues de Freitas Junior
CONTRIBUTORS
* Chris Weyl
* David Cantrell
* David Precious
* Graham Knop
* intrigeri
* Kent Fredric
* Mark Gardner
* Mike Schilli
* Mohammad S Anwar
* Paulo Custodio
* Randy Stauner
* Sanko Robinson
* Shoichi Kaji
COPYRIGHT AND LICENSE
This software is Copyright (c) 2024 by Mike Schilli.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007
Archive-Tar-Wrapper-0.42/MANIFEST.SKIP 000644 000766 000024 00000000147 14664064025 017353 0 ustar 00gknop staff 000000 000000 blib
^Makefile$
^Makefile.old$
CVS
.cvsignore
docs
MANIFEST.bak
adm/release
.git
^MYMETA\.(json|yaml)$
Archive-Tar-Wrapper-0.42/CONTRIBUTING.md 000644 000766 000024 00000001153 14664064025 017704 0 ustar 00gknop staff 000000 000000 # CONTRIBUTING
Contributing to this project is easy.
First you need to fork this repository. It will be much easier if you have a free Github account.
When done, just hit:
```
$ git clone https://github.com//archive-tar-wrapper-perl.git
```
Or whatever you prefer to do to clone a git repository.
From there you can modify or create new files.
When you finished, you then can create a pull request to this project.
Just keep in mind to use Perltidy with your files in order to format them. That's exactly what is here, and with default configurations.
That's it! Thanks for contributing!
Archive-Tar-Wrapper-0.42/META.yml 000644 000766 000024 00000003164 14664064025 016730 0 ustar 00gknop staff 000000 000000 ---
abstract: "API wrapper around the 'tar' utility"
author:
- 'Mike Schilli '
- 'Alceu Rodrigues de Freitas Junior '
build_requires:
ExtUtils::MakeMaker: '0'
File::Spec: '0'
IO::Handle: '0'
IPC::Open3: '0'
Test::More: '0'
configure_requires:
ExtUtils::MakeMaker: '0'
File::Which: '0'
dynamic_config: 0
generated_by: 'Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010'
license: gpl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: Archive-Tar-Wrapper
provides:
Archive::Tar::Wrapper:
file: lib/Archive/Tar/Wrapper.pm
version: '0.42'
requires:
Cwd: '0'
File::Temp: '0'
File::Which: '0'
IPC::Run: '0'
Log::Log4perl: '0'
perl: '5.008001'
resources:
bugtracker: https://github.com/haarg/Archive-Tar-Wrapper/issues
repository: https://github.com/haarg/Archive-Tar-Wrapper.git
version: '0.42'
x_contributors:
- 'Chris Weyl '
- 'David Cantrell '
- 'David Precious '
- 'Graham Knop '
- 'intrigeri '
- 'Kent Fredric '
- 'Mark Gardner '
- 'Mike Schilli '
- 'Mohammad S Anwar '
- 'Paulo Custodio '
- 'Randy Stauner '
- 'Sanko Robinson '
- 'Shoichi Kaji '
x_generated_by_perl: v5.38.2
x_serialization_backend: 'YAML::Tiny version 1.74'
x_spdx_expression: GPL-3.0-only
x_use_unsafe_inc: 0
Archive-Tar-Wrapper-0.42/lib/ 000755 000766 000024 00000000000 14664064025 016221 5 ustar 00gknop staff 000000 000000 Archive-Tar-Wrapper-0.42/Makefile.PL 000644 000766 000024 00000005234 14664064025 017431 0 ustar 00gknop staff 000000 000000 # This Makefile.PL for Archive-Tar-Wrapper was generated by
# Dist::Zilla::Plugin::MakeMaker::Awesome 0.49.
# Don't edit it but the dist.ini and plugins used to construct it.
use strict;
use warnings;
use 5.008001;
use ExtUtils::MakeMaker;
if ( $^O eq 'MSWin32' ) {
require Win32;
require File::Which;
my $product_info = Win32::GetOSDisplayName();
my ( $osvername, $major, $minor, $id ) = Win32::GetOSVersion();
print "Running on $product_info - major=$major, minor=$minor, id=$id\n";
unless ( $major >= 6 ) {
warn
"Too old Microsoft Windows to be supported, major version must be equal or higher 6.\n";
die "OS unsupported\n";
}
# double quoting is required on Windows if there are spaces in the path
my $tar_path = File::Which::which('bsdtar.exe');
$tar_path = File::Which::which('tar') unless ( defined($tar_path) );
unless ( defined($tar_path) ) {
warn "No tar program available, cannot work without it.\n";
die "OS unsupported\n";
}
else {
my $version_info = `"$tar_path" --version`;
print "Using $tar_path $version_info\n";
if ( $version_info =~ /GNU/ ) {
warn
"Sorry, GNU tar is not supported on Microsoft Windows. Install a BSD tar or check your PATH configuration\n";
die "OS unsupported\n";
}
}
}
my %WriteMakefileArgs = (
"ABSTRACT" => "API wrapper around the 'tar' utility",
"AUTHOR" => "Mike Schilli , Alceu Rodrigues de Freitas Junior ",
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => 0,
"File::Which" => 0
},
"DISTNAME" => "Archive-Tar-Wrapper",
"LICENSE" => "gpl",
"MIN_PERL_VERSION" => "5.008001",
"NAME" => "Archive::Tar::Wrapper",
"PREREQ_PM" => {
"Cwd" => 0,
"File::Temp" => 0,
"File::Which" => 0,
"IPC::Run" => 0,
"Log::Log4perl" => 0
},
"TEST_REQUIRES" => {
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"IO::Handle" => 0,
"IPC::Open3" => 0,
"Test::More" => 0
},
"VERSION" => "0.42",
"test" => {
"TESTS" => "t/*.t"
}
);
my %FallbackPrereqs = (
"Cwd" => 0,
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"File::Temp" => 0,
"File::Which" => 0,
"IO::Handle" => 0,
"IPC::Open3" => 0,
"IPC::Run" => 0,
"Log::Log4perl" => 0,
"Test::More" => 0
);
unless ( eval { ExtUtils::MakeMaker->VERSION('6.63_03') } ) {
delete $WriteMakefileArgs{TEST_REQUIRES};
delete $WriteMakefileArgs{BUILD_REQUIRES};
$WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}
delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
WriteMakefile(%WriteMakefileArgs);
Archive-Tar-Wrapper-0.42/weaver.ini 000644 000766 000024 00000000163 14664064025 017445 0 ustar 00gknop staff 000000 000000 [@CorePrep]
[-SingleEncoding]
[-StopWords]
[Generic / NAME]
[Leftovers]
[Bugs]
[Authors]
[Contributors]
[Legal]
Archive-Tar-Wrapper-0.42/eg/ 000755 000766 000024 00000000000 14664064025 016046 5 ustar 00gknop staff 000000 000000 Archive-Tar-Wrapper-0.42/.perlcriticrc 000644 000766 000024 00000006522 14664064025 020146 0 ustar 00gknop staff 000000 000000 severity = 1
verbose = 9
only = 1
[BuiltinFunctions::ProhibitComplexMappings]
[BuiltinFunctions::ProhibitLvalueSubstr]
[BuiltinFunctions::ProhibitShiftRef]
[BuiltinFunctions::ProhibitSleepViaSelect]
[BuiltinFunctions::ProhibitStringyEval]
[BuiltinFunctions::ProhibitUniversalCan]
[BuiltinFunctions::ProhibitUniversalIsa]
[BuiltinFunctions::ProhibitVoidGrep]
[BuiltinFunctions::ProhibitVoidMap]
[BuiltinFunctions::RequireGlobFunction]
[BuiltinFunctions::RequireSimpleSortBlock]
[ClassHierarchies::ProhibitOneArgBless]
[CodeLayout::ProhibitHardTabs]
[CodeLayout::RequireConsistentNewlines]
[ControlStructures::ProhibitCascadingIfElse]
[ControlStructures::ProhibitDeepNests]
[ControlStructures::ProhibitLabelsWithSpecialBlockNames]
[ControlStructures::ProhibitMutatingListFunctions]
[ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions]
[ControlStructures::ProhibitUnreachableCode]
[ControlStructures::ProhibitYadaOperator]
[ErrorHandling::RequireCheckingReturnValueOfEval]
[InputOutput::ProhibitBacktickOperators]
[InputOutput::ProhibitBarewordFileHandles]
[InputOutput::ProhibitExplicitStdin]
[InputOutput::ProhibitInteractiveTest]
[InputOutput::ProhibitJoinedReadline]
[InputOutput::ProhibitOneArgSelect]
[InputOutput::ProhibitReadlineInForLoop]
[InputOutput::ProhibitTwoArgOpen]
[InputOutput::RequireCheckedOpen]
[InputOutput::RequireEncodingWithUTF8Layer]
[Miscellanea::ProhibitFormats]
[Miscellanea::ProhibitUnrestrictedNoCritic]
[Modules::ProhibitAutomaticExportation]
[Modules::ProhibitConditionalUseStatements]
[Modules::ProhibitEvilModules]
[Modules::ProhibitExcessMainComplexity]
[Modules::RequireBarewordIncludes]
[Modules::RequireEndWithOne]
[Modules::RequireExplicitPackage]
[Modules::RequireFilenameMatchesPackage]
[NamingConventions::ProhibitAmbiguousNames]
[Objects::ProhibitIndirectSyntax]
[RegularExpressions::ProhibitCaptureWithoutTest]
[RegularExpressions::ProhibitComplexRegexes]
[RegularExpressions::ProhibitUnusedCapture]
[Subroutines::ProhibitBuiltinHomonyms]
[Subroutines::ProhibitExcessComplexity]
max_mccabe = 30
[Subroutines::ProhibitExplicitReturnUndef]
[Subroutines::ProhibitManyArgs]
[Subroutines::ProhibitNestedSubs]
[Subroutines::ProhibitReturnSort]
[Subroutines::ProhibitSubroutinePrototypes]
[Subroutines::ProhibitUnusedPrivateSubroutines]
[Subroutines::ProtectPrivateSubs]
[TestingAndDebugging::ProhibitProlongedStrictureOverride]
[TestingAndDebugging::RequireTestLabels]
[TestingAndDebugging::RequireUseStrict]
[TestingAndDebugging::RequireUseWarnings]
[ValuesAndExpressions::ProhibitCommaSeparatedStatements]
[ValuesAndExpressions::ProhibitComplexVersion]
[ValuesAndExpressions::ProhibitImplicitNewlines]
[ValuesAndExpressions::ProhibitLeadingZeros]
[ValuesAndExpressions::ProhibitMismatchedOperators]
[ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters]
[ValuesAndExpressions::ProhibitSpecialLiteralHeredocTerminator]
[ValuesAndExpressions::ProhibitVersionStrings]
[ValuesAndExpressions::RequireQuotedHeredocTerminator]
[Variables::ProhibitAugmentedAssignmentInDeclaration]
allow_our = 1
[Variables::ProhibitConditionalDeclarations]
[Variables::ProhibitMatchVars]
[Variables::ProhibitReusedNames]
[Variables::ProhibitUnusedVariables]
[Variables::ProtectPrivateVars]
[Variables::RequireInitializationForLocalVars]
[Variables::RequireLexicalLoopIterators]
[Variables::RequireLocalizedPunctuationVars]
[Variables::RequireNegativeIndices]
Archive-Tar-Wrapper-0.42/META.json 000644 000766 000024 00000006176 14664064025 017106 0 ustar 00gknop staff 000000 000000 {
"abstract" : "API wrapper around the 'tar' utility",
"author" : [
"Mike Schilli ",
"Alceu Rodrigues de Freitas Junior "
],
"dynamic_config" : 0,
"generated_by" : "Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010",
"license" : [
"gpl_3"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "Archive-Tar-Wrapper",
"prereqs" : {
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0",
"File::Which" : "0"
}
},
"develop" : {
"requires" : {
"Dumbbench" : "0",
"Pod::Coverage::TrustPod" : "0",
"Test::CPAN::Changes" : "0.19",
"Test::CPAN::Meta" : "0",
"Test::EOL" : "0",
"Test::Kwalitee" : "1.21",
"Test::MinimumVersion" : "0",
"Test::Mojibake" : "0",
"Test::More" : "0.88",
"Test::NoTabs" : "0",
"Test::Perl::Critic" : "0",
"Test::Pod" : "1.41",
"Test::Pod::Coverage" : "1.08",
"Test::Portability::Files" : "0",
"Test::Spelling" : "0.12",
"Test::Version" : "1"
}
},
"runtime" : {
"requires" : {
"Cwd" : "0",
"File::Temp" : "0",
"File::Which" : "0",
"IPC::Run" : "0",
"Log::Log4perl" : "0",
"perl" : "5.008001"
}
},
"test" : {
"recommends" : {
"CPAN::Meta" : "2.120900"
},
"requires" : {
"ExtUtils::MakeMaker" : "0",
"File::Spec" : "0",
"IO::Handle" : "0",
"IPC::Open3" : "0",
"Test::More" : "0"
}
}
},
"provides" : {
"Archive::Tar::Wrapper" : {
"file" : "lib/Archive/Tar/Wrapper.pm",
"version" : "0.42"
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/haarg/Archive-Tar-Wrapper/issues"
},
"repository" : {
"type" : "git",
"url" : "https://github.com/haarg/Archive-Tar-Wrapper.git",
"web" : "https://github.com/haarg/Archive-Tar-Wrapper"
}
},
"version" : "0.42",
"x_contributors" : [
"Chris Weyl ",
"David Cantrell ",
"David Precious ",
"Graham Knop ",
"intrigeri ",
"Kent Fredric ",
"Mark Gardner ",
"Mike Schilli ",
"Mohammad S Anwar ",
"Paulo Custodio ",
"Randy Stauner ",
"Sanko Robinson ",
"Shoichi Kaji "
],
"x_generated_by_perl" : "v5.38.2",
"x_serialization_backend" : "Cpanel::JSON::XS version 4.37",
"x_spdx_expression" : "GPL-3.0-only",
"x_use_unsafe_inc" : 0
}
Archive-Tar-Wrapper-0.42/dist.ini 000644 000766 000024 00000006652 14664064025 017130 0 ustar 00gknop staff 000000 000000 name = Archive-Tar-Wrapper
author = Mike Schilli
author = Alceu Rodrigues de Freitas Junior
license = GPL_3
copyright_holder = Mike Schilli
;;; Gather
[Git::GatherDir]
exclude_filename = Makefile.PL
exclude_filename = META.json
exclude_filename = LICENSE
exclude_filename = README.md
[GatherFile]
filename = .perlcriticrc
[Encoding]
encoding = bytes
matches = \.(tar(\.(gz|bz2))?|tgz)
;;; Metadata
[Git::Contributors]
[MetaProvides::Package]
[MetaResources]
bugtracker.web = https://github.com/haarg/Archive-Tar-Wrapper/issues
repository.url = https://github.com/haarg/Archive-Tar-Wrapper.git
repository.web = https://github.com/haarg/Archive-Tar-Wrapper
repository.type = git
[PrereqsFile]
[UseUnsafeInc]
dot_in_INC = 0
;;; Modification
[PodWeaver]
; authordep Pod::Weaver::Section::Contributors
; authordep Pod::Weaver::Plugin::StopWords
;;; Extra Files
[License]
[MetaJSON]
[MetaYAML]
[Manifest]
[Pod2Readme]
;;; Installer
[MakeMaker::Awesome]
delimiter = |
header = |if ( $^O eq 'MSWin32' ) {
header = | require Win32;
header = | require File::Which;
header = | my $product_info = Win32::GetOSDisplayName();
header = | my ( $osvername, $major, $minor, $id ) = Win32::GetOSVersion();
header = | print "Running on $product_info - major=$major, minor=$minor, id=$id\n";
header = |
header = | unless ( $major >= 6 ) {
header = | warn
header = |"Too old Microsoft Windows to be supported, major version must be equal or higher 6.\n";
header = | die "OS unsupported\n";
header = | }
header = |
header = | # double quoting is required on Windows if there are spaces in the path
header = | my $tar_path = File::Which::which('bsdtar.exe');
header = | $tar_path = File::Which::which('tar') unless ( defined($tar_path) );
header = |
header = | unless ( defined($tar_path) ) {
header = | warn "No tar program available, cannot work without it.\n";
header = | die "OS unsupported\n";
header = | }
header = | else {
header = | my $version_info = `"$tar_path" --version`;
header = | print "Using $tar_path $version_info\n";
header = |
header = | if ( $version_info =~ /GNU/ ) {
header = | warn
header = |"Sorry, GNU tar is not supported on Microsoft Windows. Install a BSD tar or check your PATH configuration\n";
header = | die "OS unsupported\n";
header = | }
header = | }
header = |}
;;; Release
[TestRelease]
[RunExtraTests]
[ConfirmRelease]
[UploadToCPAN]
[Git::Check]
[Git::Remote::Check]
branch = master
[@Git::VersionManager]
-remove = Prereqs
NextRelease.format = %-6v %{yyyy-MM-dd}d%{ (TRIAL RELEASE)}T
[Git::Push]
;;; Tests
[MetaTests]
[MojibakeTests]
[PodCoverageTests]
[PodSyntaxTests]
[Test::CPAN::Changes]
[Substitute / RenameTestCPANChanges]
file = xt/release/cpan-changes.t
filename_code = s{release}{author};
code =
[Test::ChangesHasContent]
[Test::Compile]
[Test::EOL]
[Test::Kwalitee]
filename = xt/author/kwalitee.t
[Test::MinimumVersion]
[Test::NoTabs]
[Test::Perl::Critic]
critic_config = .perlcriticrc
[Test::PodSpelling]
[Test::Portability]
options = test_one_dot = 0
[Test::ReportPrereqs]
[Test::Version]
;;; Repo files
[CopyFilesFromRelease]
filename = Makefile.PL
filename = META.json
filename = LICENSE
[ReadmeAnyFromPod / ReadmeGFMInRoot]
phase = release
[Regenerate::AfterReleasers]
plugin = CopyFilesFromRelease
plugin = ReadmeGFMInRoot
Archive-Tar-Wrapper-0.42/eg/tarflat 000755 000766 000024 00000004332 14664064025 017433 0 ustar 00gknop staff 000000 000000 #!/usr/bin/perl
use strict;
use warnings;
use Getopt::Std;
use Pod::Usage;
use Archive::Tar::Wrapper;
use Sysadm::Install qw(:all);
use vars qw($CVSVERSION);
$CVSVERSION = '$Revision: 1.1 $';
getopts( "hv", \my %opts );
pod2usage() if $opts{h};
if ( $opts{v} ) {
my ($version) = $CVSVERSION =~ /(\d\S+)/;
die "$0 $version\n";
}
my ( $target_dir, @tarfiles ) = @ARGV;
unless ( defined($target_dir) or @tarfiles ) {
pod2usage("Wrong number of arguments");
}
unless ( -d $target_dir ) {
my $create = ask "$target_dir doesn't exist. Create it [y]", "y";
mkd $target_dir if $create =~ /[yY]/;
}
my $arch = Archive::Tar::Wrapper->new();
for my $tarfile (@tarfiles) {
$arch->read($tarfile);
}
$arch->list_reset();
while ( my $entry = $arch->list_next() ) {
my ( $tar_path, $phys_path ) = @$entry;
if ( -f $phys_path ) {
cp $phys_path, $target_dir;
}
}
__END__
=head1 NAME
tarflat - Unpack tarfiles and put their content flat in a single directory
=head1 SYNOPSIS
tarflat target_dir tarfile ...
=head1 OPTIONS
=over 8
=item B<-h>
Prints this manual page in text format.
=item B<-v>
Prints the script version.
=back
=head1 DESCRIPTION
C
=head1 EXAMPLES
# Unpack foo.tgz and bar.tgz and store all of their files
# (anywhere in the directory hierarchy) in the directory
# /tmp/junk.
$ mkdir /tmp/junk
$ tarflat /tmp/junk foo.tgz bar.tgz
=head1 LEGALESE
This software is copyright (c) 2005 of Mike Schilli.
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
Archive-Tar-Wrapper. If not, see L.
=head1 AUTHOR
2005, Mike Schilli
=head1 MAINTAINER
2018, Alceu Rodrigues de Freitas Junior
=cut
Archive-Tar-Wrapper-0.42/lib/Archive/ 000755 000766 000024 00000000000 14664064025 017602 5 ustar 00gknop staff 000000 000000 Archive-Tar-Wrapper-0.42/lib/Archive/Tar/ 000755 000766 000024 00000000000 14664064025 020330 5 ustar 00gknop staff 000000 000000 Archive-Tar-Wrapper-0.42/lib/Archive/Tar/Wrapper.pm 000644 000766 000024 00000103006 14664064025 022306 0 ustar 00gknop staff 000000 000000 package Archive::Tar::Wrapper;
use strict;
use warnings;
use File::Temp qw(tempdir);
use Log::Log4perl qw(:easy);
use File::Spec::Functions;
use File::Spec;
use File::Path;
use File::Copy;
use File::Find;
use File::Basename;
use File::Which qw(which);
use IPC::Run qw(run);
use Cwd;
use Config;
use IPC::Open3;
use Symbol 'gensym';
use Carp;
our $VERSION = '0.42';
my $logger = get_logger();
sub new {
my ( $class, %options ) = @_;
my $self = {
tar => delete $options{tar} || undef,
tmpdir => undef,
tar_read_options => '',
tar_write_options => '',
tar_error_msg => undef,
tar_gnu_read_options => [],
tar_gnu_write_options => [],
dirs => 0,
max_cmd_line_args => 512,
ramdisk => undef,
_os_names => {
openbsd => 'openbsd',
mswin => 'MSWin32',
solaris => 'solaris'
},
# hack used to enable unit testing
osname => delete $options{osname} || $Config{osname},
bzip2_regex => qr/\.bz2$/ix,
gzip_regex => qr/\.t? # an optional t for matching tgz
gz$ # ending with gz, which means compressed by gzip
/ix,
tar_error_msg => undef,
version_info => undef,
tar_exit_code => undef,
is_gnu => undef,
is_bsd => undef,
version_info => undef,
tar_exit_code => undef,
%options,
};
bless $self, $class;
unless ( defined $self->{tar} ) {
if ( ( $self->_is_openbsd ) and ( $self->{tar_read_options} ) ) {
$self->{tar_read_options} = '-' . $self->{tar_read_options};
}
if ( $self->{osname} eq 'MSWin32' ) {
$self->_setup_mswin();
}
else {
$self->{tar} = which('tar') || which('gtar');
}
unless ( defined $self->{tar} ) {
# this is specific for testing under MS Windows smokers without tar installed
# "OS unsupported" will mark the testing as NA instead of failure as convention.
if ( $self->{osname} eq 'MSWin32' ) {
LOGDIE 'tar not found in PATH, OS unsupported';
}
else {
LOGDIE 'tar not found in PATH, please specify location';
}
}
}
$self->_acquire_tar_info();
if ( defined $self->{ramdisk} ) {
my $rc = $self->ramdisk_mount( %{ $self->{ramdisk} } );
unless ($rc) {
LOGDIE "Mounting ramdisk failed";
}
$self->{tmpdir} = $self->{ramdisk}->{tmpdir};
}
else {
$self->{tmpdir} =
tempdir( $self->{tmpdir} ? ( DIR => $self->{tmpdir} ) : () );
}
$self->{tardir} = File::Spec->catfile( $self->{tmpdir}, 'tar' );
mkpath [ $self->{tardir} ], 0, oct(755)
or LOGDIE 'Cannot create the path ' . $self->{tardir} . ": $!";
$logger->debug( 'tardir location: ' . $self->{tardir} )
if ( $logger->is_debug );
$self->{objdir} = tempdir();
return $self;
}
sub _is_openbsd {
my $self = shift;
return ( $self->{osname} eq $self->{_os_names}->{openbsd} );
}
sub _is_solaris {
my $self = shift;
return ( $self->{osname} eq $self->{_os_names}->{solaris} );
}
sub _read_solaris_opts {
my ( $self, $compress_opt ) = @_;
my @cmd;
push( @cmd, $self->{tar} );
push( @cmd, 'xp' );
if ($compress_opt) {
$cmd[-1] .= $compress_opt;
}
$cmd[-1] .= 'f';
push( @cmd, $self->{tar_read_options} )
if ( $self->{tar_read_options} ne '' );
return \@cmd;
}
sub _read_openbsd_opts {
my ( $self, $compress_opt ) = @_;
my @cmd;
push( @cmd, $self->{tar} );
if ($compress_opt) {
# actually, prepending '-' would work with any modern GNU tar
$compress_opt = '-' . $compress_opt;
push( @cmd, $compress_opt );
}
push( @cmd, '-x' );
push( @cmd, $self->{tar_read_options} )
if ( $self->{tar_read_options} ne '' );
push( @cmd, @{ $self->{tar_gnu_read_options} } )
if ( scalar( @{ $self->{tar_gnu_read_options} } ) > 0 );
return \@cmd;
}
sub read { ## no critic (ProhibitBuiltinHomonyms)
my ( $self, $tarfile, @files ) = @_;
my $cwd = getcwd();
unless ( File::Spec::Functions::file_name_is_absolute($tarfile) ) {
$tarfile = File::Spec::Functions::rel2abs( $tarfile, $cwd );
}
chdir $self->{tardir}
or LOGDIE "Cannot chdir to $self->{tardir}";
my $compr_opt = ''; # sane value
$compr_opt = $self->is_compressed($tarfile);
my @cmd;
if ( $self->_is_openbsd ) {
@cmd = @{ $self->_read_openbsd_opts($compr_opt) };
push @cmd, '-f';
}
elsif ( $self->_is_solaris ) {
@cmd = @{ $self->_read_solaris_opts($compr_opt) };
}
else {
@cmd = (
$self->{tar},
"${compr_opt}x$self->{tar_read_options}",
@{ $self->{tar_gnu_read_options} }, '-f'
);
}
push( @cmd, $tarfile, @files );
$logger->debug("Running @cmd") if ( $logger->is_debug );
my $error_code = run( \@cmd, \my ( $in, $out, $err ) );
unless ($error_code) {
ERROR "@cmd failed: $err";
chdir $cwd or LOGDIE "Cannot chdir to $cwd";
return;
}
$logger->warn($err) if ( $logger->is_warn and $err );
chdir $cwd or LOGDIE "Cannot chdir to $cwd: $!";
return ( $error_code == 0 ) ? undef : $error_code;
}
sub list_reset {
my ($self) = @_;
#TODO: keep the file list as a fixed attribute of the instance
my $list_file = File::Spec->catfile( $self->{objdir}, 'list' );
my $cwd = getcwd();
chdir $self->{tardir} or LOGDIE "Can't chdir to $self->{tardir}: $!";
open( my $fh, '>', $list_file ) or LOGDIE "Can't open $list_file: $!";
if ( $logger->is_debug ) {
$logger->debug('List of all files identified inside the tar file');
}
find(
sub {
my $entry = $File::Find::name;
$entry =~ s#^\./##o;
my $type = (
-d $_ ? 'd'
: -l $_ ? 'l'
: 'f'
);
print $fh "$type $entry\n";
$logger->debug("$type $entry") if ( $logger->is_debug );
},
'.'
);
$logger->debug('All entries listed') if ( $logger->is_debug );
close($fh);
chdir $cwd or LOGDIE "Can't chdir to $cwd: $!";
$self->_offset(0);
return 1;
}
sub _read_from_tar {
my $self = shift;
my ( $wtr, $rdr, $err ) = ( gensym, gensym, gensym );
my $pid = open3( $wtr, $rdr, $err, "$self->{tar} --version" );
my ( $output, $error );
{
local $/ = undef;
$output = <$rdr>;
$error = <$err>;
}
close($rdr);
close($err);
close($wtr);
waitpid( $pid, 0 );
chomp $error;
chomp $output;
$self->{tar_error_msg} = $error;
$self->{version_info} = $output;
$self->{tar_exit_code} = $? >> 8;
return 1;
}
sub _acquire_tar_info {
my ( $self, $skip ) = @_;
$self->_read_from_tar() unless ($skip);
my $bsd_regex = qr/bsd/i;
$self->{is_gnu} = 0;
$self->{is_bsd} = 0;
if ( $self->_is_openbsd() ) {
# there is no way to acquire version information from default tar program on OpenBSD
$self->{version_info} = "Information not available on $Config{osname}";
$self->{tar_exit_code} = 0;
$self->{is_bsd} = 1;
}
elsif ( $self->_is_solaris() ) {
$self->{version_info} = "Information not available on $Config{osname}";
$self->{tar_exit_code} = 0;
$self->{is_bsd} = 1;
}
elsif ( ( $self->{tar} =~ $bsd_regex ) and ( $self->{tar_exit_code} == 1 ) )
{
# bsdtar exit code is 1 when asking for version, forcing to zero since is not an error
$self->{tar_exit_code} = 0;
$self->{is_bsd} = 1;
}
$self->{version_info} = 'Information not available. Search for errors'
unless ( $self->{tar_exit_code} == 0 );
$self->{is_gnu} = 1 if ( $self->{version_info} =~ /GNU/ );
return 1;
}
sub _setup_mswin {
my $self = shift;
# bsdtar is always preferred on Windows
my $tar_path = which('bsdtar');
$tar_path = which('tar') unless ( defined($tar_path) );
if ( $tar_path =~ /\s/ ) {
# double quoting will be required is there is a space
$tar_path = qq($tar_path);
}
$self->{tar} = $tar_path;
}
sub tardir {
my ($self) = @_;
return $self->{tardir};
}
sub is_compressed {
my ( $self, $tarfile ) = @_;
return 'z' if $tarfile =~ $self->{gzip_regex};
return 'j' if $tarfile =~ $self->{bzip2_regex};
# Sloppy check for gzip files
open( my $fh, '<', $tarfile ) or croak("Cannot open $tarfile: $!");
binmode($fh);
my $read = sysread( $fh, my $two, 2, 0 )
or croak("Cannot sysread $tarfile: $!");
close($fh);
return 'z'
if ( ( ( ord( substr( $two, 0, 1 ) ) ) == 0x1F )
and ( ( ord( substr( $two, 1, 1 ) ) ) == 0x8B ) );
return q{};
}
sub locate {
my ( $self, $rel_path ) = @_;
my $real_path = File::Spec->catfile( $self->{tardir}, $rel_path );
if ( -e $real_path ) {
$logger->debug("$real_path exists") if ( $logger->is_debug );
return $real_path;
}
else {
$logger->warn("$rel_path not found in tarball") if ( $logger->is_warn );
return;
}
}
sub add {
my ( $self, $rel_path, $path_or_stringref, $opts ) = @_;
if ($opts) {
unless ( ( ref($opts) ) and ( ref($opts) eq 'HASH' ) ) {
LOGDIE "Option parameter given to add() not a hashref.";
}
}
my ( $perm, $uid, $gid, $binmode );
$perm = $opts->{perm} if defined $opts->{perm};
$uid = $opts->{uid} if defined $opts->{uid};
$gid = $opts->{gid} if defined $opts->{gid};
$binmode = $opts->{binmode} if defined $opts->{binmode};
my $target = File::Spec->catfile( $self->{tardir}, $rel_path );
my $target_dir = dirname($target);
unless ( -d $target_dir ) {
if ( ref($path_or_stringref) ) {
$self->add( dirname($rel_path), dirname($target_dir) );
}
else {
$self->add( dirname($rel_path), dirname($path_or_stringref) );
}
}
if ( ref($path_or_stringref) ) {
open my $fh, '>', $target or LOGDIE "Can't open $target: $!";
if ( defined $binmode ) {
binmode $fh, $binmode;
}
print $fh $$path_or_stringref;
close $fh;
}
elsif ( -d $path_or_stringref ) {
# perms will be fixed further down
mkpath( $target, 0, oct(755) ) unless -d $target;
}
else {
copy $path_or_stringref, $target
or LOGDIE "Can't copy $path_or_stringref to $target ($!)";
}
if ( defined $uid ) {
chown $uid, -1, $target
or LOGDIE "Can't chown $target uid to $uid ($!)";
}
if ( defined $gid ) {
chown -1, $gid, $target
or LOGDIE "Can't chown $target gid to $gid ($!)";
}
if ( defined $perm ) {
chmod $perm, $target
or LOGDIE "Can't chmod $target to $perm ($!)";
}
if ( not defined $uid
and not defined $gid
and not defined $perm
and not ref($path_or_stringref) )
{
perm_cp( $path_or_stringref, $target )
or LOGDIE "Can't perm_cp $path_or_stringref to $target ($!)";
}
return 1;
}
sub perm_cp {
my ( $source, $target ) = @_;
perm_set( $target, perm_get($source) );
return 1;
}
sub perm_get {
my ($filename) = @_;
my @stats = ( stat $filename )[ 2, 4, 5 ]
or LOGDIE "Cannot stat $filename ($!)";
return \@stats;
}
sub perm_set {
my ( $filename, $perms ) = @_;
chown( $perms->[1], $perms->[2], $filename );
chmod( $perms->[0] & oct(777), $filename )
or LOGDIE "Cannot chmod $filename ($!)";
return 1;
}
sub remove {
my ( $self, $rel_path ) = @_;
my $target = File::Spec->catfile( $self->{tardir}, $rel_path );
rmtree($target) or LOGDIE "Can't rmtree $target: $!";
return 1;
}
sub list_all {
my ($self) = @_;
my @entries = ();
$self->list_reset();
while ( my $entry = $self->list_next() ) {
push @entries, $entry;
}
return \@entries;
}
sub list_next {
my ($self) = @_;
my $offset = $self->_offset();
my $list_file = File::Spec->catfile( $self->{objdir}, 'list' );
open my $fh, '<', $list_file or LOGDIE "Can't open $list_file: $!";
seek $fh, $offset, 0;
my $data;
REDO: {
my $line = <$fh>;
unless ( defined($line) ) {
close($fh);
}
else {
chomp $line;
my ( $type, $entry ) = split / /, $line, 2;
redo if ( ( $type eq 'd' ) and ( not $self->{dirs} ) );
$self->_offset( tell $fh );
close($fh);
$data =
[ $entry, File::Spec->catfile( $self->{tardir}, $entry ), $type ];
}
}
return $data;
}
sub _offset {
my ( $self, $new_offset ) = @_;
my $offset_file = File::Spec->catfile( $self->{objdir}, "offset" );
if ( defined $new_offset ) {
open my $fh, '>', $offset_file or LOGDIE "Can't open $offset_file: $!";
print $fh "$new_offset\n";
close $fh;
}
open my $fh, '<', $offset_file
or LOGDIE
"Can't open $offset_file: $! (Did you call list_next() without a previous list_reset()?)";
my $offset = <$fh>;
chomp $offset;
close $fh;
return $offset;
}
sub write { ## no critic (ProhibitBuiltinHomonyms)
my ( $self, $tarfile, $compress ) = @_;
my $cwd = getcwd();
chdir $self->{tardir} or LOGDIE "Can't chdir to $self->{tardir}: $!";
unless ( File::Spec::Functions::file_name_is_absolute($tarfile) ) {
$tarfile = File::Spec::Functions::rel2abs( $tarfile, $cwd );
}
my $compr_opt = '';
$compr_opt = 'z' if $compress;
opendir( my $dir, '.' ) or LOGDIE "Cannot open $self->{tardir}: $!";
my @top_entries = readdir($dir);
closedir($dir);
$self->_rem_dots( \@top_entries );
my $cmd = [
$self->{tar}, "${compr_opt}cf$self->{tar_write_options}",
$tarfile, @{ $self->{tar_gnu_write_options} }
];
if ( @top_entries > $self->{max_cmd_line_args} ) {
my $filelist_file = $self->{tmpdir} . "/file-list";
open( my $fh, '>', $filelist_file )
or LOGDIE "Cannot write to $filelist_file: $!";
for my $entry (@top_entries) {
print $fh "$entry\n";
}
close($fh);
push @$cmd, "-T", $filelist_file;
}
else {
push @$cmd, @top_entries;
}
$logger->debug("Running @$cmd") if ( $logger->is_debug );
my $rc = run( $cmd, \my ( $in, $out, $err ) );
unless ($rc) {
ERROR "@$cmd failed: $err";
chdir $cwd or LOGDIE "Cannot chdir to $cwd";
return;
}
WARN $err if $err;
chdir $cwd or LOGDIE "Cannot chdir to $cwd";
return 1;
}
sub _rem_dots {
my ( $self, $entries_ref ) = @_;
my ( $first, $second ); ## no critic (NamingConventions::ProhibitAmbiguousNames)
my $index = 0;
my $found = 0;
for ( @{$entries_ref} ) {
if ( ( length($_) <= 2 )
and ( ( $_ eq '.' ) or ( $_ eq '..' ) ) )
{
if ( $found < 1 ) {
$first = $index;
$found++;
$index++;
next;
}
else {
$second = $index;
last;
}
}
else {
$index++;
}
}
splice( @{$entries_ref}, $first, 1 );
# array length is now shortened by one
splice( @{$entries_ref}, ( $second - 1 ), 1 );
return 1;
}
sub DESTROY {
my ($self) = @_;
$self->ramdisk_unmount() if defined $self->{ramdisk};
rmtree( $self->{objdir} ) if defined $self->{objdir};
rmtree( $self->{tmpdir} ) if defined $self->{tmpdir};
return 1;
}
sub is_gnu {
return shift->{is_gnu};
}
sub is_bsd {
return shift->{is_bsd};
}
sub ramdisk_mount {
my ( $self, %options ) = @_;
# mkdir -p /mnt/myramdisk
# mount -t tmpfs -o size=20m tmpfs /mnt/myramdisk
$self->{mount} = which("mount") unless $self->{mount};
$self->{umount} = which("umount") unless $self->{umount};
for (qw(mount umount)) {
unless ( defined $self->{$_} ) {
LOGWARN "No $_ command found in PATH";
return;
}
}
$self->{ramdisk} = {%options};
$self->{ramdisk}->{size} = "100m"
unless defined $self->{ramdisk}->{size};
if ( !defined $self->{ramdisk}->{tmpdir} ) {
$self->{ramdisk}->{tmpdir} = tempdir( CLEANUP => 1 );
}
my @cmd = (
$self->{mount}, "-t", "tmpfs", "-o", "size=$self->{ramdisk}->{size}",
"tmpfs", $self->{ramdisk}->{tmpdir}
);
INFO "Mounting ramdisk: @cmd";
my $rc = system(@cmd);
if ($rc) {
if ( $logger->is_info ) {
$logger->info("Mount command '@cmd' failed: $?");
$logger->info('Note that this only works on Linux and as root');
}
return;
}
$self->{ramdisk}->{mounted} = 1;
return 1;
}
sub ramdisk_unmount {
my ($self) = @_;
return unless ( exists $self->{ramdisk}->{mounted} );
my @cmd = ( $self->{umount}, $self->{ramdisk}->{tmpdir} );
$logger->info("Unmounting ramdisk: @cmd") if ( $logger->is_info );
my $rc = system(@cmd);
if ($rc) {
LOGWARN "Unmount command '@cmd' failed: $?";
return;
}
delete $self->{ramdisk};
return 1;
}
1;
__END__
=pod
=encoding UTF-8
=for :stopwords Mike Schilli Alceu Rodrigues de Freitas Junior MERCHANTABILITY Okopnik
Unmounts untarring tardir
=head1 NAME
Archive::Tar::Wrapper - API wrapper around the 'tar' utility
=head1 SYNOPSIS
use Archive::Tar::Wrapper;
my $arch = Archive::Tar::Wrapper->new();
# Open a tarball, expand it into a temporary directory
$arch->read("archive.tgz");
# Iterate over all entries in the archive
$arch->list_reset(); # Reset Iterator
# Iterate through archive
while(my $entry = $arch->list_next()) {
my($tar_path, $phys_path) = @$entry;
print "$tar_path\n";
}
# Get a huge list with all entries
for my $entry (@{$arch->list_all()}) {
my($tar_path, $real_path) = @$entry;
print "Tarpath: $tar_path Tempfile: $real_path\n";
}
# Add a new entry
$arch->add($logic_path, $file_or_stringref);
# Remove an entry
$arch->remove($logic_path);
# Find the physical location of a temporary file
my($tmp_path) = $arch->locate($tar_path);
# Create a tarball
$arch->write($tarfile, $compress);
=head1 DESCRIPTION
B is an API wrapper around the C command line
program. It never stores anything in memory, but works on temporary
directory structures on disk instead. It provides a mapping between
the logical paths in the tarball and the 'real' files in the temporary
directory on disk.
It differs from L in two ways:
=over 4
=item *
B almost doesn't hold anything in memory (see C method),
instead using disk as storage.
=item *
B is 100% compliant with the platform's C
utility because it uses it internally.
=back
=head1 METHODS
=head2 new
my $arch = Archive::Tar::Wrapper->new();
Constructor for the C wrapper class. Finds the C executable
by searching C and returning the first hit. In case you want
to use a different tar executable, you can specify it as a parameter:
my $arch = Archive::Tar::Wrapper->new(tar => '/path/to/tar');
Since B creates temporary directories to store
C data, the location of the temporary directory can be specified:
my $arch = Archive::Tar::Wrapper->new(tmpdir => '/path/to/tmpdir');
Tremendous performance increases can be achieved if the temporary
directory is located on a RAM disk. Check the L
section for details.
Additional options can be passed to the C command by using the
C and C parameters. Example:
my $arch = Archive::Tar::Wrapper->new(
tar_read_options => 'p'
);
will use C to extract the tarball instead of just
C. GNU tar supports even more options, these can
be passed in via
my $arch = Archive::Tar::Wrapper->new(
tar_gnu_read_options => ["--numeric-owner"],
);
Similarly, C can be used to provide additional
options for GNU tar implementations. For example, the tar object
my $tar = Archive::Tar::Wrapper->new(
tar_gnu_write_options => ["--exclude=foo"],
);
will call the C utility internally like
tar cf tarfile --exclude=foo ...
when the C method gets called.
By default, the C functions will return only file entries:
directories will be suppressed. To have C return directories
as well, use
my $arch = Archive::Tar::Wrapper->new(
dirs => 1
);
If more files are added to a tarball than the command line can handle,
B will switch from using the command
tar cfv tarfile file1 file2 file3 ...
to
tar cfv tarfile -T filelist
where C is a file containing all file to be added. The default
for this switch is 512, but it can be changed by setting the parameter
C:
my $arch = Archive::Tar::Wrapper->new(
max_cmd_line_args => 1024
);
The allowable parameters are:
=over
=item *
C
=item *
C
=item *
C
=item *
C
=item *
C
=item *
C
=item *
C: defaults to 512
=item *
C
=back
Returns a new instance of the class.
=head2 read
$arch->read("archive.tgz");
C opens the given tarball, expands it into a temporary directory
and returns 1 on success or C on failure.
The temporary directory holding the tar data gets cleaned up when C<$arch>
goes out of scope.
C handles both compressed and uncompressed files. To find out if
a file is compressed or uncompressed, it tries to guess by extension,
then by checking the first couple of bytes in the tar file.
If only a limited number of files is needed from a tarball, they
can be specified after the tarball name:
$arch->read("archive.tgz", "path/file.dat", "path/sub/another.txt");
The file names are passed unmodified to the C command, make sure
that the file paths match exactly what's in the tarball, otherwise
C will fail.
=head2 list_reset
$arch->list_reset()
Resets the list iterator. To be used before the first call to C.
=head2 tardir
$arch->tardir();
Return the directory the tarball was unpacked in. This is sometimes useful
to play dirty tricks on B by mass-manipulating
unpacked files before wrapping them back up into the tarball.
=head2 is_compressed
Returns a string to identify if the tarball is compressed or not.
Expect as parameter a string with the path to the tarball.
Returns:
=over
=item *
a "z" character if the file is compressed with C.
=item *
a "j" character if the file is compressed with C.
=item *
a "" character if the file is not compressed at all.
=back
=head2 locate
$arch->locate($logic_path);
Finds the physical location of a file, specified by C<$logic_path>, which
is the virtual path of the file within the tarball. Returns a path to
the temporary file B created to manipulate the
tarball on disk.
=head2 add
$arch->add($logic_path, $file_or_stringref, [$options]);
Add a new file to the tarball. C<$logic_path> is the virtual path
of the file within the tarball. C<$file_or_stringref> is either
a scalar, in which case it holds the physical path of a file
on disk to be transferred (i.e. copied) to the tarball, or it is
a reference to a scalar, in which case its content is interpreted
to be the data of the file.
If no additional parameters are given, permissions and user/group
id settings of a file to be added are copied. If you want different
settings, specify them in the options hash:
$arch->add($logic_path, $stringref,
{ perm => 0755, uid => 123, gid => 10 });
If $file_or_stringref is a reference to a Unicode string, the C
option has to be set to make sure the string gets written as proper UTF-8
into the tar file:
$arch->add($logic_path, $stringref, { binmode => ":utf8" });
=head2 perm_cp
Copies the permissions from a file to another.
Expects as parameters:
=over
=item 1.
string of the path to the file which permissions will be copied from.
=item 2.
string of the path to the file which permissions will be copied to.
=back
Returns 1 if everything works as expected.
=head2 perm_get
Gets the permissions from a file.
Expects as parameter the path to the source file.
Returns an array reference with only the permissions values, as returned by C.
=head2 perm_set
Sets the permission on a file.
Expects as parameters:
=over
=item 1.
The path to the file where the permissions should be applied to.
=item 2.
An array reference with the permissions (see C)
=back
Returns 1 if everything goes fine.
Ignore errors here, as we can't change uid/gid unless we're the superuser (see LIMITATIONS section).
=head2 remove
$arch->remove($logic_path);
Removes a file from the tarball. C<$logic_path> is the virtual path
of the file within the tarball.
=head2 list_all
my $items = $arch->list_all();
Returns a reference to a (possibly huge) array of items in the
tar file. Each item is a reference to an array, containing two
elements: the relative path of the item in the tar file and the
physical path to the unpacked file or directory on disk.
To iterate over the list, the following construct can be used:
# Get a huge list with all entries
for my $entry (@{$arch->list_all()}) {
my($tar_path, $real_path) = @$entry;
print "Tarpath: $tar_path Tempfile: $real_path\n";
}
If the list of items in the tar file is big, use C and
C instead of C.
=head2 list_next
my ($tar_path, $phys_path, $type) = $arch->list_next();
Returns the next item in the tar file. It returns a list of three scalars:
the relative path of the item in the tar file, the physical path
to the unpacked file or directory on disk, and the type of the entry
(f=file, d=directory, l=symlink). Note that by default,
B won't display directories, unless the C
parameter is set when running the constructor.
=head2 write
$arch->write($tarfile, $compress);
Write out the tarball by tarring up all temporary files and directories
and store it in C<$tarfile> on disk. If C<$compress> holds a true value,
compression is used.
=head2 is_gnu
$arch->is_gnu();
Checks if the tar executable is a GNU tar by running 'tar --version'
and parsing the output for "GNU".
Returns true or false (in Perl terms).
=head2 is_bsd
$arch->is_bsd();
Same as C, but for BSD.
=head2 ramdisk_mount
Mounts a RAM disk.
It executes the C program under the hood to mount a RAM disk.
Expects as parameter a hash with options to mount the RAM disk, like:
=over
=item *
C
=item *
C (most probably C)
=item *
C
=back
Returns 1 if everything goes fine.
Be sure to check the L for full details on using RAM disks.
=head2 ramdisk_unmount
Unmounts the RAM disk already mounted with C.
Don't expect parameters and returns 1 if everything goes fine.
Be sure to check the L for full details on using RAM disks.
=head1 Using RAM Disks
On Linux, it's quite easy to create a RAM disk and achieve tremendous
speedups while untarring or modifying a tarball. You can either
create the RAM disk by hand by running
# mkdir -p /mnt/myramdisk
# mount -t tmpfs -o size=20m tmpfs /mnt/myramdisk
and then feeding the RAM disk as a temporary directory to
B, like
my $tar = Archive::Tar::Wrapper->new( tmpdir => '/mnt/myramdisk' );
or using B's built-in option C:
my $tar = Archive::Tar::Wrapper->new(
ramdisk => {
type => 'tmpfs',
size => '20m', # 20 MB
},
);
Only drawback with the latter option is that creating the RAM disk needs
to be performed as root, which often isn't desirable for security reasons.
For this reason, B offers a utility functions that
mounts the RAM disk and returns the temporary directory it's located in:
# Create new ramdisk (as root):
my $tmpdir = Archive::Tar::Wrapper->ramdisk_mount(
type => 'tmpfs',
size => '20m', # 20 MB
);
# Delete a ramdisk (as root):
Archive::Tar::Wrapper->ramdisk_unmount();
Optionally, the C command accepts a C parameter
pointing to a temporary directory for the RAM disk if you wish to set it
yourself instead of letting B create it automatically.
=head1 KNOWN LIMITATIONS
=over
=item *
Currently, only C programs supporting the C option (for
compressing/decompressing) are supported. Future version will use
C alternatively.
=item *
Currently, you can't add empty directories to a tarball directly.
You could add a temporary file within a directory, and then
C the file.
=item *
If you delete a file, the empty directories it was located in
stay in the tarball. You could try to C them and delete
them. This will be fixed, though.
=item *
Filenames containing newlines are causing problems with the list
iterators. To be fixed.
=item *
If you ask B to add a file to a tarball, it copies it
into a temporary directory and then calls the system tar to wrap up that
directory into a tarball.
This approach has limitations when it comes to file permissions: If the file to
be added belongs to a different user/group, B will adjust
the uid/gid/permissions of the target file in the temporary directory to
reflect the original file's settings, to make sure the system tar will add it
like that to the tarball, just like a regular tar run on the original file
would. But this will fail of course if the original file's uid is different
from the current user's, unless the script is running with superuser rights.
The tar program by itself (without B) works differently:
It'll just make a note of a file's uid/gid/permissions in the tarball (which it
can do without superuser rights) and upon extraction, it'll adjust the
permissions of newly generated files if the -p option is given (default for
superuser).
=back
=head1 BUGS
B doesn't currently handle filenames with embedded
newlines.
=head2 Microsoft Windows support
Support on Microsoft Windows is limited.
Versions below Windows 10 will not be supported for desktops, and for servers
only Windows 2012 and above.
The GNU C program doesn't work properly with the current interface of
B.
You must use the C and make sure it appears first in the C
environment variable than the GNU tar (if it is installed). See
L for details about how to download and
install C, or go to L
for a direct download. Be sure to look for the C program package to
install it as well.
Windows 10 might come already with C program already installed. Please
search for that on the appropriate page (Microsoft keeps changing the link to
keep track of it here).
Having spaces in the path string to the tar program might be an issue too.
Although there is some effort in terms of workaround it, you best might avoid it
completely by installing in a different path than C.
Installing both C and C in C will probably be enough
when running the installers.
=head1 SEE ALSO
=over
=item *
Linux Gazette article from Ben Okopnik, L.
=back
=head1 BUGS
Please report any bugs or feature requests on the bugtracker website
L
When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired
feature.
=head1 AUTHORS
=over 4
=item *
Mike Schilli
=item *
Alceu Rodrigues de Freitas Junior
=back
=head1 CONTRIBUTORS
=for stopwords Chris Weyl David Cantrell Precious Graham Knop intrigeri Kent Fredric Mark Gardner Mike Schilli Mohammad S Anwar Paulo Custodio Randy Stauner Sanko Robinson Shoichi Kaji
=over 4
=item *
Chris Weyl
=item *
David Cantrell
=item *
David Precious
=item *
Graham Knop
=item *
intrigeri
=item *
Kent Fredric
=item *
Mark Gardner
=item *
Mike Schilli
=item *
Mohammad S Anwar
=item *
Paulo Custodio
=item *
Randy Stauner
=item *
Sanko Robinson
=item *
Shoichi Kaji
=back
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2024 by Mike Schilli.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007
=cut
Archive-Tar-Wrapper-0.42/xt/performance-small.t 000644 000766 000024 00000011243 14664064025 021703 0 ustar 00gknop staff 000000 000000 use warnings;
use strict;
use File::Temp qw(tempfile tempdir);
use Test::More tests => 1;
use lib 'xt/lib';
use ATWDumbbench;
use constant BATCH_SIZE => 1000;
use constant TOTAL_FILES => 10;
my $bench = ATWDumbbench->new(
target_rel_precision => 0.005,
initial_runs => BATCH_SIZE,
);
my $dir = tempdir( CLEANUP => 1 );
my $template = 'foobar-XXXXXXXX';
for ( 1 .. TOTAL_FILES ) {
my ( $fh, $filename ) = tempfile( $template, DIR => $dir );
print $fh rand();
close($fh);
}
my $regex = qr/^\.\.?$/;
$bench->add_instances(
Dumbbench::Instance::PerlSub->new(
name => 'with grep',
code => sub {
opendir my $dir_h, $dir or die "Cannot open $dir: $!";
my @top_entries = grep { $_ !~ /^\.\.?$/ } readdir $dir_h;
closedir($dir_h);
}
),
Dumbbench::Instance::PerlSub->new(
name => 'with grep and compiled regex',
code => sub {
opendir my $dir_h, $dir or die "Cannot open $dir: $!";
my @top_entries = grep { $_ !~ $regex } readdir $dir_h;
closedir($dir_h);
}
),
Dumbbench::Instance::PerlSub->new(
name => 'with eq',
code => sub {
opendir my $dir_h, $dir or die "Cannot open $dir: $!";
my @temp = readdir($dir_h);
closedir($dir_h);
my @top_entries;
for (@temp) {
next if ( ( $_ eq '.' ) or ( $_ eq '..' ) );
push( @top_entries, $_ );
}
}
),
Dumbbench::Instance::PerlSub->new(
name => 'with enhanced eq',
code => sub {
opendir my $dir_h, $dir or die "Cannot open $dir: $!";
my @temp = readdir($dir_h);
closedir($dir_h);
my @top_entries;
for (@temp) {
next
if ( ( length($_) <= 2 )
and ( ( $_ eq '.' ) or ( $_ eq '..' ) ) );
push( @top_entries, $_ );
}
}
),
Dumbbench::Instance::PerlSub->new(
name => 'with enhanced eq mark2',
code => sub {
opendir my $dir_h, $dir or die "Cannot open $dir: $!";
my @temp = readdir($dir_h);
closedir($dir_h);
my @top_entries;
my $counter = 0;
my $found = 0;
for (@temp) {
$counter++;
if ( ( length($_) <= 2 )
and ( ( $_ eq '.' ) or ( $_ eq '..' ) ) )
{
$found++;
if ( $found < 2 ) {
next;
}
else {
push( @top_entries, splice( @temp, $counter ) );
last;
}
}
push( @top_entries, $_ );
}
}
),
Dumbbench::Instance::PerlSub->new(
name => 'with enhanced eq mark3',
code => sub {
opendir my $dir_h, $dir or die "Cannot open $dir: $!";
my @temp = readdir($dir_h);
closedir($dir_h);
my ( $first, $second );
my $index = 0;
my $found = 0;
for (@temp) {
if ( ( length($_) <= 2 )
and ( ( $_ eq '.' ) or ( $_ eq '..' ) ) )
{
if ( $found < 1 ) {
$first = $index;
$found++;
$index++;
next;
}
else {
$second = $index;
last;
}
}
else {
$index++;
}
}
splice( @temp, $first, 1, 1 );
splice( @temp, $second, 1, 1 );
}
),
Dumbbench::Instance::PerlSub->new(
name => 'sort and shift',
code => sub {
opendir( my $dir_h, $dir ) or die "Cannot open $dir: $!";
my @top_entries = readdir($dir_h);
closedir($dir_h);
@top_entries = sort(@top_entries);
# removing the '.' and '..' entries
shift(@top_entries);
shift(@top_entries);
}
),
);
note('This will take a while... hang on.');
$bench->run;
diag( $bench->report_as_text );
TODO: {
local $TODO = 'Too many variables to account for success';
# See https://metacpan.org/pod/Number::WithError#full_cmp
my $method_name = 'with enhanced eq mark3';
cmp_ok(
$bench->measurements(),
'<=',
$bench->get_measure($method_name),
"'$method_name' is the fastest methods."
);
}
Archive-Tar-Wrapper-0.42/xt/performance.t 000644 000766 000024 00000010746 14664064025 020604 0 ustar 00gknop staff 000000 000000 use warnings;
use strict;
use File::Temp qw(tempfile tempdir);
use Test::More tests => 1;
use lib 'xt/lib';
use ATWDumbbench;
use constant BATCH_SIZE => 1000;
my $bench = ATWDumbbench->new(
target_rel_precision => 0.005,
initial_runs => BATCH_SIZE,
);
my $dir = tempdir( CLEANUP => 1 );
my $template = 'foobar-XXXXXXXX';
for ( 1 .. BATCH_SIZE ) {
my ( $fh, $filename ) = tempfile( $template, DIR => $dir );
print $fh rand();
close($fh);
}
my $regex = qr/^\.\.?$/;
$bench->add_instances(
Dumbbench::Instance::PerlSub->new(
name => 'with grep',
code => sub {
opendir my $dir_h, $dir or die "Cannot open $dir: $!";
my @top_entries = grep { $_ !~ /^\.\.?$/ } readdir $dir_h;
closedir($dir_h);
}
),
Dumbbench::Instance::PerlSub->new(
name => 'with grep and compiled regex',
code => sub {
opendir my $dir_h, $dir or die "Cannot open $dir: $!";
my @top_entries = grep { $_ !~ $regex } readdir $dir_h;
closedir($dir_h);
}
),
Dumbbench::Instance::PerlSub->new(
name => 'with eq',
code => sub {
opendir my $dir_h, $dir or die "Cannot open $dir: $!";
my @temp = readdir($dir_h);
closedir($dir_h);
my @top_entries;
for (@temp) {
next if ( ( $_ eq '.' ) or ( $_ eq '..' ) );
push( @top_entries, $_ );
}
}
),
Dumbbench::Instance::PerlSub->new(
name => 'with enhanced eq',
code => sub {
opendir my $dir_h, $dir or die "Cannot open $dir: $!";
my @temp = readdir($dir_h);
closedir($dir_h);
my @top_entries;
for (@temp) {
next
if ( ( length($_) <= 2 )
and ( ( $_ eq '.' ) or ( $_ eq '..' ) ) );
push( @top_entries, $_ );
}
}
),
Dumbbench::Instance::PerlSub->new(
name => 'with enhanced eq mark2',
code => sub {
opendir my $dir_h, $dir or die "Cannot open $dir: $!";
my @temp = readdir($dir_h);
closedir($dir_h);
my @top_entries;
my $counter = 0;
my $found = 0;
for (@temp) {
$counter++;
if ( ( length($_) <= 2 )
and ( ( $_ eq '.' ) or ( $_ eq '..' ) ) )
{
$found++;
if ( $found < 2 ) {
next;
}
else {
push( @top_entries, splice( @temp, $counter ) );
last;
}
}
push( @top_entries, $_ );
}
}
),
Dumbbench::Instance::PerlSub->new(
name => 'with enhanced eq mark3',
code => sub {
opendir my $dir_h, $dir or die "Cannot open $dir: $!";
my @temp = readdir($dir_h);
closedir($dir_h);
my ( $first, $second );
my $index = 0;
my $found = 0;
for (@temp) {
if ( ( length($_) <= 2 )
and ( ( $_ eq '.' ) or ( $_ eq '..' ) ) )
{
if ( $found < 1 ) {
$first = $index;
$found++;
$index++;
next;
}
else {
$second = $index;
last;
}
}
else {
$index++;
}
}
splice( @temp, $first, 1 );
splice( @temp, ( $second - 1 ), 1 );
}
),
Dumbbench::Instance::PerlSub->new(
name => 'sort and shift',
code => sub {
opendir( my $dir_h, $dir ) or die "Cannot open $dir: $!";
my @top_entries = readdir($dir_h);
closedir($dir_h);
@top_entries = sort(@top_entries);
# removing the '.' and '..' entries
shift(@top_entries);
shift(@top_entries);
}
),
);
note('This will take a while... hang on.');
$bench->run;
diag( $bench->report_as_text );
my $method_name = 'with enhanced eq mark3';
cmp_ok(
$bench->measurements(),
'<=',
$bench->get_measure($method_name),
"'$method_name' is the fastest method."
);
Archive-Tar-Wrapper-0.42/xt/author/ 000755 000766 000024 00000000000 14664064025 017410 5 ustar 00gknop staff 000000 000000 Archive-Tar-Wrapper-0.42/xt/release/ 000755 000766 000024 00000000000 14664064025 017526 5 ustar 00gknop staff 000000 000000 Archive-Tar-Wrapper-0.42/xt/lib/ 000755 000766 000024 00000000000 14664064025 016654 5 ustar 00gknop staff 000000 000000 Archive-Tar-Wrapper-0.42/xt/lib/ATWDumbbench.pm 000644 000766 000024 00000002502 14664064025 021454 0 ustar 00gknop staff 000000 000000 package ATWDumbbench;
use strict;
use warnings;
use parent 'Dumbbench';
sub new {
my ( $class, @args ) = @_;
my $self = $class->SUPER::new(@args);
$self->{atw_measure_map} = {};
return $self;
}
sub measurements {
my $self = shift;
return ( sort { $a <=> $b } values( %{ $self->{atw_measure_map} } ) )[0];
}
sub get_measure {
my ( $self, $name ) = @_;
return $self->{atw_measure_map}->{$name};
}
sub get_map {
my ($self) = @_;
return $self->{atw_measure_map};
}
sub report_as_text {
my ($self) = @_;
my $formatted;
foreach my $instance ( $self->instances ) {
my $result = $instance->result;
my $result_str = Dumbbench::unscientific_notation($result);
my $mean = $result->raw_number;
my $sigma = $result->raw_error->[0];
my $name = $instance->_name_prefix;
$self->{atw_measure_map}->{ $instance->name } = $result->number;
$formatted .= sprintf(
"%sRan %u iterations (%u outliers).\n",
$name,
scalar( @{ $instance->timings } ),
scalar( @{ $instance->timings } ) - $result->nsamples
);
$formatted .=
sprintf( "%sRounded run time per iteration: %s (%.1f%%)\n",
$name, $result_str, $sigma / $mean * 100 );
}
return $formatted;
}
1;
Archive-Tar-Wrapper-0.42/xt/release/changes_has_content.t 000644 000766 000024 00000002100 14664064025 023701 0 ustar 00gknop staff 000000 000000 use Test::More tests => 2;
note 'Checking Changes';
my $changes_file = 'Changes';
my $newver = '0.42';
my $trial_token = '-TRIAL';
my $encoding = 'UTF-8';
SKIP: {
ok(-e $changes_file, "$changes_file file exists")
or skip 'Changes is missing', 1;
ok(_get_changes($newver), "$changes_file has content for $newver");
}
done_testing;
sub _get_changes
{
my $newver = shift;
# parse changelog to find commit message
open(my $fh, '<', $changes_file) or die "cannot open $changes_file: $!";
my $changelog = join('', <$fh>);
if ($encoding) {
require Encode;
$changelog = Encode::decode($encoding, $changelog, Encode::FB_CROAK());
}
close $fh;
my @content =
grep { /^$newver(?:$trial_token)?(?:\s+|$)/ ... /^\S/ } # from newver to un-indented
split /\n/, $changelog;
shift @content; # drop the version line
# drop unindented last line and trailing blank lines
pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ );
# return number of non-blank lines
return scalar @content;
}
Archive-Tar-Wrapper-0.42/xt/author/mojibake.t 000644 000766 000024 00000000151 14664064025 021353 0 ustar 00gknop staff 000000 000000 #!perl
use strict;
use warnings qw(all);
use Test::More;
use Test::Mojibake;
all_files_encoding_ok();
Archive-Tar-Wrapper-0.42/xt/author/kwalitee.t 000644 000766 000024 00000000275 14664064025 021406 0 ustar 00gknop staff 000000 000000 # this test was generated with Dist::Zilla::Plugin::Test::Kwalitee 2.12
use strict;
use warnings;
use Test::More 0.88;
use Test::Kwalitee 1.21 'kwalitee_ok';
kwalitee_ok();
done_testing;
Archive-Tar-Wrapper-0.42/xt/author/no-tabs.t 000644 000766 000024 00000001036 14664064025 021140 0 ustar 00gknop staff 000000 000000 use strict;
use warnings;
# this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.15
use Test::More 0.88;
use Test::NoTabs;
my @files = (
'lib/Archive/Tar/Wrapper.pm',
't/00-compile.t',
't/00-report-prereqs.dd',
't/00-report-prereqs.t',
't/001Basic.t',
't/002Mult.t',
't/003Dirs.t',
't/004Utf8.t',
't/005Cwd.t',
't/006DirPerms.t',
't/007bzip.t',
't/009compressed.t',
't/010openbsd.t',
't/011remdots.t',
't/012tarinfo.t'
);
notabs_ok($_) foreach @files;
done_testing;
Archive-Tar-Wrapper-0.42/xt/author/critic.t 000644 000766 000024 00000000201 14664064025 021043 0 ustar 00gknop staff 000000 000000 #!perl
use strict;
use warnings;
use Test::Perl::Critic (-profile => ".perlcriticrc") x!! -e ".perlcriticrc";
all_critic_ok();
Archive-Tar-Wrapper-0.42/xt/author/minimum-version.t 000644 000766 000024 00000000154 14664064025 022733 0 ustar 00gknop staff 000000 000000 use strict;
use warnings;
use Test::More;
use Test::MinimumVersion;
all_minimum_version_from_metayml_ok();
Archive-Tar-Wrapper-0.42/xt/author/test-version.t 000644 000766 000024 00000000637 14664064025 022245 0 ustar 00gknop staff 000000 000000 use strict;
use warnings;
use Test::More;
# generated by Dist::Zilla::Plugin::Test::Version 1.09
use Test::Version;
my @imports = qw( version_all_ok );
my $params = {
is_strict => 0,
has_version => 1,
multiple => 0,
};
push @imports, $params
if version->parse( $Test::Version::VERSION ) >= version->parse('1.002');
Test::Version->import(@imports);
version_all_ok;
done_testing;
Archive-Tar-Wrapper-0.42/xt/author/eol.t 000644 000766 000024 00000001070 14664064025 020352 0 ustar 00gknop staff 000000 000000 use strict;
use warnings;
# this test was generated with Dist::Zilla::Plugin::Test::EOL 0.19
use Test::More 0.88;
use Test::EOL;
my @files = (
'lib/Archive/Tar/Wrapper.pm',
't/00-compile.t',
't/00-report-prereqs.dd',
't/00-report-prereqs.t',
't/001Basic.t',
't/002Mult.t',
't/003Dirs.t',
't/004Utf8.t',
't/005Cwd.t',
't/006DirPerms.t',
't/007bzip.t',
't/009compressed.t',
't/010openbsd.t',
't/011remdots.t',
't/012tarinfo.t'
);
eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files;
done_testing;
Archive-Tar-Wrapper-0.42/xt/author/pod-syntax.t 000644 000766 000024 00000000252 14664064025 021702 0 ustar 00gknop staff 000000 000000 #!perl
# This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests.
use strict; use warnings;
use Test::More;
use Test::Pod 1.41;
all_pod_files_ok();
Archive-Tar-Wrapper-0.42/xt/author/portability.t 000644 000766 000024 00000000163 14664064025 022137 0 ustar 00gknop staff 000000 000000 use strict;
use warnings;
use Test::More;
use Test::Portability::Files;
options(test_one_dot => 0);
run_tests();
Archive-Tar-Wrapper-0.42/xt/author/distmeta.t 000644 000766 000024 00000000223 14664064025 021404 0 ustar 00gknop staff 000000 000000 #!perl
# This file was automatically generated by Dist::Zilla::Plugin::MetaTests.
use strict;
use warnings;
use Test::CPAN::Meta;
meta_yaml_ok();
Archive-Tar-Wrapper-0.42/xt/author/pod-spell.t 000644 000766 000024 00000001061 14664064025 021472 0 ustar 00gknop staff 000000 000000 use strict;
use warnings;
use Test::More;
# generated by Dist::Zilla::Plugin::Test::PodSpelling 2.007005
use Test::Spelling 0.12;
use Pod::Wordlist;
add_stopwords();
all_pod_files_spelling_ok( qw( bin lib ) );
__DATA__
Alceu
Anwar
Archive
Cantrell
Chris
Custodio
David
Fredric
Freitas
Gardner
Graham
Junior
Kaji
Kent
Knop
Mark
Mike
Mohammad
Paulo
Precious
Randy
Robinson
Rodrigues
Sanko
Schilli
Shoichi
Stauner
Tar
Weyl
Wrapper
cpan
cweyl
david
davidp
de
github
glasswalk3r
haarg
intrigeri
kentfredric
lib
mjg
mohammad
pauloscustodio
randy
sanko
skaji
Archive-Tar-Wrapper-0.42/xt/author/cpan-changes.t 000644 000766 000024 00000000344 14664064025 022125 0 ustar 00gknop staff 000000 000000 use strict;
use warnings;
# this test was generated with Dist::Zilla::Plugin::Test::CPAN::Changes 0.013
use Test::More 0.96 tests => 1;
use Test::CPAN::Changes;
subtest 'changes_ok' => sub {
changes_file_ok('Changes');
};
Archive-Tar-Wrapper-0.42/xt/author/pod-coverage.t 000644 000766 000024 00000000365 14664064025 022154 0 ustar 00gknop staff 000000 000000 #!perl
# This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests.
use strict;
use warnings;
use Test::Pod::Coverage 1.08;
use Pod::Coverage::TrustPod;
all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' });
Archive-Tar-Wrapper-0.42/t/006DirPerms.t 000644 000766 000024 00000002167 14664064025 020064 0 ustar 00gknop staff 000000 000000 use warnings;
use strict;
use Log::Log4perl qw(:easy);
use Config;
Log::Log4perl->easy_init($ERROR);
use File::Temp qw(tempfile tempdir);
my $TARDIR = "data";
$TARDIR = "t/$TARDIR" unless -d $TARDIR;
use Test::More tests => 4;
BEGIN { use_ok('Archive::Tar::Wrapper') }
my $arch = Archive::Tar::Wrapper->new();
my $tempdir = tempdir( CLEANUP => 1 );
my ( $fh, $tarfile ) = tempfile( UNLINK => 1 );
# to get predictable results regardless of local umask settings
umask 0002;
my $foodir = "$tempdir/foo";
my $foofile = "$foodir/foofile";
mkdir "$foodir";
chmod 0710, $foodir;
open(my $fh2, '>', $foofile) or die "Cannot open $foofile ($!)";
print $fh2 "blech\n";
close($fh2);
ok( $arch->add( "foo/foofile", $foofile ), "adding file" );
# Make a tarball
ok( $arch->write($tarfile), "Tarring up" );
SKIP: {
skip 'Permissions are too different on Microsoft Windows', 1 if ($Config{osname} eq 'MSWin32' || $Config{osname} eq 'msys');
my $tarread = Archive::Tar::Wrapper->new();
$tarread->read($tarfile);
my $loc = $tarread->locate("foo");
my $mode = ( stat $loc )[2] & 07777;
is $mode, 0710, "check dir mode";
}
Archive-Tar-Wrapper-0.42/t/005Cwd.t 000644 000766 000024 00000001061 14664064025 017043 0 ustar 00gknop staff 000000 000000 use warnings;
use strict;
use File::Temp qw(tempfile);
use Cwd;
use Test::More tests => 4;
BEGIN { use_ok('Archive::Tar::Wrapper') }
my $cwd = getcwd();
my $evaled = eval {
my $arch = Archive::Tar::Wrapper->new();
my ( undef, $filename ) = tempfile( UNLINK => 1 );
unlink $filename; # OPEN => 0 gave a stupid warning
# attempt to generate error from tar by not adding any files
$arch->write( $filename, 9 );
1;
};
is $@, '', 'no error';
is $evaled, 1, 'survived eval';
is getcwd(), $cwd, 'still in original directory';
Archive-Tar-Wrapper-0.42/t/010openbsd.t 000644 000766 000024 00000002121 14664064025 017752 0 ustar 00gknop staff 000000 000000 use warnings;
use strict;
use Test::More tests => 7;
use Archive::Tar::Wrapper;
use File::Spec;
use File::Which qw(which);
SKIP: {
skip 'This test is designed to run only on OpenBSD', 7
unless ( $^O eq 'openbsd' );
my $tar_path = which('tar');
note("tar available at $tar_path");
my $tar = Archive::Tar::Wrapper->new( tar_read_options => 'p' );
is( $tar->{tar_read_options},
'-p', 'tar parameters on OpenBSD have a "-" prefix' );
ok( $tar->_is_openbsd(), 'correctly identify the OS' );
is_deeply(
$tar->_read_openbsd_opts('z'),
[ "$tar_path", '-z', '-x', '-p' ],
'got correct options for gziped tarball'
) or diag( explain( $tar->_read_openbsd_opts('z') ) );
is_deeply(
$tar->_read_openbsd_opts('j'),
[ "$tar_path", '-j', '-x', '-p' ],
'got correct options for bziped tarball'
) or diag( explain( $tar->_read_openbsd_opts('j') ) );
for my $file (qw(bar.tar foo.tgz foo.tar.bz2)) {
ok( $tar->read( File::Spec->catfile( 't', 'data', $file ) ),
"read tarball $file" );
}
}
Archive-Tar-Wrapper-0.42/t/007bzip.t 000644 000766 000024 00000001724 14664064025 017302 0 ustar 00gknop staff 000000 000000 use warnings;
use strict;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($ERROR);
use File::Which;
use File::Temp qw(tempfile);
use Test::More tests => 5;
use File::Spec;
BEGIN { use_ok('Archive::Tar::Wrapper') }
my $bzip2_path = which('bzip2');
unless ( defined($bzip2_path) ) {
diag(
'bzip2 is not available on your path! Beware that you will not be able to pack/unpack tarballs compressed with it, please install it ASAP!'
);
}
SKIP: {
skip 'bzip2 program is not available', 4 unless ( defined($bzip2_path) );
my $TARDIR = 'data';
$TARDIR = File::Spec->catdir( 't', $TARDIR ) unless -d $TARDIR;
umask(0);
my $arch = Archive::Tar::Wrapper->new();
ok( $arch->read( File::Spec->catfile( $TARDIR, 'foo.tar.bz2' ) ),
"opening compressed tarfile" );
ok( $arch->locate('001Basic.t'), "find 001Basic.t" );
ok( $arch->locate('./001Basic.t'), "find ./001Basic.t" );
ok( !$arch->locate('nonexist'), "find nonexist" );
}
Archive-Tar-Wrapper-0.42/t/004Utf8.t 000644 000766 000024 00000002070 14664064025 017154 0 ustar 00gknop staff 000000 000000 use warnings;
use strict;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($ERROR);
use File::Temp qw(tempfile);
my $TARDIR = "data";
$TARDIR = "t/$TARDIR" unless -d $TARDIR;
use Test::More tests => 6;
BEGIN { use_ok('Archive::Tar::Wrapper') }
SKIP: {
if ( $] < 5.008 ) {
skip "Unicode tests skipped with perl < 5.8", 5;
}
umask(0);
my $arch = Archive::Tar::Wrapper->new();
ok( $arch->read("$TARDIR/foo.tgz"), "opening compressed tarfile" );
# Add data
my $data = "this is data \x{00fc}";
ok( $arch->add( "foo/bar/string", \$data, { binmode => ":utf8" } ),
"adding data" );
# Make a tarball
my ( $fh, $filename ) = tempfile( UNLINK => 1 );
ok( $arch->write($filename), "Tarring up" );
# List
my $a2 = Archive::Tar::Wrapper->new();
ok( $a2->read($filename), "Reading in new tarball" );
my $f1 = $a2->locate("foo/bar/string");
open FILE, "<:utf8", $f1 or die "Cannot open $f1";
my $got_data = join '', ;
close FILE;
is( $got_data, $data, "comparing file utf8 data" );
}
Archive-Tar-Wrapper-0.42/t/009compressed.t 000644 000766 000024 00000001650 14664064025 020502 0 ustar 00gknop staff 000000 000000 use warnings;
use strict;
use Test::More;
use Archive::Tar::Wrapper;
use File::Spec;
use File::Copy;
use File::Temp qw(tempdir);
my @dirs = qw(t data);
my $arch = Archive::Tar::Wrapper->new();
is( $arch->is_compressed( File::Spec->catdir( @dirs, 'foo.tgz' ) ),
'z', 'Identify a gziped tarball' );
is( $arch->is_compressed( File::Spec->catdir( @dirs, 'foo.tar.bz2' ) ),
'j', 'Identify a bziped tarball' );
is( $arch->is_compressed( File::Spec->catdir( @dirs, 'bar.tar' ) ),
'', 'Identify non-compressed tarball' );
ok( !$arch->is_compressed( File::Spec->catdir( @dirs, 'bar.tar' ) ),
'Non-compressed tarball evaluate as false' );
my $temp_dir = tempdir( CLEANUP => 1 );
my $gziped_undercover = File::Spec->catdir( $temp_dir, 'foo' );
copy( File::Spec->catdir( @dirs, 'foo.tgz' ), $gziped_undercover );
is( $arch->is_compressed($gziped_undercover),
'z', 'Detects gziped file without file extension' );
done_testing;
Archive-Tar-Wrapper-0.42/t/002Mult.t 000644 000766 000024 00000001540 14664064025 017246 0 ustar 00gknop staff 000000 000000 use warnings;
use strict;
use Log::Log4perl qw(:easy);
use File::Path;
use File::Temp qw(tempfile tempdir);
my $TARDIR = "data";
$TARDIR = "t/$TARDIR" unless -d $TARDIR;
my $TMPDIR = tempdir( CLEANUP => 1 );
use Test::More tests => 5;
BEGIN { use_ok('Archive::Tar::Wrapper') }
my $arch = Archive::Tar::Wrapper->new( tmpdir => $TMPDIR );
ok( $arch->read("$TARDIR/foo.tgz"), "opening compressed tarfile" );
ok( $arch->read("$TARDIR/bar.tar"), "opening uncompressed" );
my $elements = $arch->list_all();
my $got = join " ", sort map { $_->[0] } @$elements;
is( $got, "001Basic.t bar/bar.dat bar/foo.dat", "file check" );
# Iterators
$arch->list_reset();
my @elements = ();
while ( my $entry = $arch->list_next() ) {
push @elements, $entry->[0];
}
$got = join " ", sort @elements;
is( $got, "001Basic.t bar/bar.dat bar/foo.dat", "file check via iterator" );
Archive-Tar-Wrapper-0.42/t/00-compile.t 000644 000766 000024 00000002644 14664064025 017756 0 ustar 00gknop staff 000000 000000 use 5.006;
use strict;
use warnings;
# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058
use Test::More;
plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
my @module_files = (
'Archive/Tar/Wrapper.pm'
);
# no fake home requested
my @switches = (
-d 'blib' ? '-Mblib' : '-Ilib',
);
use File::Spec;
use IPC::Open3;
use IO::Handle;
open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
my @warnings;
for my $lib (@module_files)
{
# see L
my $stderr = IO::Handle->new;
diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
$^X, @switches, '-e', "require q[$lib]"))
if $ENV{PERL_COMPILE_TEST_DEBUG};
my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
binmode $stderr, ':crlf' if $^O eq 'MSWin32';
my @_warnings = <$stderr>;
waitpid($pid, 0);
is($?, 0, "$lib loaded ok");
shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
and not eval { +require blib; blib->VERSION('1.01') };
if (@_warnings)
{
warn @_warnings;
push @warnings, @_warnings;
}
}
is(scalar(@warnings), 0, 'no warnings found')
or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING};
Archive-Tar-Wrapper-0.42/t/00-report-prereqs.t 000644 000766 000024 00000013601 14664064025 021313 0 ustar 00gknop staff 000000 000000 #!perl
use strict;
use warnings;
# This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.029
use Test::More tests => 1;
use ExtUtils::MakeMaker;
use File::Spec;
# from $version::LAX
my $lax_version_re =
qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )?
|
(?:\.[0-9]+) (?:_[0-9]+)?
) | (?:
v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )?
|
(?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)?
)
)/x;
# hide optional CPAN::Meta modules from prereq scanner
# and check if they are available
my $cpan_meta = "CPAN::Meta";
my $cpan_meta_pre = "CPAN::Meta::Prereqs";
my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic
# Verify requirements?
my $DO_VERIFY_PREREQS = 1;
sub _max {
my $max = shift;
$max = ( $_ > $max ) ? $_ : $max for @_;
return $max;
}
sub _merge_prereqs {
my ($collector, $prereqs) = @_;
# CPAN::Meta::Prereqs object
if (ref $collector eq $cpan_meta_pre) {
return $collector->with_merged_prereqs(
CPAN::Meta::Prereqs->new( $prereqs )
);
}
# Raw hashrefs
for my $phase ( keys %$prereqs ) {
for my $type ( keys %{ $prereqs->{$phase} } ) {
for my $module ( keys %{ $prereqs->{$phase}{$type} } ) {
$collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module};
}
}
}
return $collector;
}
my @include = qw(
);
my @exclude = qw(
);
# Add static prereqs to the included modules list
my $static_prereqs = do './t/00-report-prereqs.dd';
# Merge all prereqs (either with ::Prereqs or a hashref)
my $full_prereqs = _merge_prereqs(
( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ),
$static_prereqs
);
# Add dynamic prereqs to the included modules list (if we can)
my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml';
my $cpan_meta_error;
if ( $source && $HAS_CPAN_META
&& (my $meta = eval { CPAN::Meta->load_file($source) } )
) {
$full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs);
}
else {
$cpan_meta_error = $@; # capture error from CPAN::Meta->load_file($source)
$source = 'static metadata';
}
my @full_reports;
my @dep_errors;
my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs;
# Add static includes into a fake section
for my $mod (@include) {
$req_hash->{other}{modules}{$mod} = 0;
}
for my $phase ( qw(configure build test runtime develop other) ) {
next unless $req_hash->{$phase};
next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING});
for my $type ( qw(requires recommends suggests conflicts modules) ) {
next unless $req_hash->{$phase}{$type};
my $title = ucfirst($phase).' '.ucfirst($type);
my @reports = [qw/Module Want Have/];
for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) {
next if grep { $_ eq $mod } @exclude;
my $want = $req_hash->{$phase}{$type}{$mod};
$want = "undef" unless defined $want;
$want = "any" if !$want && $want == 0;
if ($mod eq 'perl') {
push @reports, ['perl', $want, $]];
next;
}
my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required";
my $file = $mod;
$file =~ s{::}{/}g;
$file .= ".pm";
my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC;
if ($prefix) {
my $have = MM->parse_version( File::Spec->catfile($prefix, $file) );
$have = "undef" unless defined $have;
push @reports, [$mod, $want, $have];
if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) {
if ( $have !~ /\A$lax_version_re\z/ ) {
push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)";
}
elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) {
push @dep_errors, "$mod version '$have' is not in required range '$want'";
}
}
}
else {
push @reports, [$mod, $want, "missing"];
if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) {
push @dep_errors, "$mod is not installed ($req_string)";
}
}
}
if ( @reports ) {
push @full_reports, "=== $title ===\n\n";
my $ml = _max( map { length $_->[0] } @reports );
my $wl = _max( map { length $_->[1] } @reports );
my $hl = _max( map { length $_->[2] } @reports );
if ($type eq 'modules') {
splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl];
push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports;
}
else {
splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl];
push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports;
}
push @full_reports, "\n";
}
}
}
if ( @full_reports ) {
diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports;
}
if ( $cpan_meta_error || @dep_errors ) {
diag "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n";
}
if ( $cpan_meta_error ) {
my ($orig_source) = grep { -f } 'MYMETA.json', 'MYMETA.yml';
diag "\nCPAN::Meta->load_file('$orig_source') failed with: $cpan_meta_error\n";
}
if ( @dep_errors ) {
diag join("\n",
"\nThe following REQUIRED prerequisites were not satisfied:\n",
@dep_errors,
"\n"
);
}
pass('Reported prereqs');
# vim: ts=4 sts=4 sw=4 et:
Archive-Tar-Wrapper-0.42/t/00-report-prereqs.dd 000644 000766 000024 00000004635 14664064025 021446 0 ustar 00gknop staff 000000 000000 do { my $x = {
'configure' => {
'requires' => {
'ExtUtils::MakeMaker' => '0',
'File::Which' => '0'
}
},
'develop' => {
'requires' => {
'Dumbbench' => '0',
'Pod::Coverage::TrustPod' => '0',
'Test::CPAN::Changes' => '0.19',
'Test::CPAN::Meta' => '0',
'Test::EOL' => '0',
'Test::Kwalitee' => '1.21',
'Test::MinimumVersion' => '0',
'Test::Mojibake' => '0',
'Test::More' => '0.88',
'Test::NoTabs' => '0',
'Test::Perl::Critic' => '0',
'Test::Pod' => '1.41',
'Test::Pod::Coverage' => '1.08',
'Test::Portability::Files' => '0',
'Test::Spelling' => '0.12',
'Test::Version' => '1'
}
},
'runtime' => {
'requires' => {
'Cwd' => '0',
'File::Temp' => '0',
'File::Which' => '0',
'IPC::Run' => '0',
'Log::Log4perl' => '0',
'perl' => '5.008001'
}
},
'test' => {
'recommends' => {
'CPAN::Meta' => '2.120900'
},
'requires' => {
'ExtUtils::MakeMaker' => '0',
'File::Spec' => '0',
'IO::Handle' => '0',
'IPC::Open3' => '0',
'Test::More' => '0'
}
}
};
$x;
} Archive-Tar-Wrapper-0.42/t/003Dirs.t 000644 000766 000024 00000001357 14664064025 017235 0 ustar 00gknop staff 000000 000000 use warnings;
use strict;
use Log::Log4perl qw(:easy);
use File::Path;
use File::Temp qw(tempfile tempdir);
my $TARDIR = "data";
$TARDIR = "t/$TARDIR" unless -d $TARDIR;
my $TMPDIR = tempdir( CLEANUP => 1 );
use Test::More tests => 4;
BEGIN { use_ok('Archive::Tar::Wrapper') }
rmdir $TMPDIR if -d $TMPDIR;
mkdir $TMPDIR or die "Cannot mkdir $TMPDIR";
END { rmtree $TMPDIR }
my $arch = Archive::Tar::Wrapper->new( tmpdir => $TMPDIR, dirs => 1 );
ok( $arch->read("$TARDIR/bar.tar"), "opening compressed tarfile" );
my $e = $arch->list_all();
my $all = join " ", sort( map { $_->[0] } @$e );
is( $all, ". bar bar/bar.dat bar/foo.dat", "list all dirs" );
my @dirs = map { $_->[0] } grep { $_->[2] eq "d" } @$e;
is( "@dirs", ". bar", "dirs only" );
Archive-Tar-Wrapper-0.42/t/data/ 000755 000766 000024 00000000000 14664064025 016627 5 ustar 00gknop staff 000000 000000 Archive-Tar-Wrapper-0.42/t/011remdots.t 000644 000766 000024 00000001613 14664064025 020003 0 ustar 00gknop staff 000000 000000 use strict;
use warnings;
use Archive::Tar::Wrapper;
use Test::More;
my $arch = Archive::Tar::Wrapper->new();
my @samples = (
[ '.', '..', 'ar', 'ogoyugfyu', 'iohoihoi', 'pojij' ],
[ '..', 'buiv', 'oihoih', 'oiggf', '.' ],
[ 'uiuig', 'ohphpui', 'nuvg', '.', '..' ],
[ 'uigbyufcd', 'opkokj', '.', '..', 'ugoig' ],
[ 'uigbyufcd', '.', 'opkokj', '..', 'ugoig' ]
);
plan tests => scalar(@samples);
for my $sample_ref (@samples) {
$arch->_rem_dots($sample_ref);
ok( has_no_dots($sample_ref), 'all dots removed' )
or diag( explain($sample_ref) );
}
sub has_no_dots {
my $entries_ref = shift;
my $result = 1;
for my $entry ( @{$entries_ref} ) {
if ( ( $entry eq '.' ) or ( $entry eq '..' ) ) {
$result = 0;
last;
}
}
return $result;
}
Archive-Tar-Wrapper-0.42/t/001Basic.t 000644 000766 000024 00000013531 14664064025 017350 0 ustar 00gknop staff 000000 000000 use warnings;
use strict;
use Log::Log4perl qw(:easy);
use FindBin qw($Bin);
use File::Temp qw(tempfile);
use Test::More tests => 24;
use File::Spec;
use Config;
use constant TARDIR => 't/data';
Log::Log4perl->easy_init($ERROR);
BEGIN { use_ok('Archive::Tar::Wrapper') }
umask(0);
my $arch = Archive::Tar::Wrapper->new();
diag( 'Is GNU tar? ' . ( $arch->is_gnu ? 'yes' : 'no' ) );
diag( 'Is BSD tar? ' . ( $arch->is_bsd ? 'yes' : 'no' ) );
diag( 'Version information: ' . $arch->{version_info} );
diag( 'tar error: ' . $arch->{tar_error_msg} )
if ( ( defined( $arch->{tar_error_msg} ) )
and ( $arch->{tar_error_msg} ne '' ) );
ok( $arch->read( File::Spec->catfile( TARDIR, 'foo.tgz' ) ),
'can open the compressed tar file' );
ok( $arch->locate('001Basic.t'),
'find 001Basic.t inside the compressed tar file' );
ok( $arch->locate('./001Basic.t'),
'find ./001Basic.t inside the compressed tar file' );
ok( !$arch->locate('nonexist'),
'cannot find non-existing file inside the compressed tar file' );
note('Add a new file');
my $tmploc = $arch->locate('001Basic.t');
ok( $arch->add( 'foo/bar/baz', $tmploc ), 'adding file' );
note('Add data');
my $data = 'this is data';
ok( $arch->add( 'foo/bar/string', \$data ), 'adding data' );
ok( $arch->locate('foo/bar/baz'), 'find added file' );
ok( $arch->add( 'foo/bar/permtest', $tmploc, { perm => oct(770) } ),
'adding file' );
note('Make a tarball');
my ( $fh, $filename ) = tempfile( UNLINK => 1 );
ok( $arch->write($filename), 'Tarring up' );
my $a2 = Archive::Tar::Wrapper->new();
ok( $a2->read($filename), 'Reading in new tarball' );
my @got = sort( map { $_->[0] } @{ $a2->list_all } );
is_deeply(
\@got,
[qw(001Basic.t foo/bar/baz foo/bar/permtest foo/bar/string)],
'list_all() returns the expected list elements'
);
my $f1 = $a2->locate('001Basic.t');
my $f2 = $a2->locate('foo/bar/baz');
ok( -s $f1 > 0, 'Checking tarball files sizes' );
ok( -s $f2 > 0, 'Checking tarball files sizes' );
is( -s $f1, -s $f2, 'Comparing tarball files sizes' );
my $f3 = $a2->locate('foo/bar/permtest');
my $expected_permission = sprintf '%3o', ( ( stat($f3) )[2] & 07777 );
SKIP: {
skip 'Permissions are too different on Microsoft Windows', 1
if ( $Config{osname} eq 'MSWin32' || $Config{osname} eq 'msys' );
is( $expected_permission, '770',
'testing file permission inside the tarball' );
}
my $f4 = $a2->locate('foo/bar/string');
open( my $in, '<', $f4 ) or die "Cannot open $f4: $!";
my $got_data = join '', <$in>;
close($in);
is( $got_data, $data, 'comparing file data' );
note('Iterators');
# required to be invoke since list_all() invokes it implicit
$arch->list_reset();
my @elements;
while ( my $entry = $arch->list_next() ) {
push @elements, $entry->[0];
}
@elements = sort(@elements);
is_deeply(
\@elements,
[qw(001Basic.t foo/bar/baz foo/bar/permtest foo/bar/string)],
'list_next() produce the expected results'
);
note('Check optional file names for extraction');
my $a3 = Archive::Tar::Wrapper->new();
$a3->read( File::Spec->catfile( TARDIR, 'bar.tar' ), 'bar/bar.dat' );
my $elements = $a3->list_all();
is( scalar(@$elements), 1, 'only one file extracted' );
is( $elements->[0]->[0],
'bar/bar.dat', 'the first index of list_all() has the expected data' );
note('Ask for non-existent files in tarball');
my $a4 = Archive::Tar::Wrapper->new();
# Suppress the warning
Log::Log4perl->get_logger('')->level($FATAL);
SKIP: {
skip( 'FreeBSD\'s tar is too lenient - skipping', 1 )
if ( $^O =~ /freebsd/i );
skip 'bsdtar is too lenient', 1 if ( $a4->is_bsd() );
my $rc = $a4->read( File::Spec->catfile( TARDIR, 'bar.tar' ),
'bar/bar.dat', 'quack/schmack' );
is( $rc, undef, 'Failure to ask for non-existent files' );
}
note('Testing original file permissions');
umask(022);
my $a5 = Archive::Tar::Wrapper->new( tar_read_options => 'p', );
$a5->read( File::Spec->catfile( TARDIR, 'bar.tar' ) );
$f1 = $a5->locate('bar/bar.dat');
# TODO: add conditional note on Alpine to indicate that tar over there is broken regarding -p parameter
if ($f1) {
$expected_permission = sprintf '%3o', ( ( stat($f1) )[2] & 07777 );
}
else {
note( 'Could not locate "bar/bar.dat" inside the tarball '
. File::Spec->catfile( TARDIR, 'bar.tar' ) );
}
SKIP: {
skip 'Cannot check permissions on a non-existent file', 1 unless $f1;
skip 'Permissions are too different on Microsoft Windows', 1
if ( $Config{osname} eq 'MSWin32' || $Config{osname} eq 'msys' );
is( $expected_permission, '664', 'testing file permissions' )
or diag(
'Known bug in Alpine Linux: https://bugs.busybox.net/show_bug.cgi?id=16102'
);
}
SKIP: {
# gnu options
my $a6 =
Archive::Tar::Wrapper->new( tar_gnu_read_options => ['--numeric-owner'],
);
my $is_gnu = $a6->is_gnu();
note( $a6->{tar_error_msg} ) if ( defined( $a6->{tar_error_msg} ) );
skip 'Only with gnu tar', 1 unless $is_gnu;
$a6->read( File::Spec->catfile( TARDIR, 'bar.tar' ) );
$f1 = $a6->locate('bar/bar.dat');
ok( defined $f1, 'numeric owner works' );
}
note('Trying to test GNU options');
SKIP: {
# gnu options
my $tar =
Archive::Tar::Wrapper->new( tar_gnu_write_options => ['--exclude=foo'], );
my $is_gnu = $tar->is_gnu();
note( $tar->{tar_error_msg} ) if ( defined( $tar->{tar_error_msg} ) );
skip 'Test is possible only with GNU tar', 1 unless $is_gnu;
my $file_loc = $tar->locate('001Basic.t');
$tar->add( 'foo/bar/baz', $0 );
$tar->add( 'boo/bar/baz', $0 );
my ( $fh, $filename ) = tempfile( UNLINK => 1, SUFFIX => '.tgz' );
$tar->write( $filename, 1 );
my $tar_read = Archive::Tar::Wrapper->new();
$tar_read->read($filename);
for my $entry ( @{ $tar_read->list_all() } ) {
my ( $tar_path, $real_path ) = @$entry;
is( $tar_path, 'boo/bar/baz', 'foo excluded' );
}
}
Archive-Tar-Wrapper-0.42/t/012tarinfo.t 000644 000766 000024 00000003551 14664064025 017774 0 ustar 00gknop staff 000000 000000 use warnings;
use strict;
use Test::More tests => 14;
use Archive::Tar::Wrapper;
use File::Which;
note('Testing generic interface, should work everywhere');
my $arch = Archive::Tar::Wrapper->new();
# don't use those methods yourself outside these tests!
$arch->_acquire_tar_info();
ok( $arch->{version_info}, 'has version_info' );
is( $arch->{tar_exit_code}, 0, 'has the expected exit code' );
ok( defined( $arch->is_gnu ), 'is_gnu is defined' );
ok( defined( $arch->is_bsd ), 'is_bsd is defined' );
note('Specific tests for OpenBSD');
SKIP: {
skip 'Not running on OpenBSD', 3 unless ( $^O eq 'openbsd' );
$arch = Archive::Tar::Wrapper->new();
ok( !$arch->is_gnu, 'tar is not GNU' );
ok( $arch->is_bsd, 'tar is BSD' );
like(
$arch->{version_info},
qr/^Information not available/,
'OpenBSD has no version information'
);
}
note('All tests below are forced to ignore platform specific details');
note('Faking error when executing tar');
my $tar;
if ( $^O eq 'MSWin32' ) {
$tar = which('bsdtar');
}
else {
$tar = which('tar');
}
$arch = Archive::Tar::Wrapper->new( osname => 'yadayadayada', tar => $tar );
$arch->{tar_exit_code} = 42;
$arch->_acquire_tar_info(1);
like(
$arch->{version_info},
qr/^Information not available/,
'on error has no version information'
);
is( $arch->is_gnu, 0, 'is not GNU tar' );
is( $arch->is_bsd, 0, 'is not BSD tar' );
note('Testing as GNU tar');
$arch->{tar_exit_code} = 0;
$arch->{version_info} = 'tar (GNU tar) 1.26';
$arch->_acquire_tar_info(1);
ok( $arch->is_gnu, 'tar is GNU' );
ok( !$arch->is_bsd, 'tar is not BSD' );
note('Testing as BSD tar');
$arch->{tar_exit_code} = 1;
$arch->{version_info} = 'bsdtar 2.4.12 - libarchive 2.4.12';
$arch->{tar} = '/usr/bin/bsdtar';
$arch->_acquire_tar_info(1);
ok( !$arch->is_gnu, 'tar is not GNU' );
ok( $arch->is_bsd, 'tar is BSD' );
Archive-Tar-Wrapper-0.42/t/data/bar.tar 000644 000766 000024 00000024000 14664064025 020077 0 ustar 00gknop staff 000000 000000 bar/ 0040775 0000764 0000764 00000000000 10270764326 012041 5 ustar mschilli mschilli bar/bar.dat 0100664 0000764 0000764 00000000013 10270764317 013266 0 ustar mschilli mschilli barcontent
bar/foo.dat 0100664 0000764 0000764 00000000013 10270764326 013305 0 ustar mschilli mschilli foocontent
Archive-Tar-Wrapper-0.42/t/data/foo.tar.bz2 000644 000766 000024 00000000544 14664064025 020621 0 ustar 00gknop staff 000000 000000 BZh91AY&SYR.@ „ÿ„Ä \ã}Ÿv§€ûïÿª 0:Ò`Ñ©ˆ m@M@A¢&“j0šz&š4@ QLˆh 4€ M±xœÆ" 󨀅 ©N0Ô’¨ 9T!;Úb>*©ª“2¦¯VŽé™÷1ndBûo×*›2ŸtýNf1¯6æœc)F} ˜€”î{{J º‡Í£I–5È`ØmS£
ƒË+% YbƒS\b,)€òŒ±½¾8 g5°ãfŽˆAu£Igwóé™òzY
à†µAºÇ'D¾<©MzHÉÎx€ dÁ~œ #`±R{Îâo܈™¢¢(İû¤’J“g½×kˆÖ³Ï !\}biÂ\G¥À]+
‰pÐF_ÇÂje#xBYAñ¥øZ´Å"X4N£ï
“š8ÂÚÅÜ‘N$Ô‹ Archive-Tar-Wrapper-0.42/t/data/foo.tgz 000644 000766 000024 00000000530 14664064025 020136 0 ustar 00gknop staff 000000 000000 ‹ © ZB íÒËjÂ@à¬óŒebƒÂ؆V*R¨ÝÔÒ¥Œajss&©Hé»wE°t£-…ÿ[$“œ.9„1,ŒŠz…s6Ìgl³†ƒÃ{=ö/Ÿõûƒ€1ÿbhóý!bç;Ò—ÒB9‰‰^U«ïr?Õÿ©æI¸MšKS)U!é%Ót£m»Þ$çs¡9Ö"Ï¥¶±åŽfj-éqßMºŒr‘^ÛZœHe
©{Q–„å–FÒVèT¥+3ªŸL¡UTìÇ÷ÙŠs{ ªýi³õ¸f×¹…nX½]¨T^ëv2~šÚD=¿úfÎg™–Õä4[ä±Hmq<™Þ=Ð;ÙÌ"[{í£Íhwèîcë~µ^²£–°9º:Þ»n˜Êg“uªf¹L½Æ¦Ñz)tÃþúW €_ö ÁŒ¥î (