# 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, 2019-2020, 2022 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>|I<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, see the
L<Announcement> section for more details.

=head2 Upload methods

The default transfer method is B<ftp>.
Alternative methods are B<http>, B<https>, B<scp>/SSH, B<scpb>/SSH,
B<rsync>/SSH and B<copy>.

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<https>, or one of
B<scp> or B<rsync> via SSH, because B<ftp> transmits the password in clear
text.

=over 2

=item B<ftp>

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 command-line or the environment.

=item B<http> (since 2.9.9) / B<https> (since 2.9.9)

There is no default login nor password.
If you specify a login, a password will be fetched from B<passwordcmd> or
if that is not defined via the Secret Service interface, otherwise it will
be prompted.

=item B<scp> (since 1.8) / B<scpb> (since 1.17)

The default login is delegated to SSH and its own configuration.

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.

=item B<rsync> (since 2.4.1)

The default login is delegated to SSH and its own configuration.

=item B<copy> (since 2.9.0)

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

=back

=head2 Announcement

If the host has been configured to send announcement mails, the F<.changes>
file will be sent to the specified addresses.

The contents of all the following files are prepended to the announcement
mail body, if present:

=over

=item I<package>B<.announce>

=item I<package>B<_>I<upstream-version>B<.announce>

=item I<package>B<_>I<upstream-version>B<->I<revision>B<.announce>

=back

Where I<upstream-version> and I<revision> 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 F<foobar_3.14-2.announce>.

=item *

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

=item *

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

=back

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

=head1 OPTIONS

=over 12

=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<-c>, B<--configfile> I<filename>

Read the file I<filename> as a configuration file, in addition to the global
configuration file.

=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<-q>, B<--quiet>

Be quiet, i.e., suppress normal output and progress bars.

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

Enable more verbose output from the B<ftp>, B<scp> and B<scpb> methods.

For B<scp> and B<scpb> (since 2.10.2) a B<-v> per I<level> is passed
to the B<scp> command.

=item B<--no>

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

=item B<--nostats>

Suppress printing download statistics.

Since version 2.10.2.

=item B<--mta> I<pathname>

Use I<pathname> as the sendmail compatible MTA.
The MTA specified must support the B<-f> option to set the envelope sender
address, and the B<-F> option to set the sender's full name.
The default is F</usr/sbin/sendmail>.

Since version 2.9.8.

=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, but sends the announcements,
unconditionally.

=item B<--noarchive>

Adds an 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<--skip-hooks> I<hook>[,...]

Skip running the comma-separated list of hooks.
The hook names can be the filename or the absolute pathname for the hook
command,
excluding any argument.
This option can be specified multiple times.

Since version 2.11.0.

=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<--help>

Prints the program usage message and exits.

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

Prints version and exits.

=back

=head1 FILES

=over

=item F</etc/dupload.conf>

=item F<~/.dupload.conf>

=item B<--configfile> I<config-file>

The configuration files are loaded if available in the order listed,
overriding previous files.

=item I<package>B<.announce>

=item I<package>B<_>I<upstream-version>B<.announce>

=item I<package>B<_>I<upstream-version>B<->I<revision>B<.announce>

If present, they will all be read to prepend to the announcement mail.

=item F<.changes>

=item F<.dsc>

=item F<.orig.tar.*>

=item F<.debian.tar.*>

=item F<.diff.*>

=item F<.deb>

The F<.changes> file to upload and all of its referenced files.

=item I<package>B<_>I<version>B<_>I<arch>.upload

The file where B<dupload> writes the upload log.

=back

=head1 ENVIRONMENT

=over 2

=item B<DUPLOAD_SKIP_HOOKS>

A comma-separated list of hooks to skip running.
The B<--skip-hooks> option overrides this setting.

Since version 2.11.0.

=back

=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)
