Last active
May 14, 2019 11:05
-
-
Save mwhudson/e827487b579a2ea076cb984c42c47b3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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