# Copyright © 1996, 1997 Heiko Schlittermann
# Copyright © 1999, 2001 Stephane Bortzmeyer
# Copyright © 2002, 2003 Josip Rodin <joy-packages@debian.org>
# Copyright © 2008 Frank Lichtenheld <djpig@debian.org>
# Copyright © 2017 Guillem Jover <guillem@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

=head1 NAME

dupload - Debian package upload tool

=head1 SYNOPSIS

B<dupload> [I<options>...] [I<changes-file|directory>...]

=head1 DESCRIPTION

B<dupload> is a tool that enables people maintaining Debian packages to
easily upload them to a Debian repository.

B<dupload> checks each non-option argument to find readable files or
directories. It parses the files as F<.changes> files, or tries to find
such files in the given directories.

B<dupload> will warn if the name of the file does not end with
F<.changes>. Further processing is done changing into the
directories of the changes files.

B<dupload> tests the available checksums and size for each file listed in the F<.changes> file,
and fails if it finds a mismatch. If all this goes well, B<dupload> checks
if there is an F<.upload> file with the basename of the F<.changes> file.
If the file to be uploaded is recorded to have already been uploaded to the
specified host, it is skipped.

After the list of files to upload is finished, B<dupload> tries to connect
to the server and upload. Each successfully uploaded file is recorded in the
F<.upload> log file.

If all files of a package are processed, the F<.changes> file is mailed to the
announcement address specified in the configuration file.  If files with
Z<> F<package>.announce, F<package_UPSTREAMVER>.announce, or
Z<> F<package_UPSTREAMVER-DEBIANREV>.announce exist, these files get
prepended to the announcement. I<UPSTREAMVER> and I<DEBIANREV> are to be
replaced with actual version numbers. For example, if your package is called
B<foobar>, has upstream version 3.14, and Debian revision 2:

=over 2

=item *

If you only want the announcement to be made with only ONE upload,
you name it I<foobar_3.14-2.announce>.

=item *

If you want it to be made with every upload of a particular upstream
version, name it I<foobar_3.14.announce>.

=item *

If you want it made with B<every> upload of a given package, name it
foobar.announce.

=back

=head2 Login and password

If no login (username) is defined in the configuration file,
B<anonymous> is used.  The password is derived from your
login name and your hostname, which is common for anonymous FTP logins.
For anonymous logins only, you can provide the "password" in
the configuration file.

For logins other than B<anonymous>, you are asked for
the password.  For security reasons there is no way to supply it via
the commandline or the environment.

=head2 ftp / scp / rsync / copy

The default transfer method is B<ftp>.  Alternative methods are B<scp>/SSH
and B<rsync>/SSH.  For B<scp> and B<rsync>, the default login is taken
from your local user name.

The B<scp>/SSH method only works properly if no password is required
(see B<ssh>(1)).
When you use B<scp>, it is recommended to set the "method" keyword to
B<scpb>, which will transfer all files in a batch.

The B<copy> method works by simply copying the files to another directory
in the local filesystem.

If you are using an upload queue, use B<ftp> because it is fast.
If you are using an authenticated host, B<always> use B<scp> or B<rsync>
via SSH, because B<ftp> transmits the password in clear text.

=head1 OPTIONS

=over 12

=item B<-d>, B<--debug> [I<level>]

Enable more verbose output from the FTP module.

=item B<-f>, B<--force>

Upload regardless of the transfers logged as already completed.

=item B<-k>, B<--keep>

Keep going, skipping packages whose checksums does not match.

=item B<-c>, B<--configfile> [I<filename>]

Read the file I<filename> or F<./dupload.conf> (if it exists and no argument
is provided).

B<Warning>: Using this option without a I<filename> argument is deprecated
(as of dupload 2.9.0) because it is a security risk if you are in a directory
where other people can write. The argument will become mandatory in the future.

=item B<--no>

Dry run, no files are changed, no upload is attempted, only tell
what we would do.

=item B<--nomail>

Suppress announcement for this run. You can send it later by just
calling dupload again w/o this option. Note that this option is by
default implied for all hosts with the B<dinstall_runs> option set to 1.

=item B<--mailonly>

Acts as if B<--no> has been specified and but sends the announcements,
unconditionally.

=item B<--noarchive>

Adds a B<X-No-Archive: yes> header so that the announcement will not be
archived. You can use the per-host B<archive> option in the configuration
file.

=item B<-p>, B<--print>

Print the E<quot>databaseE<quot> as read from the config files and exit.
If a host is specified via option B<--to>, only this host's entry is
displayed.

=item B<-q>, B<--quiet>

Be quiet, i.e., suppress normal output.

=item B<-t>, B<--to> I<nickname>

Upload to I<nickname>'d host.  I<nickname> is the key for doing lookups
in the config file. You can use the B<default_host> configuration option
to specify a host without B<--to>.

=item B<--help>

Prints the program usage message and exits.

=item B<-V>, B<--Version>

Prints version and exits.

=back

=head1 FILES

=head2 Configuration

The configuration files are searched as follows (and read in this
order, overriding each other):

	/etc/dupload.conf
	~/.dupload.conf

=head2 Other

Various Debian package files are used by B<dupload>: .dsc, .changes, .deb,
Z<>.orig.tar.*, .debian.tar.*, .diff.*

B<dupload> itself writes the log file I<package_version-debian>.upload,
and the additional announcement files I<package>.announce,
I<package_upstreamver>.announce, or I<package_upstreamver-debianrev>.announce.

=head2 Announcement addresses

By default, the announcement addresses are unset because dinstall sends
mails instead.

=head1 BUGS

B<dupload> is tested on B<Debian> systems only. It should not require too
much effort to make it run under others systems, though.

=head1 SEE ALSO

B<dupload.conf>(5)
