Remove hard coded ROCm path in rdc.service
The executable rdcd was using an absolute path in rdc.service. Using update-alternatives gives the flexibility to invoke the binary from anywhere and no absolute path is required.
Change-Id: I2f3d6fcbf9dd854870cfc2e00532c504ce6cd6fc
[ROCm/rdc commit: 0ca6d6fa59]
이 커밋은 다음에 포함됨:
커밋한 사람
Galantsev, Dmitrii
부모
c314326da0
커밋
916d40d5bf
@@ -99,6 +99,7 @@ function(get_version_from_tag DEFAULT_VERSION_STRING VERSION_PREFIX GIT)
|
||||
set( VERSION_STRING "${VERSION_STRING}" PARENT_SCOPE )
|
||||
set( VERSION_MAJOR "${VERSION_MAJOR}" PARENT_SCOPE )
|
||||
set( VERSION_MINOR "${VERSION_MINOR}" PARENT_SCOPE )
|
||||
set( VERSION_PATCH "${VERSION_PATCH}" PARENT_SCOPE )
|
||||
endfunction()
|
||||
|
||||
function(num_change_since_prev_pkg VERSION_PREFIX)
|
||||
|
||||
@@ -23,8 +23,9 @@ AmbientCapabilities=CAP_DAC_OVERRIDE
|
||||
|
||||
# If we need to start anything before rdcd, use this
|
||||
# ExecStartPre=
|
||||
|
||||
ExecStart=/@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/rdcd
|
||||
# update-alternative has been run for rdcd and
|
||||
# soft link will be available in usr/bin
|
||||
ExecStart=rdcd
|
||||
|
||||
# If we need to start anything after rdcd use this
|
||||
# ExecStartPost=
|
||||
|
||||
@@ -1,5 +1,56 @@
|
||||
#!/bin/bash
|
||||
|
||||
do_update_alternatives(){
|
||||
# skip update if program doesn't exist
|
||||
command -v update-alternatives >/dev/null || return 0
|
||||
local binaries altscore now
|
||||
now=$(date -u +%s) # Number of seconds since 1 Jan 1970
|
||||
|
||||
# The reason for this approach rather than using the build number
|
||||
# is to allow for jobs from different builds. In one build job the
|
||||
# job number might be at 1200, whilst in a release job the number
|
||||
# may be only 1. This approach assums that if you install a build
|
||||
# with a different semantic version then the highest is the
|
||||
# desired one, but if you install two with the same semver then
|
||||
# the newest is the desired version.
|
||||
|
||||
# Build up a score. It needs to fit in 32 bits
|
||||
altscore=$((@VERSION_MAJOR@ - 3))
|
||||
altscore=$((altscore * 14 + @VERSION_MINOR@)) # Allow up to 14 minor
|
||||
altscore=$((altscore * 14 + @VERSION_PATCH@)) # Allow up to 14 patch
|
||||
|
||||
# So far if the version is less than 9 we have a number (altscore)
|
||||
# that is less than 1175. 2**31/1175 is about 1.8 million. So
|
||||
# multiply altscore by 1,000,000 and add in a factor of how many
|
||||
# minutes have passed from an arbitary point in time (1,600,000,000
|
||||
# seconds after 1 Jan 1970 or Sep 13 12:26:40 2020) on the
|
||||
# basis that no one is going to be installing a new version more
|
||||
# often than every minute. This does get things wrong if a million
|
||||
# minutes pass and you are downgrading, but the chances of someone
|
||||
# waiting almost 2 years between installing a version and the
|
||||
# previous patch level is small.
|
||||
|
||||
altscore=$((altscore*1000000+(now-1600000000)/60))
|
||||
|
||||
binaries=(
|
||||
rdcd
|
||||
)
|
||||
|
||||
for i in $binaries
|
||||
do
|
||||
# No obvious recover strategy if things fail
|
||||
# No manual or other slave pages to install
|
||||
if [ -e @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/"$i" ]
|
||||
then
|
||||
update-alternatives --install /usr/bin/"$i" "$i" \
|
||||
@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/"$i" "$altscore"
|
||||
else
|
||||
echo "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/$i not found, but that is OK" >&2
|
||||
fi
|
||||
done
|
||||
true
|
||||
}
|
||||
|
||||
# This will return 0 if an id is created and non-zero if
|
||||
# it already exists
|
||||
# https://www.debian.org/doc/debian-policy/ch-opersys.html#users-and-groups
|
||||
@@ -34,9 +85,9 @@ reload_systemd() {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
do_update_alternatives
|
||||
do_create_rdc_user
|
||||
create_rdc_service
|
||||
reload_systemd
|
||||
@@ -49,4 +100,3 @@ case "$1" in
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
do_update_alternatives(){
|
||||
# skip update if program doesn't exist
|
||||
command -v update-alternatives >/dev/null || return 0
|
||||
binaries=(
|
||||
rdcd
|
||||
)
|
||||
|
||||
for i in "$binaries"
|
||||
do
|
||||
update-alternatives --remove $i @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/$i
|
||||
done
|
||||
}
|
||||
|
||||
stop_rdc() {
|
||||
#stop RDC service if systemd exists and service is running
|
||||
if [ -d /run/systemd/system ] && $( systemctl is-active --quiet rdc ); then
|
||||
@@ -34,6 +47,7 @@ case "$1" in
|
||||
rm_rdc_service
|
||||
reload_systemd
|
||||
rm_pyc
|
||||
do_update_alternatives
|
||||
;;
|
||||
purge)
|
||||
;;
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
#!/bin/bash
|
||||
do_update_alternatives(){
|
||||
# skip update if program doesn't exist
|
||||
command -v update-alternatives >/dev/null || return 0
|
||||
binaries=(
|
||||
rdcd
|
||||
)
|
||||
|
||||
for i in "$binaries"
|
||||
do
|
||||
update-alternatives --remove $i @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/$i
|
||||
done
|
||||
}
|
||||
|
||||
stop_rdc() {
|
||||
#stop RDC service if systemd exists and service is running
|
||||
@@ -28,4 +40,5 @@ if [ $1 -le 1 ]; then
|
||||
stop_rdc
|
||||
rm_rdc_service
|
||||
reload_systemd
|
||||
do_update_alternatives
|
||||
fi
|
||||
|
||||
@@ -1,5 +1,55 @@
|
||||
#!/bin/bash
|
||||
|
||||
do_update_alternatives(){
|
||||
# skip update if program doesn't exist
|
||||
command -v update-alternatives >/dev/null || return 0
|
||||
local binaries altscore now
|
||||
now=$(date -u +%s) # Number of seconds since 1 Jan 1970
|
||||
|
||||
# The reason for this approach rather than using the build number
|
||||
# is to allow for jobs from different builds. In one build job the
|
||||
# job number might be at 1200, whilst in a release job the number
|
||||
# may be only 1. This approach assums that if you install a build
|
||||
# with a different semantic version then the highest is the
|
||||
# desired one, but if you install two with the same semver then
|
||||
# the newest is the desired version.
|
||||
|
||||
# Build up a score. It needs to fit in 32 bits
|
||||
altscore=$((@VERSION_MAJOR@ - 3))
|
||||
altscore=$((altscore * 14 + @VERSION_MINOR@)) # Allow up to 14 minor
|
||||
altscore=$((altscore * 14 + @VERSION_PATCH@)) # Allow up to 14 patch
|
||||
|
||||
# So far if the version is less than 9 we have a number (altscore)
|
||||
# that is less than 1175. 2**31/1175 is about 1.8 million. So
|
||||
# multiply altscore by 1,000,000 and add in a factor of how many
|
||||
# minutes have passed from an arbitary point in time (1,600,000,000
|
||||
# seconds after 1 Jan 1970 or Sep 13 12:26:40 2020) on the
|
||||
# basis that no one is going to be installing a new version more
|
||||
# often than every minute. This does get things wrong if a million
|
||||
# minutes pass and you are downgrading, but the chances of someone
|
||||
# waiting almost 2 years between installing a version and the
|
||||
# previous patch level is small.
|
||||
|
||||
altscore=$((altscore*1000000+(now-1600000000)/60))
|
||||
binaries=(
|
||||
rdcd
|
||||
)
|
||||
|
||||
for i in $binaries
|
||||
do
|
||||
# No obvious recover strategy if things fail
|
||||
# No manual or other slave pages to install
|
||||
if [ -e @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/"$i" ]
|
||||
then
|
||||
update-alternatives --install /usr/bin/"$i" "$i" \
|
||||
@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/"$i" "$altscore"
|
||||
else
|
||||
echo "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/$i not found, but that is OK" >&2
|
||||
fi
|
||||
done
|
||||
true
|
||||
}
|
||||
|
||||
# https://fedoraproject.org/wiki/Packaging%3aUsersAndGroups
|
||||
do_create_rdc_user() {
|
||||
useradd -r -s /sbin/nologin rdc
|
||||
@@ -26,6 +76,8 @@ reload_systemd() {
|
||||
return 0
|
||||
}
|
||||
|
||||
do_update_alternatives
|
||||
|
||||
do_create_rdc_user
|
||||
|
||||
#Symlink RDC Service
|
||||
|
||||
새 이슈에서 참조
사용자 차단