From 435529497eec3ebfa5e1d29a6e1e633976f8172c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20K=C3=BCthe?= Date: Wed, 17 Jan 2024 00:41:49 +0000 Subject: [PATCH] Improve error handling --- deb/build.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/deb/build.sh b/deb/build.sh index 6918e9c..f291b35 100755 --- a/deb/build.sh +++ b/deb/build.sh @@ -12,24 +12,28 @@ die () { ) ( - mkdir ../build - cd ../build + mkdir ../build || die "Failed to create build directory" + cd ../build || die "Failed to change to build directory" cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr .. || die "Failed to configure project" cmake --build .. || die "Failed to build project" cmake --install .. --prefix "../deb/package/" || die "Failed to install project into package directory" ) -mkdir -p package/DEBIAN/ +mkdir -p package/DEBIAN/ || die "Failed to create meta data directory" + VERSION="$(git describe --long | sed 's/^libtuntap-//')" -cp control.template package/DEBIAN/control -sed "s/%VERSION%/$VERSION/" -i package/DEBIAN/control -sed "s/%ARCHITECTURE%/$(dpkg --print-architecture)/" -i package/DEBIAN/control +[ "$VERSION" ] || die "Failed to get version string" +ARCH="$(dpkg --print-architecture)" +[ "$ARCH" ] || die "Failed to get architecture string" + +cp control.template package/DEBIAN/control || die "Failed to copy control template" +sed "s/%VERSION%/$VERSION/" -i package/DEBIAN/control || die "Failed to replace version in control template" +sed "s/%ARCHITECTURE%/$ARCH/" -i package/DEBIAN/control || die "Failed to replace architecture in control template" -mkdir -p package/usr/share/doc/libtuntap-dev/ -cp copyright package/usr/share/doc/libtuntap-dev/copyright +mkdir -p package/usr/share/doc/libtuntap-dev/ || die "Failed to create package meta data directory" +cp copyright package/usr/share/doc/libtuntap-dev/copyright || die "Failed to copy copyright file" echo "Building package..." dpkg-deb --root-owner-group --build package libtuntap-dev.deb || die "Failed to build package" echo "Package $(dpkg-deb --show libtuntap-dev.deb | sed "s/\t/ /") successful builded!" -