Skip to content
forked from BOINC/boinc

Commit

Permalink
[linux] fix install scripts to handle upgrade cases.
Browse files Browse the repository at this point in the history
This fixes BOINC#5564.

Signed-off-by: Vitalii Koshura <lestat.de.lionkur@gmail.com>
  • Loading branch information
AenBleidd committed May 21, 2024
1 parent 308bac6 commit c58cc73
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 22 deletions.
79 changes: 71 additions & 8 deletions .github/workflows/linux-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ jobs:
if [ ! -d /etc/boinc-client ] ; then
mkdir -p /etc/boinc-client
fi
if [ ! -f ${BOINCDIR}/cc_config.xml ] ; then
if [ ! -e ${BOINCDIR}/cc_config.xml ] ; then
echo \"\"\"
<!--
This is a configuration file of the BOINC client.
Expand All @@ -432,9 +432,11 @@ jobs:
<cc_config>
</cc_config>
\"\"\" > ${BOINCDIR}/cc_config.xml
fi
if [ ! -e /etc/boinc-client/cc_config.xml ] ; then
ln -s ${BOINCDIR}/cc_config.xml /etc/boinc-client/cc_config.xml
fi
if [ ! -f ${BOINCDIR}/global_prefs_override.xml ] ; then
if [ ! -e ${BOINCDIR}/global_prefs_override.xml ] ; then
echo \"\"\"
<!--
This is a configuration file of the BOINC client that can be used to override global preferences
Expand All @@ -444,30 +446,37 @@ jobs:
<global_preferences>
</global_preferences>
\"\"\" > ${BOINCDIR}/global_prefs_override.xml
fi
if [ ! -e /etc/boinc-client/global_prefs_override.xml ] ;
then
ln -s ${BOINCDIR}/global_prefs_override.xml /etc/boinc-client/global_prefs_override.xml
fi
if [ ! -f ${BOINCDIR}/gui_rpc_auth.cfg ] ; then
if [ ! -e ${BOINCDIR}/gui_rpc_auth.cfg ] ; then
echo \"\" > ${BOINCDIR}/gui_rpc_auth.cfg
fi
if [ ! -e /etc/boinc-client/gui_rpc_auth.cfg ] ; then
ln -s ${BOINCDIR}/gui_rpc_auth.cfg /etc/boinc-client/gui_rpc_auth.cfg
fi
if [ ! -f ${BOINCDIR}/remote_hosts.cfg ] ; then
if [ ! -e ${BOINCDIR}/remote_hosts.cfg ] ; then
echo \"\"\"
# This file contains a list of remote host names or IP addresses (one per line)
# that are allowed to connect to the BOINC client via the GUI RPC interface.
# Only the hosts listed in this file will be allowed to connect.
# Lines starting with '#' and ';' are comments and are ignored.
\"\"\" > ${BOINCDIR}/remote_hosts.cfg
fi
if [ ! -e /etc/boinc-client/remote_hosts.cfg ] ; then
ln -s ${BOINCDIR}/remote_hosts.cfg /etc/boinc-client/remote_hosts.cfg
fi
if [ ! -e ${BOINCDIR}/ca-bundle.crt ] ; then
ln -s ${CA_BUNDLE} ${BOINCDIR}/ca-bundle.crt
fi
set_perm_recursive ${BOINCDIR} ${BOINCUSER} ${BOINCGROUP} u+rw,g+rw,o+r-w
set_perm ${BOINCDIR} ${BOINCUSER} ${BOINCGROUP} 0775
if [ -f ${BOINCDIR}/gui_rpc_auth.cfg ] ; then
if [ -e ${BOINCDIR}/gui_rpc_auth.cfg ] ; then
set_perm ${BOINCDIR}/gui_rpc_auth.cfg ${BOINCUSER} ${BOINCGROUP} 0660
fi
if [ -f ${BOINC_DIR}/remote_hosts.cfg ] ; then
if [ -e ${BOINC_DIR}/remote_hosts.cfg ] ; then
set_perm ${BOINCDIR}/remote_hosts.cfg ${BOINCUSER} ${BOINCGROUP} 0660
fi
if [ -d ${BOINCDIR}/projects ] ; then
Expand All @@ -478,6 +487,18 @@ jobs:
set_perm ${BOINCDIR}/slots ${BOINCUSER} ${BOINCGROUP} 0775
update_nested_dirs ${BOINCDIR}/slots u+x,g+x,o+x
fi
if [ -e /etc/boinc-client/cc_config.xml ] ; then
set_perm /etc/boinc-client/cc_config.xml ${BOINCUSER} ${BOINCGROUP} 0660
fi
if [ -e /etc/boinc-client/global_prefs_override.xml ] ; then
set_perm /etc/boinc-client/global_prefs_override.xml ${BOINCUSER} ${BOINCGROUP} 0660
fi
if [ -e /etc/boinc-client/gui_rpc_auth.cfg ] ; then
set_perm /etc/boinc-client/gui_rpc_auth.cfg ${BOINCUSER} ${BOINCGROUP} 0660
fi
if [ -e /etc/boinc-client/remote_hosts.cfg ] ; then
set_perm /etc/boinc-client/remote_hosts.cfg ${BOINCUSER} ${BOINCGROUP} 0660
fi
if [ -x /bin/systemctl ] ; then
systemctl enable --now boinc-client.service
fi
Expand Down Expand Up @@ -586,6 +607,7 @@ jobs:
strategy:
matrix:
os: [buster, bullseye, bookworm]
type: [install, upgrade]
fail-fast: false
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
Expand All @@ -598,6 +620,16 @@ jobs:
apt update -qq
apt install -y python3
- name: Install distro package for further upgrade
if: success() && matrix.type == 'upgrade'
run: |
DEBIAN_FRONTEND=noninteractive apt install -y boinc-client boinc-manager
- name: Rename systemctl (not supported on CI)
if: success() && matrix.type == 'upgrade'
run: |
mv /bin/systemctl /bin/systemctl.bak
- name: Download client
if: success()
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e
Expand Down Expand Up @@ -631,6 +663,7 @@ jobs:
strategy:
matrix:
os: [focal, jammy, noble]
type: [install, upgrade, upgrade-from-ppa]
fail-fast: false
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
Expand All @@ -643,6 +676,24 @@ jobs:
apt update -qq
apt install -y python3
- name: Install distro package for further upgrade
if: success() && matrix.type == 'upgrade'
run: |
DEBIAN_FRONTEND=noninteractive apt install -y boinc-client boinc-manager
- name: Install distro package for further upgrade from the PPA
if: success() && matrix.type == 'upgrade-from-ppa'
run: |
DEBIAN_FRONTEND=noninteractive apt install -y software-properties-common
add-apt-repository -y ppa:costamagnagianfranco/boinc
apt update -qq
DEBIAN_FRONTEND=noninteractive apt install -y boinc-client boinc-manager
- name: Rename systemctl (not supported on CI)
if: success() && matrix.type == 'upgrade'
run: |
mv /bin/systemctl /bin/systemctl.bak
- name: Download client
if: success()
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e
Expand Down Expand Up @@ -676,6 +727,7 @@ jobs:
strategy:
matrix:
os: [37, 38, 39, 40]
type: [install, upgrade]
fail-fast: false
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
Expand All @@ -687,6 +739,11 @@ jobs:
run: |
dnf install -y python3
- name: Install distro package for further upgrade
if: success() && matrix.type == 'upgrade'
run: |
dnf install -y boinc-client boinc-manager
- name: Download client
if: success()
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e
Expand All @@ -702,8 +759,8 @@ jobs:
- name: Install client and manager
if: success()
run: |
yum localinstall -y $(find ./ -type f -name "boinc-client*.rpm" -printf "%p\n")
yum localinstall -y $(find ./ -type f -name "boinc-manager*.rpm" -printf "%p\n")
yum localinstall -y --allowerasing $(find ./ -type f -name "boinc-client*.rpm" -printf "%p\n")
yum localinstall -y --allowerasing $(find ./ -type f -name "boinc-manager*.rpm" -printf "%p\n")
- name: Run integration tests
if: success()
Expand All @@ -719,13 +776,19 @@ jobs:
strategy:
matrix:
os: [15.4, 15.5]
type: [install, upgrade]
fail-fast: false
steps:
- name: Install dependencies
if: success()
run: |
zypper install -y python3 tar gzip
- name: Install distro package for further upgrade
if: success() && matrix.type == 'upgrade'
run: |
zypper install -y boinc-client boinc-manager
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
with:
fetch-depth: 2
Expand Down
40 changes: 34 additions & 6 deletions packages/deb/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if [ ! -d /etc/boinc-client ] ; then
mkdir -p /etc/boinc-client
fi

