/[CCFs]/ccfdev/packages/devel/lib/uploadccf
ViewVC logotype

Annotation of /ccfdev/packages/devel/lib/uploadccf

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations)
Tue Apr 3 10:15:51 2001 UTC (23 years, 8 months ago) by gvacanti
Branch: MAIN
Changes since 1.4: +33 -17 lines
*** empty log message ***

1 gvacanti 1.1 #!/usr/local/bin/perl
2     #
3     # uploadccf
4    
5     BEGIN {
6     my $fail = 0;
7     my @mods = qw(Net::FTP Mail::Send);
8     foreach (@mods) {
9     unless (eval "require $_") {
10     warn "Could not find required module $_: $@.\n";
11     $fail++;
12     }
13     }
14     die "Some of the required modules could not be found.\n"if $fail;
15     }
16    
17 gvacanti 1.5 use strict;
18 gvacanti 1.1
19     require 5.001;
20    
21 gvacanti 1.5 my $VERSION = "1.0";
22 gvacanti 1.1
23     use Getopt::Long;
24    
25     =head1 NAME
26    
27     uploadccf -
28    
29     =head1 SYNOPSIS
30    
31 gvacanti 1.5 uploadccf [--clobber] package ...
32 gvacanti 1.1
33     =head1 DESCRIPTION
34    
35 gvacanti 1.5 Upload CCF packages to the server. If a package already exists on the server
36     it will not be uploaded again unless the --clobber option is given.
37 gvacanti 1.1
38     =head1 EXAMPLES
39    
40     =over 4
41    
42     =item *
43    
44     Submit packages foo-1.2.tgz and bar-2.4.tgz
45    
46 gvacanti 1.4 C< uploadccf foo-1.2.tgz bar-2.4.tgz>
47 gvacanti 1.1
48     =back
49    
50     =head1 AUTHOR
51    
52     Giuseppe Vacanti <gvacanti@astro.estec.esa.nl>
53    
54     =cut
55    
56    
57     # Configure these for the remote FTP server:
58 gvacanti 1.5 my $server = "astro.estec.esa.nl";
59     my $remote_dir = "/pub/ccflib/private/incoming/";
60     my $user = "anonymous";
61 gvacanti 1.1
62 gvacanti 1.5 my $ccflib = 'ccflib@astro.estec.esa.nl';
63 gvacanti 1.1
64     # Get program name
65 gvacanti 1.5 my $progname = $0;
66 gvacanti 1.1 $progname =~ s/.*\///;
67    
68 gvacanti 1.5 my $clobber = 0;
69    
70     my $result = GetOptions("clobber+", \$clobber);
71    
72 gvacanti 1.1 # Process each ".tgz" file in turn
73     my @flist;
74    
75     foreach(@ARGV){
76     if(/-v/){
77     print "$progname - $VERSION\n";
78     exit(0);
79     }
80     if(-r){
81     if(! /.+\.tgz/){
82     warn("$_ is not a package and it'll be ignored.\n");
83     next;
84     }
85     push @flist, $_;
86     } else {
87     warn("$_ cannot be read.\n");
88     }
89     }
90    
91     die "No files to transfer.\n" unless @flist;
92    
93     my $ftp = Net::FTP->new("$server") or die "Cannot connect to $server: $!\n";
94     $ftp->login($user) or die "Cannot login as $user: $!\n";
95     $ftp->binary();
96     $ftp->cwd($remote_dir) or die "Cannot change directory to $remote_dir: $!\n";;
97     my @oklist;
98    
99     foreach(@flist){
100 gvacanti 1.5 my @there = $ftp->ls($_);
101     if(@there and not $clobber){
102     warn("$_ already exists on the server. Your local copy will not be uploaded\n");
103     } else {
104     $ftp->put($_) ? push @oklist, $_ : warn("Could not tranfer $_: $!\n");
105     }
106 gvacanti 1.1 }
107    
108 gvacanti 1.3 foreach (@oklist) {
109     $_ =~ s/^.*\///;
110     }
111    
112 gvacanti 1.5 if(@oklist){
113     my $msg = Mail::Send->new(
114     Subject => "CCF package upload: @oklist",
115     To => $ccflib,
116     );
117     my $fh = $msg->open();
118     print $fh "\nThe following files were uploaded to $server:\n";
119     foreach (@oklist) {
120 gvacanti 1.1 print $fh " $_\n";
121 gvacanti 1.5 }
122     $fh->close();
123     print "Notification message sent to $ccflib\n";
124     } else {
125     print "No package was uploaded.\n";
126 gvacanti 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.27