FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian dpkg

 
 
LinkBack Thread Tools
 
Old 12-05-2011, 09:05 AM
Gianluca Ciccarelli
 
Default Bug #583585 dpkg-maintscript-helper

Hi all,

My name is Gianluca and I'm willing to contribute to the dpkg package
maintenance and (eventually) development, so I'm following Raphael
Hertzog's suggestions and looking into bugs that seem a good starting
point.

I found bug #583585, and I guessed it was a good idea to tell everyone
that I'm trying to implement the feature requested. I'd also like your
opinion about my interpretation of the feature: it should be an
additional option in the `case' statement of the script, that takes the
symlink as argument, and
1) moves the directory (or also a single file?) to the place where the
synlink lives
2) removes the symlink
3) creates the symlink again in the previous FS location where the
directory used to live

Could you be so kind to tell me if I'm on the right path, or did I miss
something crucial?

All the best,

--
Gianluca Ciccarelli
http://disi.unitn.it/~ciccarelli
GPG key ID: FDF429B0
 
Old 12-05-2011, 10:08 AM
Raphael Hertzog
 
Default Bug #583585 dpkg-maintscript-helper

Hello,

On Mon, 05 Dec 2011, Gianluca Ciccarelli wrote:
> My name is Gianluca and I'm willing to contribute to the dpkg package
> maintenance and (eventually) development, so I'm following Raphael
> Hertzog's suggestions and looking into bugs that seem a good starting
> point.

Great!

> I found bug #583585, and I guessed it was a good idea to tell everyone
> that I'm trying to implement the feature requested. I'd also like your
> opinion about my interpretation of the feature: it should be an
> additional option in the `case' statement of the script, that takes the
> symlink as argument, and
> 1) moves the directory (or also a single file?) to the place where the
> synlink lives
> 2) removes the symlink
> 3) creates the symlink again in the previous FS location where the
> directory used to live
>
> Could you be so kind to tell me if I'm on the right path, or did I miss
> something crucial?

You have to deal with multiple cases:

1/ replacing a directory with a symlink

v1 has /foo/bar as directory
v2 has /foo/bar as symlink

2/ replacing a symlink with a directory

v1 has /foo/bar as symlink
v2 has /foo/bar as directory

3/ swapping a symlink and a directory

v1 has /foo/bar1 as symlink & /foo/bar2 as directory
v2 has /foo/bar1 as directory & /foo/bar2 as symlink

So I guess you will have 3 commands and not a single one. Or a single one
with a supplementary parameter to differentiate between the 3 use cases.

The precise behaviour depends on which of the 3 operations you're
referring to. You seem to be referring to 3/ but I'm not sure.

You should probably consider doing 1/ and 2/ first to discover the
challenges.

Have you read the parts of the debian policy that explain dpkg's behaviour
with symlinks and directories?

Cheers,
--
Raphaël Hertzog ◈ Debian Developer

Pre-order a copy of the Debian Administrator's Handbook and help
liberate it: http://debian-handbook.info/liberation/


--
To UNSUBSCRIBE, email to debian-dpkg-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20111205110845.GI2810@rivendell.home.ouaza.com">ht tp://lists.debian.org/20111205110845.GI2810@rivendell.home.ouaza.com
 
Old 12-06-2011, 07:17 PM
Gianluca Ciccarelli
 
Default Bug #583585 dpkg-maintscript-helper

Hello Raphael, and hello world,

On 2011/12/05 12:08PM, Raphael Hertzog wrote:
[...]
>
>You have to deal with multiple cases:
>
>1/ replacing a directory with a symlink
>
> v1 has /foo/bar as directory
> v2 has /foo/bar as symlink
>
[...]

Now I have a problem I interpret your notation as: before, we have a
directory /foo/bar; after, we have a symlink /foo/bar.

Where is the directory supposed to go after I run the script's option?

[...]
>
>Have you read the parts of the debian policy that explain dpkg's behaviour
>with symlinks and directories?
>

