1
0
dotfiles/.config/zsh/alias/sbuild.zsh

75 lines
1.8 KiB
Bash
Raw Permalink Normal View History

2024-01-27 00:10:58 +03:00
#!/bin/zsh
krd-debsrc() {
2024-03-04 15:35:55 +03:00
(( $+commands[deb-src-export] )) || return 127
[ -n "${1:?}" ]
2024-01-27 00:10:58 +03:00
local dstdir
case "$1" in
*/* ) dstdir="$1/src" ;;
* ) dstdir="/tmp/$1/src" ;;
esac
rm -rf "${dstdir}"
deb-src-export "${dstdir}"
}
krd-sbuild() {
2024-03-04 15:35:55 +03:00
(( $+commands[sbuild] )) || return 127
(( $+commands[xz] )) || return 127
2024-01-27 00:10:58 +03:00
2024-03-04 15:35:55 +03:00
[ -n "${1:?}" ]
[ -n "${2:?}" ]
2024-01-27 00:10:58 +03:00
local topdir
case "$1" in
*/* ) topdir="$1" ;;
* ) topdir="/tmp/$1" ;;
esac
2024-03-04 15:35:55 +03:00
[ -d "${topdir}" ] || return 1
2024-01-27 00:10:58 +03:00
local srcdir="${topdir}/src"
2024-03-04 15:35:55 +03:00
[ -d "${srcdir}" ] || return 2
2024-01-27 00:10:58 +03:00
arch="$2"
## done with args
shift 2
local -a sbuild_env sbuild_args
local i
for i ; do
## naive splitting args and env
case "$i" in
2024-08-03 13:51:01 +03:00
-*) sbuild_args+=( $i ) ;;
2024-01-27 00:10:58 +03:00
*=* ) sbuild_env+=( $i ) ;;
*) sbuild_args+=( $i ) ;;
esac
done
(
for i ( ${sbuild_env} ) ; do
export "$i"
done
z-set-tmpdir /tmp
builddir="${topdir}/${arch}"
2024-08-03 14:08:31 +03:00
mkdir -p "${topdir}/all" "${builddir}" "${builddir}-all" "${builddir}-debug"
2024-01-27 00:10:58 +03:00
cd "${builddir}"
for i ( "${srcdir}"/*.dsc(N.r) ) ; do
idle sbuild --arch-all --arch-any --arch=${arch} ${sbuild_args[@]} "$i"
find -name '*.build' -type l -exec rm -f {} +
find -name '*.build' -type f -exec xz -9vv {} +
done
2024-08-03 14:08:31 +03:00
find -name '*_all.deb' -type f -exec mv -fvt "../${arch}-all" {} +
find -name '*_all.ddeb' -type f -exec mv -fvt "../${arch}-all" {} +
find -name '*dbgsym*.deb' -type f -exec mv -fvt "../${arch}-debug" {} +
find -name '*.ddeb' -type f -exec mv -fvt "../${arch}-debug" {} +
cd "${builddir}-all"
find -type f -exec mv -nvt '../all' {} +
2024-01-27 00:10:58 +03:00
)
}