Installation

apt
apt install -o Dpkg::Options::="--force-confnew"

# Packages
apt install etckeeper
apt install packaging-dev debtags debmake dgit config-package-dev

# Packages
apt install packaging-dev debtags debmake dgit
apt install dwww debian-policy debian-handbook debian-kernel-handbook debian-reference-en developers-reference doc-debian maint-guide newbiedoc debconf-doc apt-doc debian-faq debian-history debian-installer aptitude-doc-en harden-doc intallation-guide-amd64
apt install --install-suggests packaging-dev debtags dgit dwww surfraw aptitude

# Debug
apt install strace ltrace uftrace gdb valgrind
apt install libstdc++-7-doc

apt install --install-suggests packaging-dev debtags dgit dwww surfraw aptitude

# Packages
apt install packaging-dev debtags debmake dgit config-package-dev
apt install dwww debian-policy debian-handbook debian-kernel-handbook debian-reference-en developers-reference doc-debian maint-guide newbiedoc debconf-doc apt-doc debian-faq debian-history debian-installer aptitude-doc-en harden-doc
apt install --install-suggests packaging-dev debtags dgit dwww surfraw aptitude
apt install packaging-dev debtags debmake dgit dwww

# Debug
apt install strace ltrace uftrace gdb valgrind
apt install libstdc++-7-doc
apt install --install-suggests packaging-dev debtags dgit dwww surfraw aptitude

apt install \
        apt-doc \
        aptitude-doc-en \
        bash-doc \
        debian-faq \
        debian-handbook \
        debian-history \
        debian-installer \
        debian-policy \
        debian-reference-en \
        doc-debian \
        harden-doc \
        manpages \
        newbiedoc

# Developers documentation
apt install \
        cppreference-doc-en-html \
        cppreference-doc-en-qch \
        debconf-doc \
        debian-kernel-handbook \
        developers-reference
        maint-guide \
        debian-maintainers \
        manpages-dev \

# /var/lib/apt/lists/deb.debian.org_debian_dists_stable_main_binary-amd64_Packages
debtags grep devel::editor 2>&- | tagcoll related -d 11 emacs
debtags cat | tagcoll implications
debtags cat | tagcoll reverse | cut -f 1 -d ' ' | grep role::
debtags cat | grep automake | tagcoll reverse | cut -d: -f -3 | sort | uniq

man apt_preferences
sudo gem install asccidoc-include-ext mail-room

apt-config dump
bash /etc/cron.weekly/dwww
apt install libpod-index-perl
dhelp
dlocate
dpkg-statoverride
debtags
grep-available
dpkg-divert
debtags
aptitude search ~sutils

view /usr/share/tasksel/descs/debian-tasks.desc
< *dists_stable_main*Packages grep-dctrl --field=Depends tasksel --show-field=Package,Section,Tag,Maintainer

Netboot and preseed

Debian automated installation with dhcp and tftp. Dhcp bootfile option can be used for ipxe or a debian preseed config. There is a conflict when qemu and debian use dhcp filename option (bootfile?) for pxelinux.0 and preseed.cfg! The ipxe boot file may be loaded from tftp. It may require additional configuration in dnsmasq.conf. (dhcp-boot=pxelinux.0)

netboot
# Debian netboot installation
cd $(mktemp -d) && cd ..
dd count=0 seek=6M of=disk.img
wget -c -r -nc -np -nH -nd -P amd64 \
        http://cdn-fastly.deb.debian.org/debian/dists/stable/main/installer-amd64/current/images/netboot/debian-installer/amd64/
exec lkvm run -n -d disk.img -k amd64/linux -i amd64/initrd.gz -p 'root=/dev/vda auto=true priority=critical url=tftp://192.168.33.100/preseed.cfg'

#Bug#749991
#Besides installing dist=stable by default, also testing and sid are supported.
#
#Just adding 'mirror/suite=testing' as additional param to the kernel command line is enough.

Build from source package

Building a Debian package from source is simple. The script records build steps from the terminal and paste it online

Debug build

DEB_BUILD_OPTIONS=nostrip,noopt gdb --directory /usr/lib/debug/ -p 1234