I've looked into the debian policy and the only specific thing I've
found is about symlinks (in section 10.5. of
/usr/share/doc/debian-policy/policy.txt.gz), that basically describes
the cases when a link should be absolute and when relative. Did you
refer to something else?

TIA and all the best,

--
Gianluca Ciccarelli
http://disi.unitn.it/~ciccarelli
GPG key ID: FDF429B0
 
Old 12-06-2011, 07:32 PM
Jean-Christophe Dubacq
 
Default Bug #583585 dpkg-maintscript-helper

On 06/12/2011 21:17, Gianluca Ciccarelli wrote:
> Hello Raphael, and hello world,
>
> On 2011/12/05 12:08PM, Raphael Hertzog wrote:
> [...]
>>
>> You have to deal with multiple cases:
>>
>> 1/ replacing a directory with a symlink
>>
>> v1 has /foo/bar as directory
>> v2 has /foo/bar as symlink
>>
> [...]
>
> Now I have a problem I interpret your notation as: before, we have a
> directory /foo/bar; after, we have a symlink /foo/bar.
>
> Where is the directory supposed to go after I run the script's option?

/foo/bar should be a symlink to a directory, obviously. And the files
should be moved to the inside of the directory.

(IMHO, IANADD, etc.)

--
Jean-Christophe Dubacq


--
To UNSUBSCRIBE, email to debian-dpkg-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4EDE7BC9.1010505@free.fr">http://lists.debian.org/4EDE7BC9.1010505@free.fr
 
Old 12-06-2011, 08:19 PM
Gianluca Ciccarelli
 
Default Bug #583585 dpkg-maintscript-helper

On 2011/12/06 09:32PM, Jean-Christophe Dubacq wrote:
>On 06/12/2011 21:17, Gianluca Ciccarelli wrote:
>> Hello Raphael, and hello world,
>>
>> On 2011/12/05 12:08PM, Raphael Hertzog wrote:
>> [...]
>>> You have to deal with multiple cases:
>>>
>>> 1/ replacing a directory with a symlink
>>>
>>> v1 has /foo/bar as directory
>>> v2 has /foo/bar as symlink
>>>
>>
>> Now I have a problem I interpret your notation as: before, we have a
>> directory /foo/bar; after, we have a symlink /foo/bar.
>>
>> Where is the directory supposed to go after I run the script's option?
>
>/foo/bar should be a symlink to a directory, obviously. And the files
>should be moved to the inside of the directory.
>

Thank you Jean-Christophe,

So let me see if I got it. We want all the files in /foo/bar to be
reachable by a symlink at the same hierarchy level of /foo/bar, named,
say, `foobar'. This link is such that, if I do `ls foobar', it returns the
content (files, and directories) of /foo/bar.

I then remove /foo/bar. At this point, what's the link pointing to?

Best,

--
Gianluca Ciccarelli
http://disi.unitn.it/~ciccarelli
GPG key ID: FDF429B0
 
Old 12-06-2011, 08:59 PM
Jean-Christophe Dubacq
 
Default Bug #583585 dpkg-maintscript-helper

On 06/12/2011 22:19, Gianluca Ciccarelli wrote:

> Thank you Jean-Christophe,
>
> So let me see if I got it. We want all the files in /foo/bar to be
> reachable by a symlink at the same hierarchy level of /foo/bar, named,
> say, `foobar'. This link is such that, if I do `ls foobar', it returns the
> content (files, and directories) of /foo/bar.
>
> I then remove /foo/bar. At this point, what's the link pointing to?


Package v1 has for example a directory /usr/share/mypackage containing a
and bdir.
Package v2 has now /usr/lib/mypackage, with a and bdir.
/usr/share/mypackage is now a compatibility symlink to /usr/lib/mypackage.

I do not know whether the helper script has to move a and bdir or not
(the bug report is a bit underspecified). Thinking again, I am not sure
at all of what to do.

The problem is that right now, dpkg considers a directory and a symlink
to a directory to play the same role, and does not alter the nature of
these. The real dpkg maintainers will correct me if I am wrong. So
manual work is needed if a package maintainer wants to change the nature
of one such item.