if [ ! -f ${BOINCDIR}/cc_config.xml ] ; then
if [ ! -e ${BOINCDIR}/cc_config.xml ] ; then
echo """
<!--
This is a configuration file of the BOINC client.
Expand All @@ -95,10 +95,13 @@ if [ ! -f ${BOINCDIR}/cc_config.xml ] ; then
<cc_config>
</cc_config>
""" > ${BOINCDIR}/cc_config.xml
fi

if [ ! -e /etc/boinc-client/cc_config.xml ] ; then
ln -s ${BOINCDIR}/cc_config.xml /etc/boinc-client/cc_config.xml
fi

if [ ! -f ${BOINCDIR}/global_prefs_override.xml ] ; then
if [ ! -e ${BOINCDIR}/global_prefs_override.xml ] ; then
echo """
<!--
This is a configuration file of the BOINC client that can be used to override global preferences
Expand All @@ -108,21 +111,30 @@ if [ ! -f ${BOINCDIR}/global_prefs_override.xml ] ; then
<global_preferences>
</global_preferences>
""" > ${BOINCDIR}/global_prefs_override.xml
fi

if [ ! -e /etc/boinc-client/global_prefs_override.xml ] ; then
ln -s ${BOINCDIR}/global_prefs_override.xml /etc/boinc-client/global_prefs_override.xml
fi