dgit
#dgit
dgit cloned dgit
cd dgit
git checkout -b master
dgit gbp-build
debuild
#!/bin/bash
# Install required packages
apt install devscripts bsdutils
apt build-dep debbugs/experimental

# Record typescript with script
script -c "$( cat <<-'SCRIPT'
        set -e -x
        cd $(mktemp -d)
        apt source debbugs/experimental
        cd debbugs-*
        debuild -uc -us
        SCRIPT
)"
# Remove escape sequences from typescript then add it to debpaste
# < typescript bbe -b "/\x1b\x5b/:/\x6d/" -e D | iconv --from=latin1 --to=utf-8 | debpaste add
gradle
#!/bin/bash
# create gradle-3.3.0-1 package for debian
# https://www.debian.org/doc/manuals/maint-guide/index.en.html
set -e
set -x

## Install dependencies
apt install packaging-dev -y
apt build-dep gradle -y

# Build with debug symbols (objcopy --only-keep-debug)

git init gradle-3.3.0
cd gradle-3.3.0
git remote add origin https://anonscm.debian.org/git/pkg-java/gradle.git
git remote add upstream https://github.com/gradle/gradle.git
git fetch --all
git checkout debian/3.2.1-1
git rebase v3.2.1 v3.3.0 --onto debian/3.2.1-1 --strategy=recursive --strategy-option=ours || \
    while ! git rebase --continue; do
        git rm $(git ls-files -u | cut -f2 )
    done

wget -O- http://paste.debian.net/downloadh/2d45d7c3 | \
    patch -p1

dch --newversion 3.3.0-1 "Merge upstream v3.3.0"
dh_make --indep --yes --createorig || true

debuild
quilt
apt install quilt
cd $(mktemp -d)
apt source debbugs
cd debbugs-*
quilt import -f <( cat \
<<-PATCH
PATCH
)

# Split patches
quilt push -a && \
quilt snapshot && \
quilt series | \
while read; do \
        quilt files | \
        grep ^debian | \
        xargs -r quilt remove && \
                quilt refresh && \
                quilt pop
done
bts
# Bugtracking
BROWSER=w3m bts show debbugs

GPG

gpg
aptitude install gpg dirmngr
# Generate gpg signatures to sign Debian packages
gpg --quick-gen-key --yes $(whoami)
gpg --list-sigs --with-keygrip
gpg --keyid-format long --fingerprint 0123456789ABCDEF
gpg --send-key --keyserver example.com 0123456789ABCDEF
gpg --recv-key --keyserver example.com 0123456789ABCDEF
gpg --export --armor | gpg --import --armor
gpg --armor --export 0123456789ABCDEF | sudo apt-key add -
#gpg --export 0123456789ABCDEF | sudo apt-key add -
#apt-key list
#wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

gpg --output revoke.asc --gen-revoke 01234567

Repositories

debmirror
> gpg.conf cat <<'EOF'
trusted-key sdasdsa
EOF
export GNUPGHOME=$PWD
debmirror --verbose --debug .
gpg --list-packets --verbose < .temp/dists/stretch/Release.gpg
gpg --receive EF0F382A1A7B6500
gpg --edit-key EF0F382A1A7B6500 trust
gpg --verify .temp/dists/stretch/Release.gpg .temp/dists/stretch/Release

ln -s pubring.kbx trustedkeys.kbx
gpgv .temp/dists/stretch/Release.gpg .temp/dists/stretch/Release

debmirror --verbose --progress --debug --keyring pubring.kbx .

Custom repository

Repository
#!/bin/bash

# download packages and create ftparchive
12<<-'APTSOURCES' \
11<<-'APTRELEASE' \
10<<-'APTSECURITY' \
9<<-'APTDOWNLOAD' \
8<<-'PACKAGES' \
7<<-'SCAN' \
6<<-'GPG' \
5<<-'SIGN' \
0<<-'SCHROOT' \
20<<-'DEBS' \
bash -e
        # deb [trusted=yes] http://deb.devuan.org/merged testing main
        # deb-src [trusted=yes] http://deb.devuan.org/merged testing main
        deb [trusted=yes arch=amd64 ] http://deb.devuan.org/devuan unstable main
        deb-src [trusted=yes arch=amd64 ] http://deb.devuan.org/devuan unstable main
APTSOURCES

        APT::Default-Release "unstable";