Case three in Raphael's mail would be
Package v1 has a directory /usr/share/mypackage containing a and bdir,
and /usr/lib/mypackage a symlink to /usr/share/mypackage.
Package v1 has a directory /usr/lib/mypackage containing a and bdir, and
/usr/share/mypackage a symlink to /usr/lib/mypackage.
I suppose that in this case, the files have to be moved by your script.

Sincerly,
--
Jean-Christophe Dubacq


--
To UNSUBSCRIBE, email to debian-dpkg-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4EDE9043.4070600@free.fr">http://lists.debian.org/4EDE9043.4070600@free.fr
 
Old 12-07-2011, 06:05 AM
Raphael Hertzog
 
Default Bug #583585 dpkg-maintscript-helper

Hello,

On Tue, 06 Dec 2011, Gianluca Ciccarelli wrote:
> >1/ replacing a directory with a symlink
> >
> > v1 has /foo/bar as directory
> > v2 has /foo/bar as symlink
> >
> [...]
>
> Now I have a problem I interpret your notation as: before, we have a
> directory /foo/bar; after, we have a symlink /foo/bar.
>
> Where is the directory supposed to go after I run the script's option?

You should not have to care about this. The package installs the files in
a new place, your only task is to ensure that /foo/bar is moved away so
that dpkg can install the symlink in /foo/bar.

> >Have you read the parts of the debian policy that explain dpkg's behaviour
> >with symlinks and directories?
>
> I've looked into the debian policy and the only specific thing I've
> found is about symlinks (in section 10.5. of
> /usr/share/doc/debian-policy/policy.txt.gz), that basically describes
> the cases when a link should be absolute and when relative. Did you
> refer to something else?

Yes,
http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html#s-unpackphase
and in particular at end of point 4:

“A directory will never be replaced by a symbolic link to a directory or
vice versa; instead, the existing state (symlink or not) will be left
alone and dpkg will follow the symlink if there is one.”

It's important also to know what happens at each step so that you know
what you must do in each maintainer script.

Basically you must ensure that the directory is only owned by the current
package, then move it away in the "preinst upgrade". In the "postinst
configure" you can drop the directory that you moved away. In case of
error, you should reinstall the directory that you moved away in "postrm
abort-upgrade".

Cheers,
--
Raphaël Hertzog ◈ Debian Developer

Pre-order a copy of the Debian Administrator's Handbook and help
liberate it: http://debian-handbook.info/liberation/


--
To UNSUBSCRIBE, email to debian-dpkg-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20111207070512.GC26636@rivendell.home.ouaza.com">h ttp://lists.debian.org/20111207070512.GC26636@rivendell.home.ouaza.com
 
Old 12-15-2011, 12:24 PM
Gianluca Ciccarelli
 
Default Bug #583585 dpkg-maintscript-helper

Hello dpkg-ers,

Thanks for the comments so far, they were really useful.

I start to see some light. I report on my ideas to let you know that I'm
working on it, and to get some feedback, if possible.

On 2011/12/07 08:05AM, Raphael Hertzog wrote:
[...]
>Basically you must ensure that the directory is only owned by the current
>package, then move it away in the "preinst upgrade". In the "postinst
>configure" you can drop the directory that you moved away. In case of
>error, you should reinstall the directory that you moved away in "postrm
>abort-upgrade".
>

I've read dpkg-maintscript-helper's man page. We want some commands in
the script, invoked by the maintainer scripts always as:
dpkg-maintscript-helper <my_command_name> <options>
-- "$@"

that executes differently according to the value of the variable
DPKG_MAINTSCRIPT_NAME. Let's assume I want to address the first issue,
that is, move away a directory $dir and substitute it with a symlink
with the same name.

In the preinst script, "upgrade" command, I'd invoke the helper as
above, and it will result in something like (as per Raphael's
suggestions):
1) # Ensure ownership of $dir by the package
2) mv "$dir" "$dir".dpkg_bak

