mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-01-18 08:58:15 +01:00
build: better change build dev container name.
This commit is contained in:
parent
736e44a483
commit
7632a2c168
1 changed files with 28 additions and 26 deletions
|
@ -8,6 +8,7 @@
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
readonly BASEIMAGE="${BASEIMAGE:-}"
|
readonly BASEIMAGE="${BASEIMAGE:-}"
|
||||||
|
readonly IMAGEPREFIX="builder-"
|
||||||
readonly PKGNAME=apparmor.d
|
readonly PKGNAME=apparmor.d
|
||||||
readonly VOLUME=/tmp/build
|
readonly VOLUME=/tmp/build
|
||||||
readonly BUILDIR=/home/build/tmp
|
readonly BUILDIR=/home/build/tmp
|
||||||
|
@ -17,13 +18,13 @@ PACKAGER="$(git config user.name) <$(git config user.email)>"
|
||||||
readonly VERSION PACKAGER
|
readonly VERSION PACKAGER
|
||||||
|
|
||||||
_start() {
|
_start() {
|
||||||
local name="$1"
|
local img="$1"
|
||||||
docker start "$name"
|
docker start "$img"
|
||||||
}
|
}
|
||||||
|
|
||||||
_is_running() {
|
_is_running() {
|
||||||
local name="$1"
|
local img="$1"
|
||||||
res="$(docker inspect -f '{{ .State.Running }}' "$name")" &>/dev/null
|
res="$(docker inspect -f '{{ .State.Running }}' "$img")" &>/dev/null
|
||||||
exist=$?
|
exist=$?
|
||||||
if [[ $exist -ne 0 ]]; then
|
if [[ $exist -ne 0 ]]; then
|
||||||
return $exist
|
return $exist
|
||||||
|
@ -35,8 +36,8 @@ _is_running() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_exist() {
|
_exist() {
|
||||||
local name="$1"
|
local img="$1"
|
||||||
docker inspect -f '{{ .State.Running }}' "$name" &>/dev/null
|
docker inspect -f '{{ .State.Running }}' "$img" &>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
sync() {
|
sync() {
|
||||||
|
@ -45,42 +46,44 @@ sync() {
|
||||||
}
|
}
|
||||||
|
|
||||||
build_in_docker_makepkg() {
|
build_in_docker_makepkg() {
|
||||||
local name="$1"
|
local dist="$1"
|
||||||
|
local img="$IMAGEPREFIX$dist"
|
||||||
|
|
||||||
if _exist "$name"; then
|
if _exist "$img"; then
|
||||||
if ! _is_running "$name"; then
|
if ! _is_running "$img"; then
|
||||||
_start "$name"
|
_start "$img"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
docker build -t "$BASEIMAGE$name" "dists/build/$name"
|
docker build -t "$BASEIMAGE$img" "dists/build/$dist"
|
||||||
docker run -tid --name "$name" --volume "$VOLUME:$BUILDIR" \
|
docker run -tid --name "$img" --volume "$PWD:$BUILDIR" \
|
||||||
--env MAKEFLAGS="-j$(nproc)" --env PACKAGER="$PACKAGER" \
|
--env MAKEFLAGS="-j$(nproc)" --env PACKAGER="$PACKAGER" \
|
||||||
--env PKGDEST="$BUILDIR" --env DIST="$name" \
|
--env PKGDEST="$BUILDIR" --env DIST="$dist" \
|
||||||
"$BASEIMAGE$name"
|
"$BASEIMAGE$img"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker exec -i --workdir="$BUILDIR/$PKGNAME" "$name" \
|
docker exec -i "$img" \
|
||||||
makepkg -sfC --noconfirm --noprogressbar
|
makepkg -sfC --noconfirm --noprogressbar
|
||||||
mv "$VOLUME/$PKGNAME"-*.pkg.* .
|
mv "$VOLUME/$PKGNAME"-*.pkg.* .
|
||||||
}
|
}
|
||||||
|
|
||||||
build_in_docker_dpkg() {
|
build_in_docker_dpkg() {
|
||||||
local name="$1"
|
local dist="$1"
|
||||||
|
local img="$IMAGEPREFIX$dist"
|
||||||
|
|
||||||
if _exist "$name"; then
|
if _exist "$img"; then
|
||||||
if ! _is_running "$name"; then
|
if ! _is_running "$img"; then
|
||||||
_start "$name"
|
_start "$img"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
docker build -t "$BASEIMAGE$name" "dists/build/$name"
|
docker build -t "$BASEIMAGE$img" "dists/build/$dist"
|
||||||
docker run -tid --name "$name" --volume "$VOLUME:$BUILDIR" \
|
docker run -tid --name "$img" --volume "$VOLUME:$BUILDIR" \
|
||||||
--env DEBIAN_FRONTEND=noninteractive --env DIST="$name" \
|
--env DEBIAN_FRONTEND=noninteractive --env DIST="$dist" \
|
||||||
"$BASEIMAGE$name"
|
"$BASEIMAGE$img"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker exec --workdir="$BUILDIR/$PKGNAME" "$name" \
|
docker exec --workdir="$BUILDIR/$PKGNAME" "$img" \
|
||||||
dch --newversion="$VERSION" --urgency=medium --distribution=stable --controlmaint "Release $VERSION"
|
dch --newversion="$VERSION" --urgency=medium --distribution=stable --controlmaint "Release $VERSION"
|
||||||
docker exec --workdir="$BUILDIR/$PKGNAME" "$name" \
|
docker exec --workdir="$BUILDIR/$PKGNAME" "$img" \
|
||||||
dpkg-buildpackage -b -d --no-sign
|
dpkg-buildpackage -b -d --no-sign
|
||||||
mv "$VOLUME/${PKGNAME}_${VERSION}"_*.* .
|
mv "$VOLUME/${PKGNAME}_${VERSION}"_*.* .
|
||||||
}
|
}
|
||||||
|
@ -88,7 +91,6 @@ build_in_docker_dpkg() {
|
||||||
main() {
|
main() {
|
||||||
case "$COMMAND" in
|
case "$COMMAND" in
|
||||||
archlinux)
|
archlinux)
|
||||||
sync
|
|
||||||
build_in_docker_makepkg "$COMMAND"
|
build_in_docker_makepkg "$COMMAND"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue