MDV::Packdrakeng(3)

πŸ“¦
version 1.13 Β· 2 versions
, in fedora 43

πŸ’– MDV::Packdrakeng πŸ’–

okay bestie, sit down, we're learning MDV::Packdrakeng β€” it's a Simple Archive Extractor/Builder and it lives in the User Contributed Perl Documentation section of your man pages, under the name MDV::Packdrakeng(3). she's giving very much "quiet library module that just works" energy and honestly? obsessed.


✨ SYNOPSIS ✨

use MDV::Packdrakeng;

# creating an archive
$pack = MDV::Packdrakeng->new(archive => "myarchive.cz");
# Adding a few files
$pack->add("/path/", "file1", "file2");
# Adding an unamed file
open($handle, "file");
$pack->add_virtual("filename", $handle);
close($handle);

$pack = undef;

# extracting an archive
$pack = MDV::Packdrakeng->open(archive => "myarchive.cz");
# listing files
$pack->list();
# extracting few files
$pack->extract("/path/", "file1", "file2");
# extracting data into a file handle
open($handle, "file");
$pack->extract_virtual($handle, "filename");
close($handle);

like. look at that. build a thing, yeet some files in, close it, open it back up, pull stuff out. that's the whole vibe fr fr 🌸


πŸ¦‹ DESCRIPTION πŸ¦‹

MDV::Packdrakeng is a simple indexed archive builder and extractor using standard compression methods. that's it, that's the girl. she builds, she extracts, she uses compression like every other normal archiver, no drama, no cap.


πŸŽ€ IMPLEMENTATION πŸŽ€

okay this is the part where it gets juicy. compressed data are stored by block. so picture this:

 UncompresseddatA1UncompresseddatA2 UncompresseddatA3UncompresseddatA4
 |--- size  1 ---||--- size  2 ---| |--- size  3 ---||--- size  4 ---|
 |<-offset1       |<-offset2        |<-offset3       |<-offset4

and that lil arrangement gives you:

 CompresseD1CompresseD2 CompresseD3CompresseD4
 |--- c. size 1, 2 ---| |--- c. size 3, 4 ---|
 |<-c. offset 1, 2      |<-c. offset 3, 4

so basically multiple uncompressed things get smooshed into one compressed block, and the offsets do the bookkeeping. a new block is started when its size exceeds the block_size value. periodt. πŸ’…

then, the compressed data are followed by the table of contents (toc), which is just a simple list of packed files. every file name is terminated by the "\n" character:

dir1
dir2
...
dirN
symlink1
point_file1
symlink2
point_file2
...
...
symlinkN
point_fileN
file1
file2
...
fileN

then comes the file sizes β€” and heads up, 4 values are stored for each file: offset into archive of compressed block, size of compressed block, offset into block of the file, and the file's size. four things. per file. every file. she's thorough like that. πŸ‘‘

finally, the archive contains a 64-byte trailer with info about the toc and the archive itself:

'cz[0', strings 4 bytes
number of directory, 4 bytes
number of symlinks, 4 bytes
number of files, 4 bytes
the toc size, 4 bytes
the uncompression command, string of 40 bytes length
'0]cz', string 4 bytes

🌈 FUNCTIONS 🌈

πŸ’œ new(%options)

creates a new archive. brand new baby archive, freshly born. 🫢 options are:

  • archive β€” the file name of the archive. if the file doesn't exist, it will be created; else it will be owerwritten. yeah. overwritten. say bye to whatever was there. see "open".
  • compress β€” the application to use to compress. if unspecified, gzip is used.
  • uncompress β€” the application used to extract data from archive. this option is useless if you're opening an existing archive (unless you want to force it, main character move). if unset, this value is based on the compress command followed by the -d argument.
  • extern β€” if you're using gzip, by default MDV::Packdrakeng will use perl-zlib to save system ressources. this option forces MDV::Packdrakeng to use the external gzip command instead. this has no meaning with other compress programs, because internal functions are not implemented yet. (not yet!! future plans!!)
  • comp_level β€” the compression level passed as an argument to the compression program. by default, this is set to 6.
  • block_size β€” the limit size after which we start a new compressed block. default value is 400KB. set it to 0 to be sure a new block will be started for each packed file, and -1 to never start a new block. > be aware that a big block size will slow down the file extraction. like, it's giving slow. plan accordingly bestie.
  • quiet β€” do not output anything. shut up. 🀫
  • debug β€” print debug messages.

πŸ’œ open(%options)

opens an existing archive for extracting or adding files.

the uncompression command is found into the archive, and the compression command is deduced from it. detective work. iconic.

if you add files, a new compressed block will be started even if the last block is smaller than the value of the block_size option. and if some compression options can't be found in the archive, the new preference will be applied.

options are the same than for the new() function. πŸ’–

πŸ’œ MDV::Packdrakeng->add_virtual($type, $filename, $data)

adds a file into archive according passed information. $type gives the type of the file:

  • 'd' β€” the file will be a directory, store as '$filename'. $data is not used.
  • 'l' β€” the file will be a symlink named $filename, pointing to the file whose path is given by the string $data.
  • 'f' β€” the file is a normal file, $filename will be its name, $data is either an handle to open file, data will be read from current position to the end of file, either a string to push as the content of the file.

πŸ’œ MDV::Packdrakeng->add($prefix, @files)

adds @files into archive located into $prefix. only directory, files and symlink will be added. for each file, the path should be relative to $prefix and is stored as is.

πŸ’œ MDV::Packdrakeng->extract_virtual(*HANDLE, $filename)

extracts $filename data from archive into the *HANDLE. $filename should be a normal file. (so like, not a directory, not a symlink, a real one. respect the rules babe.)

πŸ’œ MDV::Packdrakeng->extract($destdir, @files)

extracts @files from the archive into $destdir prefix.

πŸ’œ MDV::Packdrakeng->getcontent()

returns three arrayrefs describing files files into archive β€” respectively directory list, files list and symlink list. three little lists, one for each girlie. πŸ’…

πŸ’œ MDV::Packdrakeng->infofile($file)

returns type and information about a given file into the archive; that is:

  • 'f' and the the size of the file for a plain file
  • 'l' and the linked file for a symlink
  • 'd' and undef for a directory
  • undef if the file can't be found into archive. 😭

πŸ’œ MDV::Packdrakeng->infofile($handle)

print to $handle (STDOUT if not specified) the content of the archive.

πŸ’œ MDV::Packdrakeng->dumptoc($handle)

print to $handle (STDOUT if not specified) the table of content of the archive.


⭐ CHANGELOG ⭐

1.10

  • use an oo code
  • add_virtual() now accept a string as file content

glow up. ✨


πŸ‘‘ AUTHOR πŸ‘‘

Olivier Thauvin <nanardon@mandriva.org>, Rafael Garcia-Suarez <rgarciasuarez@mandriva.com>

Copyright (c) 2005 Mandriva

This module is a from scratch-rewrite of the original packdrake utility. Its format is fully compatible with the old packdrake. full compatibility, no cap, she speaks the old language fluently πŸ¦‹


🌸 LICENSE 🌸

This program is free software; you can redistribute it and/or modify it under the terms of GNU General Public License as published by the Free Software Foundation; either version 2 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.

If you do not have a copy of the GNU General Public License write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


okay that's the whole page bestie, you're officially educated πŸ’– this was perl v5.42.0, dated 2025-07-25, and yes she's still out here being MDV::Packdrakeng(3). go build an archive, slay, bye πŸŽ€βœ¨

πŸ“¦ where this page comes from