In postinst, command "configure", I'd have
1) rm -rf "$dir".dpkg_bak

and finally, in postrm upgrade I'd have:
1) mv "$dir".dpkg_bak "$dir"

Of course I've omitted the security/error checks and other code for now,
that might clutter my point.

Thanks for reading so far, more soon!

--
Gianluca Ciccarelli
http://disi.unitn.it/~ciccarelli
GPG key ID: FDF429B0
 
Old 12-15-2011, 03:12 PM
Raphael Hertzog
 
Default Bug #583585 dpkg-maintscript-helper

Hello,

On Thu, 15 Dec 2011, Gianluca Ciccarelli wrote:
> I've read dpkg-maintscript-helper's man page. We want some commands in
> the script, invoked by the maintainer scripts always as:
> dpkg-maintscript-helper <my_command_name> <options>
> -- "$@"
>
> that executes differently according to the value of the variable
> DPKG_MAINTSCRIPT_NAME. Let's assume I want to address the first issue,
> that is, move away a directory $dir and substitute it with a symlink
> with the same name.

So $dir is part of the <options> above. We also need the first version
that contains the directory instead of the symlink so that we can do the
command only when required (and not on future upgrades).

> In the preinst script, "upgrade" command, I'd invoke the helper as
> above, and it will result in something like (as per Raphael's
> suggestions):
> 1) # Ensure ownership of $dir by the package
> 2) mv "$dir" "$dir".dpkg_bak
>
> In postinst, command "configure", I'd have
> 1) rm -rf "$dir".dpkg_bak

Yes.

> and finally, in postrm upgrade I'd have:
> 1) mv "$dir".dpkg_bak "$dir"

Here it should be "postrm failed-upgrade" I think. And it should not fail
if $dir.dpkg_bak does not exist (the failure to upgrade might be due to
something else and maybe that dir doesn't exist yet).

BTW for consistency please use ".dpkg-bak" and not ".dpkg_bak".

Cheers,
--
Raphaël Hertzog ◈ Debian Developer

Pre-order a copy of the Debian Administrator's Handbook and help
liberate it: http://debian-handbook.info/liberation/


--
To UNSUBSCRIBE, email to debian-dpkg-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20111215161247.GD13254@rivendell.home.ouaza.com">h ttp://lists.debian.org/20111215161247.GD13254@rivendell.home.ouaza.com
 
Old 12-28-2011, 02:55 PM
Gianluca Ciccarelli
 
Default Bug #583585 dpkg-maintscript-helper

On 2011/12/15 05:12PM, Raphael Hertzog wrote:
[...]
>> In the preinst script, "upgrade" command, I'd invoke the helper as
>> above, and it will result in something like (as per Raphael's
>> suggestions):
>> 1) # Ensure ownership of $dir by the package
>> 2) mv "$dir" "$dir".dpkg_bak
>>
>> In postinst, command "configure", I'd have
>> 1) rm -rf "$dir".dpkg_bak
>
>Yes.
>
>> and finally, in postrm upgrade I'd have:
>> 1) mv "$dir".dpkg_bak "$dir"
>
>Here it should be "postrm failed-upgrade" I think. And it should not fail
>if $dir.dpkg_bak does not exist (the failure to upgrade might be due to
>something else and maybe that dir doesn't exist yet).
>
>BTW for consistency please use ".dpkg-bak" and not ".dpkg_bak".
>

I've tried to go on about the first case (substitute a directory with a
symlink). I've noticed there are idioms to perform some of the
operations that I had to perform, so I tried to stick to them.

I thought it was a good idea to share with you the patch for the first
case for feedback, before going on.

I've created the patch according to the guidelines at the dpkg team's
website. Any feedback would be much appreciated.

Cheers,

http://wiki.debian.org/Teams/Dpkg/Contribute

--
Gianluca Ciccarelli
http://disi.unitn.it/~ciccarelli
GPG key ID: FDF429B0
 

Thread Tools




All times are GMT. The time now is 05:43 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org