DPKG::...:Entry(3pm)

πŸ“¦
version 0.03 Β· 2 versions
  • 0.03 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.03 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ¦‹ DPKG::Parse::Entry β€” the manual page, but make it make sense πŸ’…

okay bestie so this is DPKG::Parse::Entry, from the User Contributed Perl Documentation collection, and it's literally the thing that reads a Package-style entry for you. no cap.

✨ NAME ✨

DPKG::Parse::Entry β€” Parse a Package style entry πŸŽ€


🌸 SYNOPSIS 🌸

    use DPKG::Parse::Entry;

    my $data = <<EOH;
 Package: kernel-image-2.6.12.2
 Source: kernel-source-2.6.12.2
 Version: wrk01
 Priority: optional
 Section: base
 Maintainer: Jamie Heilman <jamie@marchex.com>
 Depends: coreutils | fileutils (>= 4.0)
 Suggests: lilo (>= 19.1) | grub, fdutils, kernel-doc-2.6.12.2 | kernel-source-2.6.12.2
 Provides: kernel-image, kernel-image-2.6
 Architecture: i386
 Filename: packages/./kernel-image-2.6.12.2_wrk01_i386.deb
 Size: 4293154
 Installed-Size: 10312
 MD5sum: 2acf846b127b71a1fa1143214b2b85a9
 Description: Linux kernel binary image for version 2.6.12.2.
 EOH

    my $entry = DPKG::Parse::Entry->new('data' => $data);

    print $entry->package . " " . $entry->version . "\n";

    $entry->package("kernel-foobar");

like. look at her go. 🫢


πŸ’– DESCRIPTION πŸ’–

okay so DPKG::Parse::Entry parses a dpkg "Package" file entry, and it makes a whole new DPKG::Parse::Entry instance out of it. the way that works is: you hand over the contents, starting with a "Package:" line, as the 'data' argument to new. that's it, that's the whole intro.

and then?? after that, all the data gets populated as lowercased instance methods. so if we used the example above to build an $entry object, we'd be sitting pretty with:

   $entry->package == "kernel-image-2.6.12.2"
   $entry->size    == 4293154
   $entry->md5sum  == 2acf846b127b71a1fa1143214b2b85a9

iconic. ✨

now, DPKG::Parse::Entry will skip any attribute it does not know about. no drama, no crash, it just moves on. and if you're nosy (respectfully πŸ’…) you can see exactly what it skipped by passing a true value to the 'debug' option to new().

it should know all the attributes present in a Packages, available, and status file. periodt.

SEE ALSO vibes: peep DPKG::Parse::Status, DPKG::Parse::Available, and DPKG::Parse::Packages for more info on how to easily generate DPKG::Parse::Entry objects. they do the heavy lifting so you don't have to. 😌

🧚 METHODS 🧚

πŸŽ€ Accessor Methods πŸŽ€

the following accessor methods correspond directly to the values found in the parsed Package block β€” with one exception: "-" characters are replaced with "_". so "build-essential" becomes "build_essential". yes bestie, that's the whole trick, it's giving very straightforward of her. πŸ’…

the accessors are:

    architecture
    bugs
    build_essential
    conflicts
    config_version
    conffiles
    depends
    description
    enhances
    essential
    filename
    installed_size
    maintainer
    md5sum
    origin
    package
    priority
    provides
    pre_depends
    recommends
    replaces
    size
    source
    section
    suggests
    status
    task
    tag
    url
    version

thirty of them. all lowercase. all yours. πŸ¦‹


⭐ new('data' => $data, 'debug' => 1) ⭐

creates a new DPKG::Parse::Entry object. πŸŽ‰

'data' should be a scalar that contains the text of a dpkg-style Package entry. that's the main character of this whole operation.

and if the 'debug' flag is set, we will Carp about entries we don't have accessors for β€” so like, it'll yell at you (politely, in Perl) about the stuff it couldn't name. super useful for vibe checking your input, fr fr.


🌈 parse('data' => $data); 🌈

does the actual parsing of the Package block given to new(). the real work. the labor. πŸ™ˆ

heads up bestie: it probably should only be called once per object. don't be weird about it. πŸ’€

and that's the page!! this was perl v5.34.0, dated 2022-06-13, and it's the DPKG::...:Entry(3pm) manpage from User Contributed Perl Documentation. slay, go parse something. πŸ’–βœ¨πŸ‘‘

πŸ“¦ where this page comes from