Le 5784 Septembre 1993, Daniel Dehennin a envoyé: > Le 5784 Septembre 1993, Daniel Dehennin a envoyé: >> I provide a little patch to permit the use of PLACEHOLDER in prog.dldir. >> >> * vcheck: use File::Path::mkpath. >> Remove validate on dldir. >> Substitute PLACEHOLDERS in prog.dldir. >> Create directory if it does not exist. > > This patch has a little problem, when vcheck save the configuration, the > placeholders are "resolved". > > I'll provide a new one soon.
Here is the modified patch, it adds: * vcheck: Add prog.dldirlast which contains the placeholder substitued prog.dldir. Add documentation about prog.dldirlast. Regards. -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1
=== modified file 'vcheck' --- vcheck 2009-07-01 16:42:49 +0000 +++ vcheck 2009-07-03 10:55:18 +0000 @@ -120,6 +120,7 @@ require HTTP::Request; use Fcntl ':flock'; use File::Basename; +use File::Path qw{mkpath}; #-----8<-------------------------------------------------------------------- @@ -702,13 +703,6 @@ }, dldir => { type => 'string', - validate => sub { - if (m#^/#) { - return (-d && -w && -x) ? 0 : 'Directory not accessible/writable' - } else { - return 'Not an absolute path' - } - }, help => "absolute path of a directory where to put d/l'ed files" }, dlexec => { @@ -819,13 +813,10 @@ }, dldir => { type => 'string', - validate => sub { - if (m#^/#) { - return (-d && -w && -x) ? 0 : 'Directory not accessible/writable' - } else { - return 0 # can't check presence lacking global $dldir value - } - }, + help => "d/l directory (absolute, or relative to global \$dldir)" + }, + dldirlast => { + type => 'string', help => "d/l directory (absolute, or relative to global \$dldir)" }, dlexec => { @@ -1284,6 +1275,9 @@ } } } + if (exists $data{$name}{'dldir'}) { + $data{$name}{'dldirlast'} = &substitute_vers($data{$name}{'dldir'}, \...@vers); + } } &save_data(); @@ -1293,10 +1287,13 @@ while (@dls) { @_ = @{shift @dls}; # (name, ver, fname, URL, D/L URL, vers_ref [, retry]) eprint "Trying to retrieve Â...@_[0, 1]§N...\n--> URL: <$_[4]>\n"; - my $of = (exists $data{$_[0]}{dldir} && $data{$_[0]}{dldir} =~ m#^/# ? - "$data{$_[0]}{dldir}/" : - ($config{dldir} ? "$config{dldir}/" . (exists $data{$_[0]}{dldir} ? - "$data{$_[0]}{dldir}/" : '') : '')); + my $of = (exists $data{$_[0]}{dldirlast} && $data{$_[0]}{dldirlast} =~ m#^/# ? + "$data{$_[0]}{dldirlast}/" : + ($config{dldir} ? "$config{dldir}/" . (exists $data{$_[0]}{dldirlast} ? + "$data{$_[0]}{dldirlast}/" : '') : '')); + if (! -d $of) { + mkpath($of, {mode => 0750}); + } if (length $of && !(-d $of && -w $of && -x $of)) { eprint "--> §YSkipping§N, since §Rspecified `dldir' doesn't exist§N.\n"; next @@ -1862,6 +1859,22 @@ will be considered relative to either B<config.dldir>, if specified, or the directory the script is executing in. +The dldir string is subject to expansion of the following placeholders (see +L<"PLACEHOLDERS"> for their meaning): C<__NEWVER__>. + +=item B<dldirlast> (string) + +This option specifies the download directory of the last downloaded +version of a program. It does not contains L<"PLACEHOLDERS"> unlike +C<prog.dldir>. If the directory is absolute (i.e., relative to the root +directory, as indicated by a leading slash), it will be treated as an +absolute path, otherwise it will be considered relative to either +B<config.dldir>, if specified, or the directory the script is +executing in. + +This option is only used to store L<"PLACEHOLDER"> free dldir, it is +overwriten at each new download. + =item B<dlexec> (string, may be zero-length) Specifies a command to be executed after any successful download of the
pgpj6ij2ULOLx.pgp
Description: PGP signature