Project

General

Profile

Rebuild script

Synopsis

# ./rebuild pandoc
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Build-Depends dependency for pandoc cannot be satisfied because candidate version of package libghc-aeson-dev can't satisfy version requirements

# ./rebuild libghc-aeson-dev

Purpose

Non-interactively update a package from Debian source repository.

Setup

APT repositories

# cat /etc/apt/sources.list
deb http://apt.osdyson.ru unstable main
deb-src http://http.debian.net/debian sid main

Signing result

Add your GPG key to GPG agent to bypass passphrase

Dput

/etc/dput.cf:

[dyson]
login= pashev
fqdn= apt.osdyson.org
method= scp
incoming= /srv/apt/incoming
allow_dcut= 1
post_upload_command = ssh apt.osdyson.ru /srv/apt/script/import-new-packages.sh && sudo apt-get update

Source code

#!/bin/sh

set -u
set -e
set -x

pkg="$1" 
vertries=7

sudo apt-get -y build-dep "$pkg" 
curver=`(apt-cache show $pkg || echo 'Version: 0~0') | awk '/Version:/ {print $2}'`

tmpdir=`mktemp -d "/var/tmp/pkg-${pkg}-XXXXXXX"`

cd "$tmpdir" 
apt-get source "$pkg" 
pkgdir=`find * -maxdepth 0 -type d | head -n 1`
echo "*** building in $pkgdir ***" 
cd "$pkgdir" 

dch --l '+dyson' 'Package for Dyson'
bump=0
while true; do
    newver=`dpkg-parsechangelog | awk '/Version:/ {print $2}'`
    if dpkg --compare-versions "$newver" gt "$curver"; then
        break
    else
        if [ $bump = 0 ]; then
            echo "There is already package version $newver in Dyson. Bump version? [y/N]" 
            read bump
        fi
        case $bump in
        y|Y|yes|Yes)
            dch -i ''
            vertries=`expr $vertries - 1 || true`
            if [ $vertries = 0 ]; then
                echo "Version bump failed!" 
                exit 1
            fi
            ;;
        *)
            echo "Aborted" >&2
            exit 1
            ;;
        esac
    fi
done

dch -r ''
dpkg-buildpackage -sa
dput dyson `realpath ../*.changes`

cd
rm -fr -- "$tmpdir" 

exit 0

Also available in: PDF HTML TXT