Skip to content

Instantly share code, notes, and snippets.

@mwhudson
Last active May 14, 2019 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwhudson/e827487b579a2ea076cb984c42c47b3b to your computer and use it in GitHub Desktop.
Save mwhudson/e827487b579a2ea076cb984c42c47b3b to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eux
tarball=$1
#tmpdir=$(mktemp -d)
#cleanup () { rm -rf $tmpdir; }
#trap cleanup EXIT
tmpdir=../my-uupdate-work
rm -rf $tmpdir
mkdir $tmpdir
mkdir $tmpdir/unpacked
for tarball; do
subdir=
if [ ${tarball#*=} != $tarball ]; then
subdir=${tarball%=*}
fi
mkdir -p $tmpdir/unpacked/$subdir
tar -C $tmpdir/unpacked/$subdir -xf ${tarball#*=} --strip-components=1
done
index_file=$(realpath .git/my-uupdate-index)
rm -f $index_file
GIT_INDEX_FILE=$index_file GIT_WORK_TREE=$tmpdir/unpacked git add -A -f
tmp_tree=$(GIT_INDEX_FILE=$index_file git write-tree)
git ls-tree ${tmp_tree} > $tmpdir/tree
deb_sha=$(git ls-tree HEAD^{tree} | awk '{ if ($4 == "debian") { print $3; } }')
echo -e "040000 tree $deb_sha\tdebian" >> $tmpdir/tree
new_tree=$(cat $tmpdir/tree | git mktree)
echo "Update upstream source from '$(for tarball; do echo -n $(basename $tarball); done)'" > $tmpdir/commit-msg
commit=$(git commit-tree -p HEAD -F $tmpdir/commit-msg ${new_tree})
git merge $commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment