[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: .changes files as first-class objects



On Mon, 2010-01-18 at 13:53 -0800, Russ Allbery wrote:
> "Adam D. Barratt" <adam@adam-barratt.org.uk> writes:
> > So far as I can see, the last time such a change was made was in 2004,
> > when udeb support was added.  At that point, what is now Lab::is_lab()
> > (and was at the time still part of the frontend process) was updated to
> > require the udeb top-level directory to exist; the upgrade path for
> > static labs appears to have been "add the udeb directory".
> 
> I'm okay with doing it this way, personally.  It looks like if you tell
> Lintian to re-setup the static lab using the existing directory, the right
> thing happens.

Agreed; setup_force() appears to create all the structure required
whilst skipping any pre-existing directories.

> > We could take this opportunity to add a format specification to the
[...]
> We could have setup() for a static lab automatically recognize this case
> and create the new directory.  Adding a format is probably overkill for
> just checking whether all the directories but one are present and adding
> the missing one if so.

I had a feeling I might have been over-complicating things. :)
Something like the following should work, afaics (intentionally only
creating the new directory if the top-level directory exists and
therefore stands a chance of being an existing lab):

--- a/lib/Lab.pm
+++ b/lib/Lab.pm
@@ -61,6 +61,11 @@ sub setup {
        $self->{mode} = 'static';
        $self->{dir} = $dir;
        $self->{dist} = $dist;
+       
+       if (-d "$dir" && ! -d "$dir/changes") {
+           mkdir("$dir/changes", 0777)
+               or fail("cannot create lab directory $dir/changes");
+       }
     } else {
        $self->{mode} = 'temporary';

Adam


Reply to: