Importing a new upstream release

 1. Download the OpenBSD tarball and its detached signature

   $ OPENBSD_VERSION=6.2
   $ DESTDIR="$XDG_RUNTIME_DIR"
   $ rsync -P rsync://ftp.eu.openbsd.org/OpenBSD/$OPENBSD_VERSION/{src.tar.gz,SHA256.sig} "$DESTDIR"

 2. Verify its integrity (requires 'signify-openbsd' and 'signify-openbsd-keys' packages)

   $ PUBKEY="/usr/share/signify-openbsd-keys/openbsd-${OPENBSD_VERSION//./}-base.pub"
   $ ( cd "$DESTDIR" && signify-openbsd -p "$PUBKEY" -Cx SHA256.sig src.tar.gz )
   Signature Verified
   src.tar.gz: OK

 3. Extract to the netcat repo (branch upstream)

   $ git checkout upstream
   $ git fetch https://github.com/openbsd/src
   $ git branch openbsd FETCH_HEAD
   $ git filter-branch --subdirectory-filter usr.bin/nc/ --prune-empty -- refs/heads/openbsd
   $ git update-ref -d refs/original/refs/heads/openbsd
   $ git rm -r .
   $ ls # ensure there are no left-overs
   $ tar --extract --exclude CVS --exclude obj --strip-components=2 -vzf "$DESTDIR/src.tar.gz" usr.bin/nc/
   $ git add --all
   $ NETCAT_VERSION="$(git ls-files -cz | xargs -r0 sed -nsr '0,/^\s*\/\*\s*\$OpenBSD: .*,\s*v\s*([0-9]+(\.[0-9]+)*).* \$\s*\*\/$/ s//\1/p' \
            | sort -V | tail -n1)"
   $ [ -n "$NETCAT_VERSION" ] && git --no-pager diff --cached refs/heads/openbsd && # make sure the diff is empty, otherwise use an ancestor below
       tree="$(git write-tree)" &&
       id="$(git commit-tree -p HEAD -p refs/heads/openbsd -m "Import upstream version $NETCAT_VERSION from OpenBSD $OPENBSD_VERSION" "$tree")" &&
       git update-ref refs/heads/upstream "$id"
   $ git branch -d openbsd
   $ git tag --sign -m "Upstream version $NETCAT_VERSION" "upstream/$NETCAT_VERSION"

 4. Merge to debian/latest branch

   $ git checkout debian/latest
   $ git merge -m "Update upstream source from tag 'upstream/$NETCAT_VERSION'" -m "Update to upstream version $NETCAT_VERSION" "upstream/$NETCAT_VERSION"

 5. Rebase Debian-specific patches

   $ gbp pq drop
   $ gbp pq rebase
   $ gbp pq export
   $ git add -p debian/patches
   $ git commit -m "Refresh d/patches." debian/patches

 6. Bump version number

   $ gbp dch -N "$NETCAT_VERSION-1" --commit

 -- Guilhem Moulin <guilhem@debian.org>  Wed, 12 Apr 2023 01:28:43 +0200
