Browse Source

Refactor the deb package extraction into a function

Changelog: None

Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
2.3.x
Lluis Campos 4 years ago
parent
commit
1ceda66f8d
  1. 29
      mender-convert-modify
  2. 24
      modules/deb.sh

29
mender-convert-modify

@ -96,27 +96,22 @@ mkdir -p work/rootfs
sudo mount ${boot_part} work/boot
sudo mount ${root_part} work/rootfs
mkdir -p work/mender-client-deb/files
mkdir -p work/deb-packages
log_info "Installing Mender client and related files"
deb_arch=$(probe_debian_arch_name)
if [ "${MENDER_CLIENT_VERSION}" = "latest" ]; then
deb_name=$(deb_from_repo_get "work/mender-client-deb" ${MENDER_APT_REPO_URL} ${deb_arch} "stable" "mender-client" "latest")
deb_name=$(deb_from_repo_get "work/deb-packages" ${MENDER_APT_REPO_URL} ${deb_arch} "stable" "mender-client" "latest")
elif [ "${MENDER_CLIENT_VERSION}" = "master" ]; then
deb_name=$(deb_from_repo_get "work/mender-client-deb" ${MENDER_APT_REPO_URL} ${deb_arch} "experimental" "mender-client" "latest")
deb_name=$(deb_from_repo_get "work/deb-packages" ${MENDER_APT_REPO_URL} ${deb_arch} "experimental" "mender-client" "latest")
else
DEBIAN_REVISION="-1"
deb_name=$(deb_from_repo_get "work/mender-client-deb" ${MENDER_APT_REPO_URL} ${deb_arch} "experimental" "mender-client" "${MENDER_CLIENT_VERSION}${DEBIAN_REVISION}")
deb_name=$(deb_from_repo_get "work/deb-packages" ${MENDER_APT_REPO_URL} ${deb_arch} "experimental" "mender-client" "${MENDER_CLIENT_VERSION}${DEBIAN_REVISION}")
fi
cd work/mender-client-deb
run_and_log_cmd "ar -xv ${deb_name}"
run_and_log_cmd "sudo tar xJf data.tar.xz -C files"
cd - > /dev/null 2>&1
run_and_log_cmd "sudo rsync --archive --keep-dirlinks --verbose work/mender-client-deb/files/ work/rootfs/"
deb_extract_package "work/deb-packages/${deb_name}" "work/rootfs/"
if [ "${MENDER_ENABLE_SYSTEMD}" == "y" ]; then
run_and_log_cmd "sudo ln -sf /lib/systemd/system/mender-client.service \
@ -125,24 +120,18 @@ fi
if [ "${MENDER_ADDON_SHELL_INSTALL}" = "y" ]; then
mkdir -p work/mender-shell-deb/files
log_info "Installing Mender Shell addon"
if [ "${MENDER_ADDON_SHELL_VERSION}" = "latest" ]; then
deb_name=$(deb_from_repo_get "work/mender-shell-deb" ${MENDER_APT_REPO_URL} ${deb_arch} "stable" "mender-shell" "latest")
deb_name=$(deb_from_repo_get "work/deb-packages" ${MENDER_APT_REPO_URL} ${deb_arch} "stable" "mender-shell" "latest")
elif [ "${MENDER_ADDON_SHELL_VERSION}" = "master" ]; then
deb_name=$(deb_from_repo_get "work/mender-shell-deb" ${MENDER_APT_REPO_URL} ${deb_arch} "experimental" "mender-shell" "latest")
deb_name=$(deb_from_repo_get "work/deb-packages" ${MENDER_APT_REPO_URL} ${deb_arch} "experimental" "mender-shell" "latest")
else
DEBIAN_REVISION="-1"
deb_name=$(deb_from_repo_get "work/mender-shell-deb" ${MENDER_APT_REPO_URL} ${deb_arch} "experimental" "mender-shell" "${MENDER_ADDON_SHELL_VERSION}${DEBIAN_REVISION}")
deb_name=$(deb_from_repo_get "work/deb-packages" ${MENDER_APT_REPO_URL} ${deb_arch} "experimental" "mender-shell" "${MENDER_ADDON_SHELL_VERSION}${DEBIAN_REVISION}")
fi
cd work/mender-shell-deb
run_and_log_cmd "ar -xv ${deb_name}"
run_and_log_cmd "sudo tar xJf data.tar.xz -C files"
cd - > /dev/null 2>&1
run_and_log_cmd "sudo rsync --archive --keep-dirlinks --verbose work/mender-shell-deb/files/ work/rootfs/"
deb_extract_package "work/deb-packages/${deb_name}" "work/rootfs/"
run_and_log_cmd "sudo ln -sf /lib/systemd/system/mender-shell.service \
work/rootfs/etc/systemd/system/multi-user.target.wants/mender-shell.service"

24
modules/deb.sh

@ -62,3 +62,27 @@ function deb_from_repo_get () {
log_info "Successfully downloaded ${filename}"
echo ${filename}
}
# Extract the binary files of a deb package into a directory
#
# $1 - Deb package
# $2 - Dest directory
#
function deb_extract_package () {
if [[ $# -ne 2 ]]; then
log_fatal "deb_extract_package() requires 2 arguments"
fi
local -r deb_package="$(pwd)/${1}"
local -r dest_dir="$(pwd)/${2}"
local -r extract_dir=$(mktemp -d)
cd ${extract_dir}
run_and_log_cmd "ar -xv ${deb_package}"
mkdir -p files
run_and_log_cmd "sudo tar xJf data.tar.xz -C files"
cd - > /dev/null 2>&1
run_and_log_cmd "sudo rsync --archive --keep-dirlinks --verbose ${extract_dir}/files/ ${dest_dir}"
log_info "Successfully installed $(basename ${filename})"
}

Loading…
Cancel
Save