Importing Tarballs to Meet DEP-14 in an Old GIT Repository

Jun 21, 2021

To meet DEP-14 a git repository of a package must have some layout. I create a script to help to get tarballs of a package (that was already in Debian) and import them into a repository with an old structure, that is, only one branch with the debian/ directory, no upstream files.

import-origs-pristine.sh

#!/bin/sh

info()
{
	echo "This script is to import the tarballs of an existing Debian Package"
	echo "so, the package must be in Debian."
	echo "Also is assumed that your git repo only has the directory debian/"
	echo "(NO upstream code), and it has only one branch."
	echo
	echo "This is ok for you? <enter> to continue, C-c to cancel"
	read ans
}

info_end()
{
	echo
	echo "If your branch is named master, change it to debian/master"
	echo "$ git branch -m debian/master"
	echo "Now add a tag to the last version of your package at Debian"
	echo "gbp tag"
}

set_main_branch()
{
	mainbranch=`git branch | sed 's/\* //'`
}

create_branch()
{
	git checkout --orphan upstream
	git rm -rf . > /dev/null
	git commit --allow-empty -m 'Initial empty upstream branch'
}

get_tars()
{
	TMPSNAP="/tmp/.dsnap$$"

	echo -n "Getting sources of $pkg..."
	debsnap -d $TMPSNAP $pkg
	echo
}

import_tars()
{
	git checkout $mainbranch

	for tar in `ls $TMPSNAP/*orig*`; do
		gbp import-orig $tar --pristine-tar --no-interactive
	done

	git checkout upstream
}

# main
pkg=$1
if [ ! -d .git ]; then
	echo "You need to be inside a git repo."
	exit 1
fi

if [ "$pkg" = "" ]; then
	echo "$0 <package_name>"
	exit 1
fi

info
set_main_branch
create_branch
get_tars
import_tars
info_end
debian-devdebiangitshell-script

Back to talau's home