-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab0470f
commit 84d0d0d
Showing
7 changed files
with
213 additions
and
140 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -exuo pipefail | ||
|
||
exec 3>&1 | ||
exec 1>&2 | ||
|
||
main() ( | ||
dsc="$(realpath "$1")" | ||
dpkg_arch="$(dpkg --print-architecture)" | ||
dsc_arch="$(grep -oP '(?<=^Architecture: ).*' < "$dsc" | tr ' ' '\n')" | ||
|
||
grep -P '^(linux-)?(any|'"$dpkg_arch"')$' <<< "$dsc_arch" || exit 0 | ||
|
||
sudo apt-get build-dep --no-install-recommends -y "$dsc" | ||
|
||
dpkg-source --extract "$dsc" src | ||
cd src | ||
name="$(dpkg-parsechangelog --show-field Source)" | ||
version="$(dpkg-parsechangelog --show-field Version)" | ||
DEB_BUILD_OPTIONS="terse ${DEB_BUILD_OPTIONS-}" dpkg-buildpackage --no-sign --build=any | ||
cd .. | ||
rm -rf src | ||
ls -lah | ||
|
||
echo "${name}_${version}_${dpkg_arch}" >&3 | ||
) | ||
|
||
main "$@" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -exuo pipefail | ||
|
||
exec 3>&1 | ||
exec 1>&2 | ||
|
||
main() ( | ||
dsc="$(realpath "$1")" | ||
dsc_arch="$(grep -oP '(?<=^Architecture: ).*' < "$dsc" | tr ' ' '\n')" | ||
|
||
grep -P '^(linux-)?all$' <<< "$dsc_arch" || exit 0 | ||
|
||
sudo apt-get build-dep --no-install-recommends -y "$dsc" | ||
|
||
dpkg-source --extract "$dsc" src | ||
cd src | ||
name="$(dpkg-parsechangelog --show-field Source)" | ||
version="$(dpkg-parsechangelog --show-field Version)" | ||
DEB_BUILD_OPTIONS="terse ${DEB_BUILD_OPTIONS-}" dpkg-buildpackage --no-sign --build=all | ||
cd .. | ||
rm -rf src | ||
ls -lah | ||
|
||
echo "${name}_${version}_all" >&3 | ||
) | ||
|
||
main "$@" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -exuo pipefail | ||
|
||
exec 3>&1 | ||
exec 1>&2 | ||
|
||
main() ( | ||
debian_source= | ||
while [ $# -gt 0 ]; do | ||
case "$1" in | ||
--debian-source) | ||
debian_source="$2" | ||
shift 2 | ||
;; | ||
*) | ||
break | ||
;; | ||
esac | ||
done | ||
|
||
source="$1" | ||
shift | ||
|
||
patches=() | ||
|
||
while [ $# -gt 0 ]; do | ||
patches+=("$1") | ||
shift | ||
done | ||
|
||
if [[ "$source" = "git+"* ]]; then | ||
git_source "${source#git+}" | ||
else | ||
apt_source "$source" | ||
fi | ||
|
||
if [ -n "$debian_source" ]; then | ||
mkdir debian_src | ||
cd debian_src | ||
if [[ "$debian_source" = "git+"* ]]; then | ||
git_source "${debian_source#git+}" | ||
else | ||
apt_source "$debian_source" | ||
fi | ||
rm -rf ../src/debian | ||
mv src/debian ../src/ | ||
cd .. | ||
rm -rf debian_src | ||
fi | ||
|
||
cd src | ||
|
||
for patch in "${patches[@]}"; do | ||
apply_patches "$patch" | ||
done | ||
|
||
name="$(dpkg-parsechangelog --show-field Source)" | ||
version="$(dpkg-parsechangelog --show-field Version)" | ||
version_orig="${version%-*}" | ||
gzip < ../orig.tar > "../${name}_${version_orig}.orig.tar.gz" | ||
rm ../orig.tar | ||
|
||
dpkg-source --build . | ||
|
||
cd .. | ||
rm -rf src | ||
ls -lah | ||
|
||
echo "${name}_${version}" >&3 | ||
) | ||
|
||
apt_source() ( | ||
apt-get source --only-source --download-only "$1" | ||
orig=(*.orig.tar.*) | ||
debian=(*.debian.tar.*) | ||
dsc=(*.dsc) | ||
auto_decompress "$orig" > orig.tar | ||
mkdir src | ||
tar -C src -x --strip-components 1 < orig.tar | ||
auto_decompress "$debian" | tar -C src -xv | ||
rm "$orig" "$debian" "$dsc" | ||
) | ||
|
||
git_source() ( | ||
IFS='#' read -r url ref <<< "$1" | ||
git clone --bare --branch "$ref" --depth 1 "$url" src.git | ||
GIT_DIR=src.git git archive --prefix src/ "$ref" > orig.tar | ||
rm -rf src.git | ||
tar -x < orig.tar | ||
) | ||
|
||
auto_decompress() ( | ||
case "${1##*.}" in | ||
gz) | ||
gzip -d < "$1" | ||
;; | ||
xz) | ||
xz -d < "$1" | ||
;; | ||
*) | ||
exit 1 | ||
;; | ||
esac | ||
) | ||
|
||
apply_patches() ( | ||
git_dir="$(realpath $(mktemp -u ../patches.tmp.XXXX))" | ||
if [[ "$1" = "git+"* ]]; then | ||
IFS='#' read -r url ref <<< "${1#git+}" | ||
git clone --branch "$ref" --depth 1 "$url" "$git_dir" | ||
dir="$git_dir" | ||
else | ||
dir="$(cd .. && realpath "$1")" | ||
fi | ||
|
||
if [ -x "$dir/exec.pre" ]; then | ||
SOURCE="$source" "$dir/exec.pre" | ||
fi | ||
|
||
if [ -f "$dir/patches/series" ]; then | ||
while read -r patch; do | ||
patch -p1 < "$dir/patches/$patch" | ||
done < "$dir/patches/series" | ||
fi | ||
|
||
version="$(yq -r .version < "$dir/changelog_config.yaml")" | ||
[ "$version" != null ] || version="$(dpkg-parsechangelog --show-field Version)" | ||
email="$(yq -r .email < "$dir/changelog_config.yaml")" | ||
name="$(yq -r .name < "$dir/changelog_config.yaml")" | ||
distribution="$(yq -r .distribution < "$dir/changelog_config.yaml")" | ||
version_suffix="$(yq -r .version_suffix < "$dir/changelog_config.yaml")" | ||
message="$(yq -r .message < "$dir/changelog_config.yaml")" | ||
DEBEMAIL="$email" DEBFULLNAME="$name" dch --newversion "$version$version_suffix" --distribution "$distribution" --force-distribution -- "$message" | ||
|
||
if [ -x "$dir/exec.post" ]; then | ||
SOURCE="$source" "$dir/exec.post" | ||
fi | ||
|
||
[ ! -e "$git_dir" ] || rm -rf "$git_dir" | ||
) | ||
|
||
main "$@" |
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