logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Debian::Rules - handy manipulation of debian/rules

Constructor

       "new" is the standard Class::Accessor constructor, with the exception that if only one, non-reference
       argument is provided, it is treated as a value for the filename field.

       If a file name is given, the constructor calls "read" to read the file contents into memory.

       One of filename or lines is mandatory.

Description

       Some times, one needs to know whether debian/rules uses the dh(1) tiny variant, or whether it is
       integrated with quilt(1). Debian::Rules provides facilities to check this, as well as adding/removing
       quilt integration.

       Modified contents are written to file either vie the "write" method, or when the object reference goes
       out of scope (via DESTROY).

Fields

       filename
           Contains the file name of the rules file.

       lines
           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. Called automatically by is_dhtiny and
           is_quiltified. The result of the parsing is cached and subsequent calls to "is_XXX" use the cache. To
           force cache refresh (for example if the contents of the file have been changed), 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 the following two lines:

               %:
                       dh $@

           (any options on the "dh" command line ignored).

       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.
       add_quilt
           Integrates  quilt(1)  into  the  rules.  For  dh(1)  tiny  rules  (as  determined   by   "is_dhtiny")
           "--with=quilt"  is  added  to  every  "dh"  invocation.  For  the  more traditional variant, quilt is
           integrated via quilt.make and its "$(QUILT_STAMPFN)" and "unpatch" targets.

       drop_quilt
           Removes  quilt(1)  integration.  Both  dh(1)  tiny  style   ("dh   --with=quilt")   and   traditional
           ("$(QUILT_STAMPFN)" and "unpatch") approaches are detected and removed.

       read [filename]
           Replaces  the  current rules content with the content of filename. If filename is not given, uses the
           value of the "filename" member.

       write [filename]
           Writes the in-memory contents filename. If not given, uses the value of the "filename" member.

           If "lines" points to an empty array, the file is removed.

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->add_quilt;
           $r->drop_quilt;

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

See Also