Mise en place hooks debian + début script check-install
This commit is contained in:
65
lib/build.sh
65
lib/build.sh
@ -49,12 +49,11 @@ function exec_hook {
|
||||
|
||||
}
|
||||
|
||||
function create_debian_metadata {
|
||||
function create_debian_control_file {
|
||||
|
||||
build_dir="${1}"
|
||||
mkdir -p "${build_dir}/DEBIAN"
|
||||
debian_dir="${1}"
|
||||
|
||||
control_file="${build_dir}/DEBIAN/control"
|
||||
control_file="${debian_dir}/control"
|
||||
touch "${control_file}"
|
||||
|
||||
package_name=$(get_project_opt .name)
|
||||
@ -69,8 +68,8 @@ function create_debian_metadata {
|
||||
package_priority=$(get_project_opt .priority)
|
||||
echo "Priority: ${package_priority:-optional}" >> "${control_file}"
|
||||
|
||||
package_arch=$(get_project_opt .priority)
|
||||
echo "Architecture: ${package_arch:-any}" >> "${control_file}"
|
||||
package_arch=$(get_project_opt .package_arch)
|
||||
echo "Architecture: ${package_arch:-all}" >> "${control_file}"
|
||||
|
||||
dependencies=$( get_project_opt ".dependencies | .[\"${DISTRIB}\"] | @sh" | sed "s/' '/, /g" | sed "s/'//g" )
|
||||
|
||||
@ -86,6 +85,49 @@ function create_debian_metadata {
|
||||
|
||||
}
|
||||
|
||||
function create_debian_hooks {
|
||||
|
||||
debian_dir="${1}"
|
||||
|
||||
pre_install="$(get_project_opt .hooks.preInstall)"
|
||||
if [ ! -z "${pre_install}" ]; then
|
||||
cp "${SRC_DIR}/${pre_install}" "${debian_dir}/preinst"
|
||||
chmod +x "${debian_dir}/preinst"
|
||||
fi
|
||||
|
||||
post_install="$(get_project_opt .hooks.postInstall)"
|
||||
if [ ! -z "${post_install}" ]; then
|
||||
cp "${SRC_DIR}/${post_install}" "${debian_dir}/postinst"
|
||||
chmod +x "${debian_dir}/postinst"
|
||||
fi
|
||||
|
||||
pre_remove="$(get_project_opt .hooks.preRemove)"
|
||||
if [ ! -z "${pre_remove}" ]; then
|
||||
cp "${SRC_DIR}/${pre_remove}" "${debian_dir}/prerm"
|
||||
chmod +x "${debian_dir}/prerm"
|
||||
fi
|
||||
|
||||
post_remove="$(get_project_opt .hooks.postRemove)"
|
||||
if [ ! -z "${post_remove}" ]; then
|
||||
cp "${SRC_DIR}/${post_remove}" "${debian_dir}/postrm"
|
||||
chmod +x "${debian_dir}/postrm"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function create_debian_metadata {
|
||||
|
||||
build_dir="${1}"
|
||||
debian_dir="${build_dir}/DEBIAN"
|
||||
|
||||
# Ensure debian dir exists
|
||||
mkdir -p "${debian_dir}"
|
||||
|
||||
create_debian_control_file "${debian_dir}"
|
||||
create_debian_hooks "${debian_dir}"
|
||||
|
||||
}
|
||||
|
||||
function build_project {
|
||||
|
||||
project_name="$(get_project_opt '.name')"
|
||||
@ -107,8 +149,11 @@ function build_project {
|
||||
|
||||
exec_hook "preBuild" "${build_dir}"
|
||||
|
||||
# Ensure $DIST_DIR exists
|
||||
mkdir -p "${DIST_DIR}"
|
||||
|
||||
cd "${build_dir}/.."
|
||||
dpkg-deb --build "${project_name}"
|
||||
dpkg-deb --build "${project_name}" ${DIST_DIR}
|
||||
|
||||
info "Package created ! (${build_dir}/${project_name}.deb)"
|
||||
|
||||
@ -117,14 +162,10 @@ function build_project {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd /
|
||||
cd ${SRC_DIR}
|
||||
|
||||
exec_hook "postBuild" "${build_dir}"
|
||||
|
||||
# Copie du paquet nouvellement créé dans le répertoire "dist"
|
||||
mkdir -p "${DIST_DIR}"
|
||||
cp "${build_dir}/../${project_name}.deb" "${DIST_DIR}/${project_name}.deb"
|
||||
|
||||
}
|
||||
|
||||
function main {
|
||||
|
3
lib/install.sh
Normal file
3
lib/install.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
dpkg --install "$1" || apt-get install -f
|
Reference in New Issue
Block a user