From ab10d602158d220c6b6d9419a4a52d0485a529b6 Mon Sep 17 00:00:00 2001 From: William Petit Date: Sat, 4 Jul 2015 13:28:43 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20script=20de=20v=C3=A9rification=20d'ins?= =?UTF-8?q?tallation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check-install.sh | 19 ++++++++++++++++--- lib/build.sh | 8 +++----- lib/install.sh | 11 ++++++++++- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/check-install.sh b/check-install.sh index 5132de5..2faa228 100755 --- a/check-install.sh +++ b/check-install.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash - - source ./lib/util.sh function show_usage { @@ -24,13 +22,16 @@ function create_container { # Create temporary dir for the Dockerfile temp_dir="$(mktemp -d)" + # Link lib folder + ln -s $(readlink -f ./lib) "$temp_dir/lib" + # Create Dockerfile cat << EOF > "$temp_dir/Dockerfile" FROM $BASE_IMAGE ENV DEBIAN_FRONTEND noninteractive - RUN apt-get update + RUN apt-get update && apt-get install --yes gdebi-core ADD ./lib /root/.tamarin RUN chmod +x /root/.tamarin/install.sh @@ -53,8 +54,20 @@ EOF } function main { + + # Create container image container_tag=$(create_container) + + # Run container and install package docker run -e "DISTRIB=$BASE_IMAGE" --rm -v="$DEB_DIR:/deb" "$container_tag" "/deb/$DEB_NAME" + + # Check for return + if [ $? != 0 ]; then + fatal "Installation did not complete correctly !" + fi + + info "Installation complete." + } # Test for arguments diff --git a/lib/build.sh b/lib/build.sh index dd64277..8c08aba 100755 --- a/lib/build.sh +++ b/lib/build.sh @@ -43,8 +43,7 @@ function exec_hook { # If the script did not execute properly, we stop here if [ $? != 0 ]; then - error "The '${hook_name}' hook script did not finished properly !" - exit 1 + fatal "The '${hook_name}' hook script did not finished properly !" fi } @@ -68,7 +67,7 @@ function create_debian_control_file { package_priority=$(get_project_opt .priority) echo "Priority: ${package_priority:-optional}" >> "${control_file}" - package_arch=$(get_project_opt .package_arch) + package_arch=$(get_project_opt .arch) echo "Architecture: ${package_arch:-all}" >> "${control_file}" dependencies=$( get_project_opt ".dependencies | .[\"${DISTRIB}\"] | @sh" | sed "s/' '/, /g" | sed "s/'//g" ) @@ -158,8 +157,7 @@ function build_project { info "Package created ! (${build_dir}/${project_name}.deb)" if [ $? != 0 ]; then - error "The build process has not completed successfuly !" - exit 1 + fatal "The build process has not completed successfuly !" fi cd ${SRC_DIR} diff --git a/lib/install.sh b/lib/install.sh index 3bd48a8..775793c 100644 --- a/lib/install.sh +++ b/lib/install.sh @@ -1,3 +1,12 @@ #!/usr/bin/env bash -dpkg --install "$1" || apt-get install -f +set -e + +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +source "${DIR}/util.sh" + +info "Updating packages definition..." +apt-get update + +info "Installing package $1..." +gdebi --n "$1"