[config-package-dev] [PATCH] transform: let users pick local files as source

Luca Boccassi luca.boccassi at gmail.com
Mon Jun 19 09:18:35 EDT 2017


On Fri, 2017-06-16 at 16:22 -0400, Geoffrey Thomas wrote:
> On Sun, 11 Jun 2017, Luca Boccassi wrote:
> 
> > I have a use case where I would like to transform and displace a
> file
> > shipped from the same upstream source, so that 2 binary packages
> (that
> > conflict with each other) can be built from the same repository
> without
> > having to keep local copies.
> >
> > The first check, dpkg-divert --truename, immediately fails if the
> path
> > is not absolute. A simple patch is attached.
> 
> Hi Luca,
> 
> If I'm understanding you correctly, you have a single Debian source 
> package that builds two binary packages that conflict with each
> other, and 
> you want the second binary package to modify a file that's shipped in
> the 
> first binary package. Is that correct?
> 
> If so, then you don't need config-package-dev at all. The idea of 
> config-package-dev is to modify one file in some other package
> that's 
> already installed on the system, to prevent updates to the original 
> package from overwriting the modified version of the file, and to
> make 
> sure the original version of the file goes back when the config
> package is 
> uninstalled.
> 
> But if the two packages conflict, the second package will uninstall
> the 
> first package, and the original file won't be present.
> 
> I think you can just do something like this:
> 
> ## debian/control
> Source: something
> ...
> 
> Package: package1
> Conflicts: package2
> ...
> 
> Package: package2
> Conflicts: package1
> ...
> 
> ## debian/package1.install
> usr/bin/something
> etc/something.conf
> 
> ## debian/package2.install
> usr/bin/something
> 
> ## debian/rules
> %:
>         dh $@
> 
> override_dh_install:
>         dh_install
>         sed "s/foo/bar" < debian/tmp/etc/something.conf >
> debian/package2/etc/something.conf
> 
> which would put /usr/bin/something in both packages, the unmodified 
> /etc/something.conf in the first package, and a modified one in the
> second 
> package. And then config-package-dev isn't involved at all.
> 
> If you want to use config-package-dev's transform feature, you'd
> have 
> package2 depend on package1, instead of conflicting with it, so that 
> there's something for dpkg-divert to divert when the package is
> installed. 
> But the above approach seems like it makes more sense to me for your
> use 
> case. config-package-dev was designed for the use case of, e.g.,
> shipping 
> a config package for Firefox that doesn't require rebuilding the
> entire 
> Firefox source. But if you _are_ the same source package as the
> package 
> you're configuring, this concern doesn't apply and it seems simpler
> to 
> build things the normal Debian way.
> 
> Let me know if I'm misunderstanding the use case, though! I think
> the 
> patch looks fine, I just want to make sure this is the right thing to
> do.
> 
> -- 
> Geoffrey Thomas
> https://ldpreload.com
> geofft at ldpreload.com

Hello Geoffrey,

There is one caveat: Package1 is always installed, as it has more than
just the file I need to modify. Package2 is optional. So as things
stand I can't have the conflict. I know, complicated stuff at work :-)

Of course I could split Package1 into Package1A and Package1B, but I'd
have to change a lot of external dependencies. And I am already using
config-package-dev to divert other things in the same source package
already, so it seemed easier and less painful to just add another
.transform and keep things consistent, so that's why I came up with
this small patch.

Kind regards,
Luca Boccassi

> >
> > Kind regards,
> > Luca Boccassi
> >
> >
> > From 15864748b3170217ed0665e3cc2716c1fdf6754c Mon Sep 17 00:00:00
> 2001
> > From: Luca Boccassi <luca.boccassi at gmail.com>
> > Date: Sun, 11 Jun 2017 16:29:49 +0100
> > Subject: [PATCH] transform: let users pick local files as source
> >
> > In some case it's desirable to use a local file as the source of
> the
> > transform operation. For example, an upstream file from the same
> > repository that could be sourced at built time.
> > Skip dpkg checks on the source file if it does not start with /
> > ---
> >  dh_configpackage | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/dh_configpackage b/dh_configpackage
> > index 942766f..e76048c 100755
> > --- a/dh_configpackage
> > +++ b/dh_configpackage
> > @@ -369,9 +369,13 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
> >          my $file = shift @$line;
> >          $file =~ s|^/?|/|;
> >          my $source;
> > +        my $source_is_local = 0;
> >          if (@$line[0] =~ /^</) {
> >              $source = shift @$line;
> >              $source =~ s/^<//;
> > +            if ($source !~ m!^/!) {
> > +                $source_is_local = 1;
> > +            }
> >          } else {
> >              $source = displace_files_replace_name($package, $file,
> "");
> >              if ($source eq $file) {
> > @@ -386,7 +390,10 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
> >          #    chmod 0755, $rest;
> >          #}
> >  
> > -        $source = check_file($source);
> > +        # Let users use local files as input
> > +        if (! $source_is_local) {
> > +            $source = check_file($source);
> > +        }
> >          my $destdir = dirname("$tmp/$file");
> >          if (! -d $destdir) {
> >              doit("install", "-d", $destdir);
> > -- 
> > 2.11.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
Url : http://mailman.mit.edu/pipermail/config-package-dev/attachments/20170619/522f2681/attachment.bin


More information about the config-package-dev mailing list