APTRELEASE

        # disable some protection by default and ensure we still do the verification
        # correctly
        Acquire::AllowInsecureRepositories "1";
        Acquire::AllowDowngradeToInsecureRepositories "1";
APTSECURITY

        # install tools
        cat > /etc/apt/sources.list <&12
        cat > /etc/apt/apt.conf.d/default-release <&11
        cat > /etc/apt/apt.conf.d/weaken-security <&10

        apt-get update
        apt-get install --yes dpkg-dev
        : apt-get install --yes fdisk/testing mount/testing sysvinit-utils/testing util-linux/testing bsdutils/testing libblkid1/testing libfdisk1/testing libmount1/testing libsmartcols1/testing libuuid1/testing

        # download release
        wget --continue --no-check-certificate --directory-prefix=/tmp \
                ftp://ftp.nluug.nl/pub/os/Linux/distr/devuan/devuan_ascii/installer-iso/devuan_ascii_2.1_amd64_cd-1.iso \
                #https://cdimage.debian.org/cdimage/weekly-builds/amd64/iso-cd/debian-testing-amd64-netinst.iso

APTDOWNLOAD

    cat /var/lib/apt/lists/*_main_binary-amd64_Packages |
        grep ^Package\\\|^Priority\\\|^Filename |
        paste - - - |
        sort |
        nl -n ln |
        tee >(
                # join required and important packages
                sort -k5 |
                join -15 - <(
                        cat <<<$'important\nrequired'
                ) |
                cut -d\  -f4,7 |
                nl -n ln |
                join -j5 <(seq 1) -
        ) > >(
                # join desired packages
                sort -k3 |
                join -13 - <(
                        # append packages and dependencies
            cat <&20 |
                        tee >(
                                xargs apt-cache depends \
                                        --recurse \
                                        --installed \
                                        --no-pre-depends \
                                        --no-suggests \
                                        --no-recommends \
                                        --no-conflicts \
                                        --no-breaks \
                                        --no-replaces \
                                        --no-enhances |
                                grep Depends: |
                                cut -d: -f2 |
                                cut -d\  -f2 |
                                grep -v '^<'
                        ) | sort | uniq
                ) |
                cut -d\  -f1,7 |
                sort -n -k2 |
                nl -n ln |
                join -j5 <(seq 2 2) -
        ) |
        cut -d\  -f4,5 |
        sort | uniq |

        # format input for shell reuse
        grep -o \\S* |
        xargs -I@ printf %q\\n '@' |
        sed -e 1~2s/^/basename\ /e -e 0~2s/^/dirname\ /e |
        xargs -I@ printf %q\\n '@' |

        # divide package list into directories
        paste - - |
        nl -n ln |
        tee >(
                # package names
                cut -f1,2 | join <(seq 2 2) - -j3
        ) > >(
                # uniq directory names
                cut -f1,3 | join <(seq 1) - -j3 | uniq -i2
        ) |
        sort -k2 -n |
        cut -d\  -f2,4 |

        # group packages by folders in one line
        sed /^1\ /i\\\\\x00 |
        tail -z -n+2 |
        cut -d\  -f2 |
        tr \\n\\\000 \\\ \\\n
PACKAGES

    [ -d debian/dists/testing/main ] || {
                mkdir -p debian/dists/testing/main
                while read
        do
                        mkdir debian/dists/testing/main/$REPLY
                        tee debian/dists/testing/main/$REPLY/Release <<-EOF
                                Archive: testing
                                Origin: Devuan
                                Label: testing
                                Version: 2.0.0
                                Component: main
                                Architecture: amd64
                EOF
                done <<-WHILE
                        binary-amd64
                        source
                WHILE
    }

        dpkg-scanpackages debian/pool |
        tee debian/dists/testing/main/binary-amd64/Packages |
        tee >(
                xz -z > debian/dists/testing/main/binary-amd64/Packages.xz
        ) | grep ^Package: | sort

        dpkg-scansources debian/pool |
        tee debian/dists/testing/main/source/Sources |
        xz -z \
        > debian/dists/testing/main/source/Sources.xz

        apt-ftparchive release debian/dists/testing \
                -o APT::FTPArchive::Release::Origin="Debian" \
                -o APT::FTPArchive::Release::Label="Debian" \
                -o APT::FTPArchive::Release::Suite="testing" \
                -o APT::FTPArchive::Release::Codename="testing" \
                -o APT::FTPArchive::Release::Valid-Until="$(date --rfc-2822 --utc --date=@1600000000)" \
                -o APT::FTPArchive::Release::Architectures="amd64 source" \
                -o APT::FTPArchive::Release::Components="main" \
                -o APT::FTPArchive::Release::Description="Description: Experimental packages - not released use at your own risk." \
        > debian/dists/testing/Release
SCAN

        # Sign files
        gpg --yes -abs -o dists/sid/Release.gpg dists/sid/Release
        gpg --clearsign -o dists/sid/InRelease dists/sid/Release

        # import signatures on client
        gpg --recv-key --keyserver localhost 0123456789ABCDEF
        gpg --list-sigs
        gpg --export 0123456789ABCDEF > /usr/share/keyrings/archive-keyring.gpg

GPG
        deb [trusted=yes signed-by=/usr/share/keyrings/archive-keyring.gpg] ftp://localhost/debian sid main
        deb-src [trusted=yes signed-by=/usr/share/keyrings/archive-keyring.gpg] ftp://localhost/debian sid main

        #deb file:/var/www/html/packages/amd64/ /
        #deb-src file:/var/www/html/packages/amd64/ /
        #deb [signed-by=/usr/share/keyrings/archive-keyring.gpg] file:/srv/reprepro/debian /
        #deb-src [signed-by=/usr/share/keyrings/archive-keyring.gpg] file:/srv/reprepro/debian /
SIGN

        # apt download
        [ -d debian ] || {
                bash -e <&9
                mkdir debian debian/doc
            touch debian/doc/README
        }

        [ -d debian/pool ] || {
                # debian sources
        mkdir debian/pool debian/pool/main debian/pool/main/d
        cd debian/pool/main/d
        while read
        do
            : apt-get source --download-only $REPLY
        done <<-DEBSRC
            debian-installer
            debootstrap
            devuan-baseconf
            devuan-keyring
                DEBSRC
        cd $OLDPWD

        # debian installer
        : wget --continue \
            http://deb.devuan.org/devuan/pool/main/d/debian-installer/debian-installer_20180717+devuan1{.dsc,.tar.gz,_amd64.deb}
        : xargs -L1 wget -c -r -l6 -nv -nc -np -nH --cut-dirs=3 -P \
            debian/dists/ascii <<-DI
            http://deb.devuan.org/devuan/dists/ascii/main/debian-installer/binary-amd64/
            http://deb.devuan.org/devuan/dists/ascii/main/installer-amd64/current/images/
                DI
        }

    mkdir work iso
    mount /tmp/de*.iso iso
    mount overlay debian/pool \
        -t overlay \
        -o lowerdir=iso/debian/pool \
        -o upperdir=debian/pool \
        -o workdir=work

    # apt download required packages with filename from lists
    bash -e <&8 | {
        cd debian
        while read
        do
            set $REPLY
            mkdir -p $1
            cd $1
            shift
            apt-get -o 'APT::Architecture=amd64' download $* &
            cd $OLDPWD
        done
        wait
        cd $OLDPWD
    }

    # rename packages with epochs version
    find -name '*%*' -exec dpkg-name -o {} +

        # scan packages
        bash -ex <&7

        # sign repository
        : bash -ex <&6
        : cat >> /etc/apt/sources.list  <&5

        # cleanup
    umount debian/pool iso
    rmdir work/work work iso

SCHROOT
        apt
        apt-utils
        arch-test
        autoconf
        automake
        autopoint
        autotools-dev
        binutils
        binutils-common
        binutils-x86-64-linux-gnu
        build-essential
        busybox-static
        bzip2
        ca-certificates
        cgpt
        console-common
        console-data
        cpio
        cpp
        cpp-6
        cpp-8
        curl
        debconf-utils
        debian-installer
        debian-keyring
        debootstrap
        device-tree-compiler
        devuan-baseconf
        devuan-keyring
        dh-autoreconf
        dh-strip-nondeterminism
        dhcpcd5
        dialog
        dirmngr
        dmsetup
        dpkg-dev
        dwz
        e2fslibs
        e2fsprogs
        e2fsprogs-l10n
        fake-hwclock
        fakeroot
        fbterm
        file
        fontconfig-config
        fonts-dejavu-core
        fonts-lato
        fuse
        g++
        g++-8
        gcc
        gcc-6-base
        gcc-7-base
        gcc-8
        gcc-8-base
        gettext
        gettext-base
        git-core
        git-man
        gnupg
        gnupg-agent
        gnupg-l10n
        gnupg-utils
        gnupg2
        gpg
        gpg-agent
        gpg-wks-client
        gpg-wks-server
        gpgconf
        gpgsm
        gpgv
        groff-base
        htop
        iftop
        initramfs-tools
        initramfs-tools-core
        intltool-debian
        iotop
        isolinux
        javascript-common
        joe
        kbd
        klibc-utils
        kpartx
        less
        libalgorithm-diff-perl
        libalgorithm-diff-xs-perl
        libalgorithm-merge-perl
        libapt-pkg5.0
        libarchive-cpio-perl
        libarchive-zip-perl
        libasan3
        libasan5
        libasound2
        libasound2-data
        libassuan0
        libatomic1
        libbinutils
        libboost-filesystem1.67.0
        libboost-iostreams1.67.0
        libboost-program-options1.67.0
        libboost-system1.67.0
        libc-bin
        libc-dev-bin
        libc-l10n
        libc6
        libc6-dev
        libcc1-0
        libcilkrts5
        libcom-err2
        libcomerr2
        libcroco3
        libcurl3-gnutls
        libcurl4
        libdebconfclient0
        libdevmapper1.02.1
        libdpkg-perl
        liberror-perl
        libevent-2.1-6
        libevent-core-2.1-6
        libevent-pthreads-2.1-6
        libexpat1
        libext2fs2
        libfakeroot
        libfftw3-single3
        libfile-fcntllock-perl
        libfile-stripnondeterminism-perl
        libfontconfig1
        libfreetype6
        libfuse2
        libgcc-6-dev
        libgcc-8-dev
        libgcc1
        libgcrypt20
        libgdbm-compat4
        libgdbm6
        libglib2.0-0
        libglib2.0-data
        libgomp1
        libgpm2
        libicu63
        libisl19
        libitm1
        libjs-jquery
        libklibc
        libldap-2.4-2
        libldap-common
        liblocale-gettext-perl
        liblsan0
        libltdl-dev
        libltdl7
        liblua5.2-0
        liblzo2-2
        libmail-sendmail-perl
        libmpc3
        libmpdec2
        libmpfr6
        libmpx2
        libncurses6
        libncursesw6
        libnghttp2-14
        libopts25
        libparted2
        libpcap0.8
        libpcre2-8-0
        libperl5.28
        libpipeline1
        libpng16-16
        libpython3-stdlib
        libpython3.6-minimal
        libpython3.6-stdlib
        libpython3.7
        libpython3.7-minimal
        libpython3.7-stdlib
        libquadmath0
        librtmp1
        libruby2.5
        libsamplerate0
        libsasl2-2
        libsasl2-modules
        libsasl2-modules-db
        libseccomp2
        libsigsegv2
        libssh2-1
        libssl1.1
        libstdc++-8-dev
        libstdc++6
        libsys-hostname-long-perl
        libtcl8.6
        libtext-charwidth-perl
        libtext-iconv-perl
        libtinfo5
        libtinfo6
        libtool
        libtsan0
        libubsan0
        libubsan1
        libudev1
        libunistring2
        libunwind8
        libusb-1.0-0
        libutempter0
        libx11-6
        libx11-data
        libx86-1
        libxau6
        libxcb1
        libxdmcp6
        libxml2
        libyaml-0-2
        libzstd1
        linux-base
        linux-libc-dev
        locales
        lynx
        lynx-common
        m4
        make
        makedev
        manpages
        manpages-dev
        mime-support
        ntp
        openresolv
        openssl
        parted
        patch
        perl
        perl-base
        perl-modules-5.28
        pinthread
        po-debconf
        python3
        python3-minimal
        python3.6
        python3.6-minimal
        rake
        ruby
        ruby-did-you-mean
        ruby-minitest
        ruby-net-telnet
        ruby-power-assert
        ruby-test-unit
        ruby-xmlrpc
        ruby2.5
        rubygems-integration
        runit-init
        schroot
        schroot-common
        shared-mime-info
        sntp
        ssl-cert
        strace
        syslinux-common
        sysvinit
        sysvinit-core
        task-web-server
        tasksel-data
        tmux
        u-boot-tools
        unzip
        usbutils
        vifm
        vim
        vim-addon-manager
        vim-common
        vim-nox
        vim-runtime
        vim-tiny
        vsftpd
        wavemon
        xdg-user-dirs
        xorriso
        zip
        zlib1g
        zsh
        zsh-common
DEBS

Netboot

debiancd
#!/bin/sh

# see ftparchive.sh
cd /srv/mirror || exit 1

apt-get install --yes debian-cd

cd /usr/share/debian-cd || exit 2

# check packages required in mirror
while read
        do
                : tools/which_deb $OLDPWD/debian sid $REPLY binary || exit 2
        done <<-EOF
        coreutils
        debian-archive-keyring
        debian-installer
        debootstrap
        installation-guide-amd64
        isolinux
        syslinux-common
        tasksel-data
EOF

# tools/which_deb $OLDPWD/debian sid debootstrap || exit 3

# debootstrap --no-check-gpg --arch $(dpkg-architecture -qDEB_HOST_ARCH) --print-debs sid $OLDPWD/tmp/debootstrap.tmp file:$OLDPWD/debian | tr ' ' '\n' | tee $BDIR/debootstrap-list

# BASEDIR=$PWD MIRROR=$OLDPWD/debian ARCHES=$(dpkg-architecture -qDEB_HOST_ARCH) TDIR=$OLDPWD/tmp CODENAME=sid DISKTYPE=CD OUT=$OLDPWD/debian-cd-test make ok || exit 4

# mkdir -p $OLDPWD/tmp/sid && BASEDIR=$PWD tools/grab_md5 $OLDPWD/debian $(dpkg-architecture -qDEB_HOST_ARCH) sid sid $OLDPWD/tmp/sid/md5-check || exit 5


sed -i Makefile \
        -e '/DEBOOTSTRAP_SCRIPT/s/\s*2>\/dev\/null\s*/ /' \
        -e /INC_SOURCE/s/^\\tif/\\t\\$\(Q\)if/ \
        -e s/^correctstatus:/in\&/ \
        -e /\$\(MAKE\)\ correctstatus\;/s/\;/\ \|\|\ exit\ 1\;/ \
        -e /^\\\$\(ADIR\)\\\/status:/s/status/fake\&/ \


        #-e /^apt=/s/=\\\$/=bash\ \\\$/ \

