Upload issues

File *.orig.tar.gz already exists

File python-redis_2.10.1.orig.tar.gz already exists in Primary Archive for Ubuntu, but uploaded version has different contents.

You cannot upload file that already exists in Launchpad but has different content (file checksum). File checksum changes every time you re-create gzipped tarball, because it modifies gzip headers.

This happens for example if you import original source package from Ubuntu archive, make some fixes, eg. backport fixes, create your own source package by gbp buildpackage -S and want to upload it to PPA.

Fortunately the “fix” is simple - you need to download original tarball from Ubuntu archive and use it in your source package.

You can use script similar to this one to download original tarball from archive and replace checksums in your *.dsc file.

#!/bin/bash -x

PPA_REPO="fpytloun/extra"

orig=$(ls *.orig.tar.gz)
orig_size=$(ls -l *.orig.tar.gz | cut -d ' ' -f 5)
orig_sha1=$(sha1sum $orig | cut -d ' ' -f 1)
orig_sha256=$(sha256sum $orig | cut -d ' ' -f 1)
orig_md5=$(md5sum $orig | cut -d ' ' -f 1)

wget --quiet -O $orig-tmp "https://launchpad.net/ubuntu/+archive/primary/+files/$orig"
if [ $? -eq 0 ]; then
    echo "[WARN] Original tarball found in Ubuntu archive, using it instead"
    mv $orig-tmp $orig
    new_size=$(ls -l *.orig.tar.gz | cut -d ' ' -f 5)
    new_sha1=$(sha1sum $orig | cut -d ' ' -f 1)
    new_sha256=$(sha256sum $orig | cut -d ' ' -f 1)
    new_md5=$(md5sum $orig | cut -d ' ' -f 1)
    sed -i -e s,$orig_sha1,$new_sha1,g -e s,$orig_sha256,$new_sha256,g -e s,$orig_size,$new_size,g -e s,$orig_md5,$new_md5,g *.dsc
    sed -i -e s,$orig_sha1,$new_sha1,g -e s,$orig_sha256,$new_sha256,g -e s,$orig_size,$new_size,g -e s,$orig_md5,$new_md5,g *.changes
fi

set -e
debsign --re-sign *.changes
dput -f "ppa:$PPA_REPO" *.changes

Alternatively you can re-build source package using original tarball so you don’t need to fix checksums manually.