Last active
July 17, 2020 15:56
-
-
Save paride/0b1a4d2556452bcbe68bbd82e1cd904b to your computer and use it in GitHub Desktop.
Build a deb of from the current branch
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 | |
fail() { echo "$@" 1>&2; exit 1; } | |
cleanup() { | |
rm -rf "$tmpd" | |
git worktree prune | |
} | |
if [[ $1 = "-h" || $1 = "--help" ]]; then | |
cat <<-EOF | |
Usage: ${0##*/} [debuild options] | |
Build a deb of from the current branch: | |
1. Run build-deb-prepare to prepare the debian/ dir and orig tarball. | |
2. Run debuild, passing it the provided options. | |
3. Cleanup the working tree. | |
The generated files will be places in the parent directory, as in | |
a normal debuild run. | |
Example: ${0##*/} -us -uc | |
EOF | |
exit | |
fi | |
if [[ $(git status -s) ]]; then | |
cat 1>&2 <<-EOF | |
WARNING: There are uncommitted changes in your working directory. | |
These changes will not be included in the package. | |
EOF | |
fi | |
scriptdir=$(dirname "${BASH_SOURCE[0]}") | |
tmpd=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX") || | |
fail "failed to make tempdir" | |
wtd="${tmpd}/build-deb-worktree" | |
trap cleanup EXIT | |
git worktree add "$wtd" HEAD || fail "Failed worktree add $wtd" | |
pushd "$wtd" || fail "Failed to chdir to $wtd" | |
"$scriptdir/build-deb-prepare" || fail "Failed to run build-deb-prepare." | |
debuild "$@" || fail "debuild failed." | |
popd || fail "Failed to chdir to the initial source tree." | |
git worktree remove --force "$wtd" | |
cp "$tmpd/"* . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment