mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Improve control file management in equivs helper
This commit is contained in:
parent
dc3e07c4bd
commit
e4ec67d727
1 changed files with 10 additions and 8 deletions
|
@ -48,31 +48,33 @@ ynh_package_install() {
|
||||||
# usage: ynh_package_install_from_equivs controlfile
|
# usage: ynh_package_install_from_equivs controlfile
|
||||||
# | arg: controlfile - path of the equivs control file
|
# | arg: controlfile - path of the equivs control file
|
||||||
ynh_package_install_from_equivs() {
|
ynh_package_install_from_equivs() {
|
||||||
|
controlfile=$1
|
||||||
|
|
||||||
|
# install equivs package as needed
|
||||||
ynh_package_is_installed 'equivs' \
|
ynh_package_is_installed 'equivs' \
|
||||||
|| ynh_package_install equivs
|
|| ynh_package_install equivs
|
||||||
|
|
||||||
# retrieve package information
|
# retrieve package information
|
||||||
pkgname=$(grep '^Package: ' $1 | cut -d' ' -f 2)
|
pkgname=$(grep '^Package: ' $controlfile | cut -d' ' -f 2)
|
||||||
pkgversion=$(grep '^Version: ' $1 | cut -d' ' -f 2)
|
pkgversion=$(grep '^Version: ' $controlfile | cut -d' ' -f 2)
|
||||||
[[ -z "$pkgname" || -z "$pkgversion" ]] \
|
[[ -z "$pkgname" || -z "$pkgversion" ]] \
|
||||||
&& echo "Invalid control file" && exit 1
|
&& echo "Invalid control file" && exit 1
|
||||||
controlfile=$(readlink -f "$1")
|
|
||||||
|
|
||||||
# update packages cache
|
# update packages cache
|
||||||
ynh_package_update
|
ynh_package_update
|
||||||
|
|
||||||
# build and install the package
|
# build and install the package
|
||||||
TMPDIR=$(ynh_mkdir_tmp)
|
TMPDIR=$(ynh_mkdir_tmp)
|
||||||
(cd $TMPDIR \
|
(cp "$controlfile" "${TMPDIR}/control" \
|
||||||
&& equivs-build "$controlfile" 1>/dev/null \
|
&& cd "$TMPDIR" \
|
||||||
|
&& equivs-build ./control 1>/dev/null \
|
||||||
&& sudo dpkg --force-depends \
|
&& sudo dpkg --force-depends \
|
||||||
-i "./${pkgname}_${pkgversion}_all.deb" 2>&1 \
|
-i "./${pkgname}_${pkgversion}_all.deb" 2>&1 \
|
||||||
&& sudo apt-get -f -y -qq install) \
|
&& sudo apt-get -f -y -qq install) \
|
||||||
&& ([[ -n "$TMPDIR" ]] && rm -rf $TMPDIR)
|
&& ([[ -n "$TMPDIR" ]] && rm -rf $TMPDIR)
|
||||||
|
|
||||||
# check if the package is installed
|
# check if the package is actually installed
|
||||||
dpkg-query -W -f='${Status}' "$pkgname" 2>/dev/null \
|
ynh_package_is_installed "$pkgname"
|
||||||
| grep 'installed' >/dev/null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove package(s)
|
# Remove package(s)
|
||||||
|
|
Loading…
Add table
Reference in a new issue