sed -i CONF.sh \
        -e /^export\ CONTRIB=1/s/^/\#/ \
        -e /^export\ CODENAME=stretch/s/stretch/sid/ \
        -e /^\#export\ OMIT_DOC_TOOLS=1/s/^\#// \
        -e /^export\ DISKTYPE/s/CD/NETINST/ \

: \
        -e /^export\ INSTALLER_CD/s/^/\#/ \
        -e /^export\ TASK/s/^/\#/ \
        -e /^\#export\ INSTALLER_CD/s/^\#// \
        -e /^\#export\ TASK/s/^\#// \
        -e /^export\ INSTALLER_CD=/s/^\\\(\.\*=\\\)./\\11/ \
        -e /^export\ TASK=/s/^\\\(\.\*=\\\).\*/\\1debian-installer/ \
        -e /^\#export\ DISC_START_HOOK=/s/^\#// \
        -e /^export\ DISC_START_HOOK=/s/^\\\(\.\*=\\\).*/\\1echo\\\\\ start/ \


sed -i tools/make_disc_trees.pl \
        -e /\$size_check\ \$cddir/d

sed -i tools/apt-selection \
        -e s/\\\.\ CONF\\\.sh/.\ .\\\/CONF.sh/

sed -i tools/generate_di_list \
        -e /Missing\ package/s%file.\*\\\\n%file:\ \$mirror_path/\$component/debian-installer/binary-\$arch/Packages.\{gz,xz\}\\\\n%


