build-sys: make docbook path find easier to read
[openafs.git] / src / packaging / Debian / import-upstream
1 #!/bin/sh
2 #
3 # This script is used rather than git-import-orig to import a new upstream
4 # tarball.  It does essentially the same work as git-import-orig -- take the
5 # contents of the tarball and commit it to the upstream branch and then tag it
6 # with a new upstream/* tag -- but it records that commit as a merge commit
7 # between the upstream branch and another tag.
8 #
9 # The purpose of this procedure is to have the imported tarball look to Git
10 # like a merge between upstream's tagged Git tree corresponding to that
11 # tarball and our upstream branch.  This lets things like git cherry-pick work
12 # properly against upstream's release branch.
13 #
14 # This script assumes that the upstream tarball has already had non-DFSG
15 # material removed.
16 #
17 # Written by Sam Hartman <hartmans@debian.org> for krb5
18 # Adopted for openafs by Russ Allbery <rra@debian.org>
19
20 set -e
21
22 if [ $# -ne 3 ] ; then
23     echo "Usage: import-upstream <tarball> <upstream-tag> <local-tag>" >&2
24     exit 2
25 fi
26 tarball="$1"
27 upstream="$2"
28 tag="$3"
29
30 # Unpack the tarball.
31 dir=$(basename $(tar tzf "$tarball" | head -1))
32 tar xzf "$tarball"
33
34 # Add the tarball to the current index and then use that to create a tree
35 # object corresponding to the contents of that directory.  Then, use
36 # commit-tree to commit that to the repository.
37 git add -f "$dir"
38 tree=$(git write-tree --prefix="$dir"/)
39 commit=$(echo "Imported upstream tag $upstream via tarball" | \
40     git commit-tree "$tree" -p upstream-1.5 -p $(git rev-list -n1 "$upstream"))
41
42 # Now that we have a commit, repoint upstream at that commit, tag it, and then
43 # remove the unpacked upstream tarball from our index.
44 git branch -f upstream-1.5 "$commit"
45 git tag "$tag" "$commit"
46 git rm -q -r -f "$dir"
47 rm -rf "$dir"