Alien::Package(3pm)

πŸ’– Alien::Package(3pm) πŸ’–

okay bestie, welcome to the User Contributed Perl Documentation page for Alien::Package, and lemme tell you, this one is a whole vibe πŸ¦‹


✨ NAME ✨

Alien::Package β€” it's an object that represents a package, and yes that's the entire name, no notes πŸ’…


🌸 DESCRIPTION 🌸

okay so picture this: it's a perl object class, right? and it represents a package in an internal format that alien can actually work with. the package in question could be a deb, a rpm, a tgz, or a slp package, etc. like, the whole squad 🫢

objects in this class hold a bunch of metadata fields from the actual packages they represent, plus some fields that point at the actual contents of the package. and they can do three iconic things:

  1. examine an actual package sitting on disk and populate those fields from it
  2. build the actual package using the data stored in the fields

and honestly? a typical use of this object class is genuinely giving main character energy:

  • instantiate an object from a class derived from this one, like Alien::Package::Rpm ⭐
  • feed the object an rpm file, which populates all of its fields
  • rebless the object into the destination class, like Alien::Package::Deb πŸ”₯
  • ask the object to build a package

and boom πŸ’₯ the package has been converted. slay.


πŸŽ€ FIELDS πŸŽ€

so these fields are of course really just methods that all act the same way: you can pass a value in to set them, or just get the value of the field back if you pass nothing in. child classes may override these fields to process input data or to format output data. the general rule (iykyk) is that input data gets modified to get things into a package-independent form, which is how the data is stored in the fields. and when the value of a field is read, it too may be modified before it's returned, to change things into a form that's more suitable for that particular type of package. cute, right? 🌈

  • name β€” the package's name.
  • version β€” the package's upstream version.
  • release β€” the package's distribution specific release number.
  • arch β€” the package's architecture, in the format used by Debian.
  • maintainer β€” the package's maintainer.
  • depends β€” the package's dependencies. ⚠️ only dependencies that should exist on all target distributions can go in here tho (ie: lsb).
  • group β€” the section the package is in.
  • summary β€” a one line description of the package.
  • description β€” a longer description of the package. may contain multiple paragraphs.
  • copyright β€” a short statement of copyright.
  • origformat β€” what format the package was originally in.
  • distribution β€” what distribution family the package originated from.
  • binary_info β€” whatever the package's package tool says when told to display info about the package.
  • conffiles β€” a reference to a list of all the conffiles in the package.
  • files β€” a reference to a list of all the files in the package.
  • changelogtext β€” the text of the changelog
  • postinst β€” the postinst script of the package.
  • postrm β€” the postrm script of the package.
  • preinst β€” the preinst script of the package.
  • prerm β€” the prerm script of the package.
  • usescripts β€” only use the above scripts fields when generating the package if this is set to a true value.
  • unpacked_tree β€” points to a directory where the package has been unpacked.
  • owninfo β€” if set this will be a reference to a hash, with filename as key, that holds ownership/group information for files that cannot be represented on the filesystem. typically that's because the owners or groups just don't exist yet πŸ™ˆ it will be set at unpack time.
  • modeinfo β€” if set this will be a reference to a hash, with filename as key, that holds mode information for setuid files that have an entry in owninfo. it will be set at unpack time.

πŸ’œ METHODS πŸ’œ

  • init β€” this is called by new(). it's a handy place to set fields, etc, without having to write your own new() method. lowkey a lifesaver.
  • install β€” simply installs a package file. the filename is passed. ⚠️ this has to be overridden in child classes.
  • test β€” test a package file. the filename is passed, and it should return an array of lines of test results. child classes may implement this.
  • filename β€” set/get the filename of the package the object represents. when it's set, it performs a scan of the file, populating most other fields with data from it. (this is just a stub; child classes should override it to actually do something.) πŸ’€
  • scripts β€” returns a list of all non-empty maintainer scripts in the package.
  • scan β€” this method scans the file associated with an object, and populates as many other fields as it can with data from it.
  • unpack β€” this method unpacks the package into a temporary directory. it sets unpacked_tree to point to that directory. (this is just a stub method that makes a directory below the current working directory, and sets unpacked_tree to point to it. it should be overridden by child classes to actually unpack the package as well.)
  • prep β€” this method causes the object to prepare a build tree to be used in building the object. it expects that the unpack method has already been called. it takes the tree generated by that method, and mangles it somehow, to produce a suitable build tree. (this is just a stub method that all child classes should override.) 🧚
  • cleantree β€” this method should clean the unpacked_tree of any effects the prep and build methods might have on it.
  • revert β€” this method should ensure that the object is in the same state it was in before the prep method was called.
  • build β€” this method takes a prepped build tree, and simply builds a package from it. it should put the package in the current directory, and should return the filename of the generated package. (this is just a stub method that all child classes should override.) πŸ”₯
  • incrementrelease β€” this method should increment the release field of the package by the specified number.
  • DESTROY β€” when an object is destroyed, it cleans some stuff up. in particular, if the package was unpacked, it's time now to wipe out the temporary directory. bye bestie 😭
  • AUTOLOAD β€” handles all fields, by creating accessor methods for them the first time they are accessed. magical tbh ✨

πŸ‘‘ CLASS DATA πŸ‘‘

  • $Alien::Package::verbose β€” if set to a nonzero value, the shell commands that are run should be output. if set to a value greater than 1, any output of the commands should also be output.

🌈 CLASS METHODS 🌈

these methods can be called on either an object or on the class itself. flexible queen πŸ’…

  • new β€” returns a new object of this class. optionally, you can pass in named parameters that specify the values of any fields in the class.
  • checkfile β€” pass it a filename, and it will return true if it looks like the file is a package of the type handled by the class.
  • do β€” runs a shell command. is verbose or not depending on the value of $Alien::Package::verbose. returns true if the command succeeds, false on failure.
  • runpipe β€” this is similar to backticks, but honors $Alien::Package::verbose, logging the command run if asked to. the output of the command is returned. the first parameter controls what to do on error. if it's true then any errors from the command will be ignored (and $? will be set). if it's false, errors will abort alien. 🫣 so yeah, choose wisely.

πŸ’– AUTHOR πŸ’–

Joey Hess <joey@kitenet.net>


and that's the whole page bestie, no cap πŸŽ€ this was perl v5.40.1, dated 2025-10-08, and it's the Alien::Package(3pm) page β€” go forth and convert some packages, you absolute icon πŸ‘‘βœ¨πŸ¦‹

πŸ“¦ where this page comes from