Skip to content

Commit

Permalink
[debian] Fix postinst script (#12964)
Browse files Browse the repository at this point in the history
This commit makes postinst use ubuntu codename instead of the su exit code.

ONE-DCO-1.0-Signed-off-by: seongwoo <[email protected]>
  • Loading branch information
mhs4670go authored May 3, 2024
1 parent 5eb46c0 commit 8fbcc67
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions infra/debian/compiler/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
# Boradly speaking, the `postinst` is called after a package is unpacked.

set +e
set -e

# `postinst` script is invoked as root except given environmental variables specified in the w option,
# which causes invalid permission problem.
# e.g. When `pip` installs user packages, it proceeds based on $HOME.
# To proper installation, $HOME should be root.
su - $(whoami) -w ONE_PREPVENV_TORCH_SOURCE -c '/usr/share/one/bin/one-prepare-venv' # $(whoami) = root
if [[ $? == 1 ]]; then
# Ubuntu 18.04 doesn't support w option.
su - $(whoami) -p -c '/usr/share/one/bin/one-prepare-venv' # $(whoami) = root
CODENAME=$(awk -F "=" '/UBUNTU_CODENAME/ {print $2}' /etc/os-release)
if [[ $CODENAME == "bionic" ]]; then
# Ubuntu 18.04 doesn't support w option.
su - $(whoami) -p -c '/usr/share/one/bin/one-prepare-venv' # $(whoami) = root
else
su - $(whoami) -w ONE_PREPVENV_TORCH_SOURCE -c '/usr/share/one/bin/one-prepare-venv' # $(whoami) = root
fi

0 comments on commit 8fbcc67

Please sign in to comment.