Debian::Rules(3pm)

✨ Debian::Rules ✨

okay bestie, welcome to Debian::Rules β€” the Perl module that gives you handy manipulation of debian/rules πŸ’… it's living in the User Contributed Perl Documentation corner of the 3pm section, and honestly? she's iconic.


🌸 NAME 🌸

Debian::Rules β€” handy manipulation of debian/rules πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

my $r = Debian::Rules->new('debian/rules');

my $r = Debian::Rules->new( { filename => 'debian/rules' } );

$r->is_dhtiny && print "Using the latest and greatest\n";
$r->is_quiltified && print "quilt rules the rules\n";

# file contents changed externally
$r->parse;

$r->drop_quilt;

$r->write;  # or undef($r);

πŸ’– DESCRIPTION πŸ’–

so like, sometimes you just need to know whether debian/rules is using the dh(1) tiny variant, or whether it's all integrated with quilt(1). bestie, Debian::Rules has you β€” she provides the facilities to check that, plus adding/removing quilt integration. so versatile. so slay. ✨

and the modified contents? they get written to the file either via the write method, or when the object reference goes out of scope (via DESTROY). no cap, she cleans up after herself 🫢


πŸŽ€ CONSTRUCTOR πŸŽ€

new is the standard Class::Accessor constructor β€” except that if only one, non-reference argument is provided, it's treated as a value for the filename field. cute, right?

if a file name is given, the constructor calls read to read the file contents into memory. πŸ“–

⚠️ important bestie: one of filename or lines is mandatory. don't come to her with neither, she will not be okay.

🌈 FIELDS 🌈

  • filename β€” contains the file name of the rules file πŸ—‚οΈ
  • lines β€” a reference to an array pointing to the rules file. initialized by new πŸ’«

πŸ‘‘ METHODS πŸ‘‘

parse

parses the rules file and stores its findings for later use πŸ” she gets called automatically by is_dhtiny and is_quiltified. the result of the parsing gets cached, and subsequent calls to is_XXX use that cache. so if the file contents changed and you need a fresh vibe check, just call parse again πŸ’…

is_dhtiny

returns true if the contents of the rules file seem to use the so-called tiny variant offered by dh(1). tiny rules are detected by the presence of these two lines:

%:
    dh $@

(any options on the dh command line are ignored β€” she's not nosy like that πŸ™ˆ)

is_quiltified

returns true if the contents of the rules file indicate that quilt(1) is used. various styles of quilt integration are detected:

  • dh --with=quilt
  • quilt.make with $(QUILT_STAMPFN) and unpatch targets.

drop_quilt

removes quilt(1) integration 🧹 both the dh(1) tiny style (dh --with=quilt) and the traditional approach ($(QUILT_STAMPFN) and unpatch) are detected and removed. bye quilt πŸ‘‹

read [file name]

replaces the current rules content with the content of filename. if filename isn't given, she uses the value of the filename member.

write [filename]

writes the in-memory contents to filename. if not given, uses the value of the filename member.

if lines points to an empty array, the file is removed πŸ’€ (yes, gone gone).


copyright belongs to:

  • Copyright (C) 2009, 2010 Damyan Ivanov <dmn@debian.org>
  • Copyright (C) 2014, 2026 gregor herrmann <gregoa@debian.org>

so this program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. periodt πŸ’…

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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. πŸ›οΈ


and that's the whole thing bestie β€” this was Debian::Rules(3pm) from perl v5.40.1, dated 2026-05-08. go forth and manipulate those rules, you absolute main character πŸ«Άβœ¨πŸ’–

πŸ“¦ where this page comes from