if [ ! -f ${BOINCDIR}/gui_rpc_auth.cfg ] ; then
if [ ! -e ${BOINCDIR}/gui_rpc_auth.cfg ] ; then
echo "" > ${BOINCDIR}/gui_rpc_auth.cfg
fi

if [ ! -e /etc/boinc-client/gui_rpc_auth.cfg ] ; then
ln -s ${BOINCDIR}/gui_rpc_auth.cfg /etc/boinc-client/gui_rpc_auth.cfg
fi

if [ ! -f ${BOINCDIR}/remote_hosts.cfg ] ; then
if [ ! -e ${BOINCDIR}/remote_hosts.cfg ] ; then
echo """
# This file contains a list of remote host names or IP addresses (one per line)
# that are allowed to connect to the BOINC client via the GUI RPC interface.
# Only the hosts listed in this file will be allowed to connect.
# Lines starting with '#' and ';' are comments and are ignored.
""" > ${BOINCDIR}/remote_hosts.cfg
fi

if [ ! -e /etc/boinc-client/remote_hosts.cfg ] ; then
ln -s ${BOINCDIR}/remote_hosts.cfg /etc/boinc-client/remote_hosts.cfg
fi

Expand All @@ -133,11 +145,11 @@ fi
set_perm_recursive ${BOINCDIR} ${BOINCUSER} ${BOINCGROUP} u+rw,g+rw,o+r-w
set_perm ${BOINCDIR} ${BOINCUSER} ${BOINCGROUP} 0775

if [ -f ${BOINCDIR}/gui_rpc_auth.cfg ] ; then
if [ -e ${BOINCDIR}/gui_rpc_auth.cfg ] ; then
set_perm ${BOINCDIR}/gui_rpc_auth.cfg ${BOINCUSER} ${BOINCGROUP} 0660
fi

if [ -f ${BOINC_DIR}/remote_hosts.cfg ] ; then
if [ -e ${BOINC_DIR}/remote_hosts.cfg ] ; then
set_perm ${BOINCDIR}/remote_hosts.cfg ${BOINCUSER} ${BOINCGROUP} 0660
fi

Expand All @@ -151,6 +163,22 @@ if [ -d ${BOINCDIR}/slots ] ; then
update_nested_dirs ${BOINCDIR}/slots u+x,g+x,o+x
fi

if [ -e /etc/boinc-client/cc_config.xml ] ; then
set_perm /etc/boinc-client/cc_config.xml ${BOINCUSER} ${BOINCGROUP} 0660
fi

if [ -e /etc/boinc-client/global_prefs_override.xml ] ; then
set_perm /etc/boinc-client/global_prefs_override.xml ${BOINCUSER} ${BOINCGROUP} 0660
fi

if [ -e /etc/boinc-client/gui_rpc_auth.cfg ] ; then
set_perm /etc/boinc-client/gui_rpc_auth.cfg ${BOINCUSER} ${BOINCGROUP} 0660
fi

if [ -e /etc/boinc-client/remote_hosts.cfg ] ; then
set_perm /etc/boinc-client/remote_hosts.cfg ${BOINCUSER} ${BOINCGROUP} 0660
fi