exit(){
while read; do
        unset exit && exit $1
        apt-get $REPLY check || apt $REPLY search . && unset exit && exit $1
done <<-'EOF'
        -o Dir::State::status=$OLDPWD/tmp/apt/sid-$(dpkg-architecture -qDEB_HOST_ARCH)/status \
        -o Dir::State=$OLDPWD/tmp/apt/sid-$(dpkg-architecture -qDEB_HOST_ARCH)/apt-state/ \
        -o Dir::Cache=$OLDPWD/tmp/apt/sid-$(dpkg-architecture -qDEB_HOST_ARCH)/apt-cache/ \
        -o Dir::Etc=$OLDPWD/tmp/apt/sid-$(dpkg-architecture -qDEB_HOST_ARCH)/apt/ \
        -o APT::Cache::AllVersions=0 \
        -o APT::Cache::ShowVersion=1 \
        -o APT::Architecture=$(dpkg-architecture -qDEB_HOST_ARCH) \
        -o APT::Architectures::=$(dpkg-architecture -qDEB_HOST_ARCH) \
        -o Acquire::Languages=none \

EOF
}

# https://wiki.debian.org/DebianCustomCD
VERBOSE= VERBOSE_MAKE= bash -ex <<-EOF || exit $?
        source CONF.sh
        make \
                distclean \

        mkdir -p \
                $OLDPWD/tmp/apt/sid-amd64/apt/preferences.d/ \
                $OLDPWD/tmp/apt/sid-amd64/apt/sources.list.d/

        exit 0
        make --debug \
                $OLDPWD/tmp{,/apt/status} \

