From dbc84bb379dedc59d1853f2ed25335c2ef511db7 Mon Sep 17 00:00:00 2001 From: Alopez <alopez@iri.upc.edu> Date: Wed, 4 Nov 2020 10:15:20 +0100 Subject: [PATCH] Adapted to Ubuntu 18.04 package generation --- CMakeLists_template.txt | 4 ++-- new_project.sh | 25 ++++++++++++++++++++++++- postinst_template | 22 ++++++++++++++++++++++ prerm_template | 22 ++++++++++++++++++++++ 4 files changed, 70 insertions(+), 3 deletions(-) create mode 100755 postinst_template create mode 100644 prerm_template diff --git a/CMakeLists_template.txt b/CMakeLists_template.txt index dcccd30..bd8284c 100755 --- a/CMakeLists_template.txt +++ b/CMakeLists_template.txt @@ -77,7 +77,7 @@ IF (UNIX) SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "labrobotica - labrobotica@iri.upc.edu") #Uncomment to add the necessary mantainer scripts - #SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/scripts/debian/preinst;${CMAKE_SOURCE_DIR}/scripts/debian/postinst;${CMAKE_SOURCE_DIR}/scripts/debian/prerm;${CMAKE_SOURCE_DIR}/scripts/debian/postrm") + SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/scripts/debian/postinst;${CMAKE_SOURCE_DIR}/scripts/debian/prerm") #Uncomment to add dependencies comma separated #SET(CPACK_DEBIAN_PACKAGE_DEPENDS "iri-dep1-dev (>= 1.0~${DISTRIB}), iri-dep2-dev (>= 1.0~${DISTRIB})") @@ -88,4 +88,4 @@ ELSE(UNIX) COMMENT "packaging only implemented in unix" TARGET uninstall ) -ENDIF(UNIX) \ No newline at end of file +ENDIF(UNIX) diff --git a/new_project.sh b/new_project.sh index 7f011a0..e78c24e 100755 --- a/new_project.sh +++ b/new_project.sh @@ -168,6 +168,24 @@ else echo "Creating $FILES_DIR directory" mkdir $FILES_DIR fi +#create the scripts directory +SCRIPTS_DIR="./scripts" +if [ -e "$SCRIPTS_DIR" ] +then + echo "$SCRIPTS_DIR directory already exists, skipping ..." +else + echo "Creating $SCRIPTS_DIR directory" + mkdir $SCRIPTS_DIR +fi +#create the scripts/debian directory +DEBIAN_DIR="./scripts/debian" +if [ -e "$DEBIAN_DIR" ] +then + echo "$DEBIAN_DIR directory already exists, skipping ..." +else + echo "Creating $DEBIAN_DIR directory" + mkdir $DEBIAN_DIR +fi #parse the dependencies and create the dependencies file arr=$(echo $DEP | tr "," "\n") @@ -376,6 +394,9 @@ then sed -i "/${comment}/ a ${line_to_add}" ${file} fi +sed 's/project_name/'$NAME'/g' <postinst_template >./scripts/debian/postinst +sed 's/project_name/'$NAME'/g' <prerm_template >./scripts/debian/prerm + if [ $TEST = 1 ] then Library_name=$(echo $NAME | sed 's/\([a-zA-Z]\)\([a-zA-Z0-9]*\)/\u\1\2/g') @@ -395,4 +416,6 @@ rm driver_example_src_template.cpp rm Findlib_template.cmake rm .gitlab-ci_template.yml rm new_project.sh -rm -rf .git \ No newline at end of file +rm -rf .git +rm postinst_template +rm prerm_template diff --git a/postinst_template b/postinst_template new file mode 100755 index 0000000..b99aca1 --- /dev/null +++ b/postinst_template @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +case "$1" in + configure) + echo " Trying to add library to ldconfig..." + /usr/share/iri/add_lib_to_ld_config.sh -l project_name -p && echo " Done." || echo " /usr/share/iri/add_lib_to_ld_config.sh doesn't exists. Download it from iriutils and execute it." + + ;; + abort-upgrade) + + ;; + abort-remove) + + ;; + abort-deconfigure) + + ;; +esac + +exit 0 diff --git a/prerm_template b/prerm_template new file mode 100644 index 0000000..3238e5e --- /dev/null +++ b/prerm_template @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +case "$1" in + remove) + echo " Trying to remove library from ldconfig..." + /usr/share/iri/remove_lib_from_ld_config.sh -l project_name -p && echo " Done." || echo " /usr/share/iri/remove_lib_from_ld_config.sh doesn't exists. Download it from iriutils and execute it." + + ;; + upgrade) + + ;; + deconfigure) + + ;; + failed-upgrade) + + ;; +esac + +exit 0 -- GitLab