if [ -x /bin/systemctl ] ; then
systemctl enable --now boinc-client.service
fi
39 changes: 31 additions & 8 deletions tests/linux_package_tests/integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,37 @@ def test_files_exist(self):
ts.expect_true(os.path.exists("/usr/local/share/icons/boinc.png"), "Test 'boinc.png' file exists in '/usr/local/share/icons/'")
ts.expect_true(os.path.exists("/usr/local/share/icons/boinc.svg"), "Test 'boinc.svg' file exists in '/usr/local/share/icons/'")
ts.expect_true(os.path.exists("/var/lib/boinc/cc_config.xml"), "Test 'cc_config.xml' file exists in '/var/lib/boinc/'")
ts.expect_true(os.path.islink("/etc/boinc-client/cc_config.xml"), "Test '/etc/boinc-client/cc_config.xml' file is a symbolic link")
ts.expect_equal("/var/lib/boinc/cc_config.xml", os.readlink("/etc/boinc-client/cc_config.xml"), "Test '/etc/boinc-client/cc_config.xml' file is a symbolic link to '/var/lib/boinc/cc_config.xml'")
ts.expect_true(os.path.exists("/etc/boinc-client/cc_config.xml"), "Test 'cc_config.xml' file exists in '/etc/boinc-client/'")
if (os.path.islink("/etc/boinc-client/cc_config.xml")):
ts.expect_equal("/var/lib/boinc/cc_config.xml", os.readlink("/etc/boinc-client/cc_config.xml"), "Test '/etc/boinc-client/cc_config.xml' file is a symbolic link to '/var/lib/boinc/cc_config.xml'")
elif(os.path.islink("/var/lib/boinc/cc_config.xml")):
ts.expect_equal("/etc/boinc-client/cc_config.xml", os.readlink("/var/lib/boinc/cc_config.xml"), "Test '/var/lib/boinc/cc_config.xml' file is a symbolic link to '/etc/boinc-client/cc_config.xml'")
else:
ts.expect_true(False, "Test 'cc_config.xml' file is a symbolic link")
ts.expect_true(os.path.exists("/var/lib/boinc/global_prefs_override.xml"), "Test 'global_prefs_override.xml' file exists in '/var/lib/boinc/'")
ts.expect_true(os.path.islink("/etc/boinc-client/global_prefs_override.xml"), "Test '/etc/boinc-client/global_prefs_override.xml' file is a symbolic link")
ts.expect_equal("/var/lib/boinc/global_prefs_override.xml", os.readlink("/etc/boinc-client/global_prefs_override.xml"), "Test '/etc/boinc-client/global_prefs_override.xml' file is a symbolic link to '/var/lib/boinc/global_prefs_override.xml'")
ts.expect_true(os.path.exists("/etc/boinc-client/global_prefs_override.xml"), "Test 'global_prefs_override.xml' file exists in '/etc/boinc-client/'")
if (os.path.islink("/etc/boinc-client/global_prefs_override.xml")):
ts.expect_equal("/var/lib/boinc/global_prefs_override.xml", os.readlink("/etc/boinc-client/global_prefs_override.xml"), "Test '/etc/boinc-client/global_prefs_override.xml' file is a symbolic link to '/var/lib/boinc/global_prefs_override.xml'")
elif(os.path.islink("/var/lib/boinc/global_prefs_override.xml")):
ts.expect_equal("/etc/boinc-client/global_prefs_override.xml", os.readlink("/var/lib/boinc/global_prefs_override.xml"), "Test '/var/lib/boinc/global_prefs_override.xml' file is a symbolic link to '/etc/boinc-client/global_prefs_override.xml'")
else:
ts.expect_true(False, "Test 'global_prefs_override.xml' file is a symbolic link")
ts.expect_true(os.path.exists("/var/lib/boinc/remote_hosts.cfg"), "Test 'remote_hosts.cfg' file exists in '/var/lib/boinc/'")
ts.expect_true(os.path.islink("/etc/boinc-client/remote_hosts.cfg"), "Test '/etc/boinc-client/remote_hosts.cfg' file is a symbolic link")
ts.expect_equal("/var/lib/boinc/remote_hosts.cfg", os.readlink("/etc/boinc-client/remote_hosts.cfg"), "Test '/etc/boinc-client/remote_hosts.cfg' file is a symbolic link to '/var/lib/boinc/remote_hosts.cfg'")
ts.expect_true(os.path.exists("/etc/boinc-client/remote_hosts.cfg"), "Test 'remote_hosts.cfg' file exists in '/etc/boinc-client/'")
if (os.path.islink("/etc/boinc-client/remote_hosts.cfg")):
ts.expect_equal("/var/lib/boinc/remote_hosts.cfg", os.readlink("/etc/boinc-client/remote_hosts.cfg"), "Test '/etc/boinc-client/remote_hosts.cfg' file is a symbolic link to '/var/lib/boinc/remote_hosts.cfg'")
elif(os.path.islink("/var/lib/boinc/remote_hosts.cfg")):
ts.expect_equal("/etc/boinc-client/remote_hosts.cfg", os.readlink("/var/lib/boinc/remote_hosts.cfg"), "Test '/var/lib/boinc/remote_hosts.cfg' file is a symbolic link to '/etc/boinc-client/remote_hosts.cfg'")
else:
ts.expect_true(False, "Test 'remote_hosts.cfg' file is a symbolic link")
ts.expect_true(os.path.exists("/var/lib/boinc/gui_rpc_auth.cfg"), "Test 'gui_rpc_auth.cfg' file exists in '/var/lib/boinc/'")
ts.expect_true(os.path.islink("/etc/boinc-client/gui_rpc_auth.cfg"), "Test '/etc/boinc-client/gui_rpc_auth.cfg' file is a symbolic link")
ts.expect_equal("/var/lib/boinc/gui_rpc_auth.cfg", os.readlink("/etc/boinc-client/gui_rpc_auth.cfg"), "Test '/etc/boinc-client/gui_rpc_auth.cfg' file is a symbolic link to '/var/lib/boinc/gui_rpc_auth.cfg'")
ts.expect_true(os.path.exists("/etc/boinc-client/gui_rpc_auth.cfg"), "Test 'gui_rpc_auth.cfg' file exists in '/etc/boinc-client/'")
if (os.path.islink("/etc/boinc-client/gui_rpc_auth.cfg")):
ts.expect_equal("/var/lib/boinc/gui_rpc_auth.cfg", os.readlink("/etc/boinc-client/gui_rpc_auth.cfg"), "Test '/etc/boinc-client/gui_rpc_auth.cfg' file is a symbolic link to '/var/lib/boinc/gui_rpc_auth.cfg'")
elif(os.path.islink("/var/lib/boinc/gui_rpc_auth.cfg")):
ts.expect_equal("/etc/boinc-client/gui_rpc_auth.cfg", os.readlink("/var/lib/boinc/gui_rpc_auth.cfg"), "Test '/var/lib/boinc/gui_rpc_auth.cfg' file is a symbolic link to '/etc/boinc-client/gui_rpc_auth.cfg'")
else:
ts.expect_true(False, "Test 'gui_rpc_auth.cfg' file is a symbolic link")
ts.expect_not_equal("", self._get_ca_certificates_file_path(), "Test system 'ca-certificates.crt' file exists")
ts.expect_true(os.path.exists("/var/lib/boinc/ca-bundle.crt"), "Test 'ca-bundle.crt' file exists in '/var/lib/boinc/'")
ts.expect_true(os.path.islink("/var/lib/boinc/ca-bundle.crt"), "Test '/var/lib/boinc/ca-bundle.crt' file is a symbolic link")
Expand Down Expand Up @@ -152,6 +172,9 @@ def test_selected_values_from_boinc_client_service_file(self):