: ARCH=amd64 tools/apt-selection update || exit 8
: ARCH=amd64 tools/apt-selection check || exit 9
        exit 11


        VERBOSE= BASEDIR=$PWD MIRROR=$OLDPWD/debian TDIR=$OLDPWD/tmp APTTMP=$OLDPWD/tmp/apt CODENAME=sid ARCH=$(dpkg-architecture -qDEB_HOST_ARCH) tools/sort_deps_edu $OLDPWD/tmp/sid/list

        cpp \
                -nostdinc -P -undef -D ARCH_amd64 -U amd64 -U i386 -U linux -U unix -DFORCENONUSONCD1=0 -I $OLDPWD/tmp/sid/tasks tasks/sid/Debian-generic

        exit 1

        exit 0
EOF



VERBOSE= VERBOSE_MAKE= bash -ex <<-EOF || exit 7
        source CONF.sh

        mkdir $OLDPWD/tmp/sid

        : make --debug \
                mirrorcheck \

        make --debug \
                unstable-map \

        make --debug \
                sid_status \

        exit 0
        make --debug \
                unstable-map init sid_status status \

        exit 0
        make \
                $OLDPWD/tmp/sid/{raw,}list \
                genlist packagelists \

        exit 0
EOF

VERBOSE= VERBOSE_MAKE= bash -ex <<-EOF || exit 7
        source CONF.sh

        exit 0

        make --debug \
                $OLDPWD/tmp/sid/tasks \

        make --debug \
                $OLDPWD/tmp/sid/debootstrap \
        exit 0

        make --debug \
                $OLDPWD/tmp{,/apt/status,/sid{,/tasks,/debootstrap}} \

        make \
                --debug VERBOSE=1 \
                image-trees \

        make \
                images \
                official_images \

        : make \
                clean \

        exit 0
EOF

Ultimate debian database

udd
wget https://udd.debian.org/dumps/udd.dump
time sudo -u postgres bash <<-'BASH'
        psql <<-'EOF'
                DROP DATABASE IF EXISTS udd;
                DROP ROLE IF EXISTS udd;
                CREATE ROLE udd;
                CREATE DATABASE udd TEMPLATE template0 ENCODING SQL_ASCII;
        EOF
        pg_restore --exit-on-error --no-owner --dbname udd udd.dump
        psql --dbname udd <<-'EOF'
                DROP ROLE IF EXISTS "user";
                CREATE ROLE "user";
                REASSIGN OWNED BY udd TO "user";
                DROP OWNED BY udd;
                DROP ROLE udd;
                ALTER DATABASE udd SET default_transaction_read_only = true;
                ALTER ROLE "user" WITH LOGIN;
        EOF
BASH