def test_files_permissions(self):
ts = testset.TestSet("Test files permissions")
ts.expect_equal("boinc:boinc", self._get_file_owner("/etc/boinc-client/cc_config.xml"), "Test '/etc/boinc-client/cc_config.xml' file owner")
ts.expect_equal("boinc:boinc", self._get_file_owner("/etc/boinc-client/global_prefs_override.xml"), "Test '/etc/boinc-client/global_prefs_override.xml' file owner")
ts.expect_equal("boinc:boinc", self._get_file_owner("/etc/boinc-client/remote_hosts.cfg"), "Test '/etc/boinc-client/remote_hosts.cfg' file owner")
ts.expect_equal("boinc:boinc", self._get_file_owner("/var/lib/boinc/cc_config.xml"), "Test '/var/lib/boinc/cc_config.xml' file owner")
ts.expect_equal("boinc:boinc", self._get_file_owner("/var/lib/boinc/global_prefs_override.xml"), "Test '/var/lib/boinc/global_prefs_override.xml' file owner")
ts.expect_equal("boinc:boinc", self._get_file_owner("/var/lib/boinc/remote_hosts.cfg"), "Test '/var/lib/boinc/remote_hosts.cfg' file owner")
Expand Down

0 comments on commit c58cc73

Please sign in to comment.