OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU.
公告
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.
1732 討論

recent update to intel-oneapi-runtime-opencl has broken apt on my linux system

crobar
新手
5,735 檢視

I recently installed an update for the above package via apt. I get the following error:

Preparing to unpack .../intel-oneapi-runtime-opencl_2025.1.0-973_amd64.deb ...
dpkg: warning: old intel-oneapi-runtime-opencl package pre-removal script subprocess returned error exit status 2
dpkg: trying script from the new package instead ...
dpkg: error processing archive /var/cache/apt/archives/intel-oneapi-runtime-opencl_2025.1.0-973_amd64.deb (--unpack):
new intel-oneapi-runtime-opencl package pre-removal script subprocess returned error exit status 2
openCL has already registered, skipping update-alternatives ...
update-alternatives: warning: forcing reinstallation of alternative /opt/intel/oneapi/redist because link group opencl-intel-runtime is broken
Errors were encountered while processing:
/var/cache/apt/archives/intel-oneapi-runtime-opencl_2025.1.0-973_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

it seem maybe the package fails to unpack

Now apt is broken and I can't update anything n the system.

My system is running Mint Linux 21.1 (which is based on Ubuntu 22.04)


How do I fix this?



0 積分
1 解決方案
crobar
新手
5,704 檢視

For anyone else struggling with this, replace the script mentioned in the previous post with something like the following and you will be able to fix your installation. I also comment out the dangerous "rmdir /etc" to avoid that possibility.

#!/bin/bash

# Copyright Intel Corporation.
#
# This software and the related documents are Intel copyrighted materials,
# and your use of them is governed by the express license under which they
# were provided to you ("License"). Unless the License provides otherwise,
# you may not use, modify, copy, publish, distribute, disclose or transmit
# this software or the related documents without Intel's prior written
# permission.
#
# This software and the related documents are provided as is, with no express
# or implied warranties, other than those that are expressly stated in the
# License.

INSTALL_DIR=/opt/intel/oneapi/redist

#
#   If post-install script failed to install alternative, uninstalling package also fails, because
#   'update-alternatives' cannot remove non-existing alternative. Let us check the alternative
#   exists before removing it.
#
#remove_alternative() {
#    update-alternatives --display "$1" &>/dev/null
#    if [ $? = 0 ]; then
#        update-alternatives --remove "$1" "$2"
#    else
#        echo "Alternative for $1 is not found, skipping ..."
#    fi
#}

remove_alternative() {
    if update-alternatives --display "$1" &>/dev/null; then
        update-alternatives --remove "$1" "$2"
    else
        echo "Alternative for $1 is not found, skipping ..."
    fi
}

set -e

LIB_OPENCL_SO=`find "${INSTALL_DIR}" -name "libOpenCL.so"`

if [ "${LIB_OPENCL_SO}" ]; then
    remove_alternative opencl-libOpenCL.so  "${LIB_OPENCL_SO}"
fi

LIB_INSTALL_DIR="${INSTALL_DIR}"
remove_alternative opencl-intel-runtime "${LIB_INSTALL_DIR}"

if [ -e "/etc/OpenCL/vendors" ] ; then
    rmdir --ignore-fail-on-non-empty "/etc/OpenCL/vendors" 2>/dev/null
    rmdir --ignore-fail-on-non-empty "/etc/OpenCL" 2>/dev/null
    if [ -z "$(ls -A /etc)" ] ; then
#        rmdir "/etc" 2>/dev/null
    fi
fi

exit 0

 

 

在原始文章中檢視解決方案

9 回應
crobar
新手
5,718 檢視

The root cause of the problem is the pre-removal script which contains a silly error, and some crazy stuff which I hope is removed in the new version.

I mean this script


/var/lib/dpkg/info/intel-oneapi-runtime-opencl.prerm

 

the script fails because it sets set -e in the body, but also contains the following function at the top

remove_alternative() {
    update-alternatives --display "$1" &>/dev/null
    if [ $? = 0 ]; then
        update-alternatives --remove "$1" "$2"
    else
        echo "Alternative for $1 is not found, skipping ..."
    fi
}

 

when the following command in this function returns a non-zero exit code the script exits and returns that exit code:

 

update-alternatives --display "$1" &>/dev/null

​

 

Now, as for the crazy stuff, there's also the following snippet:

 

if [ -e "/etc/OpenCL/vendors" ] ; then
    rmdir --ignore-fail-on-non-empty "/etc/OpenCL/vendors" 2>/dev/null
    rmdir --ignore-fail-on-non-empty "/etc/OpenCL" 2>/dev/null
    if [ -z "$(ls -A /etc)" ] ; then
        rmdir "/etc" 2>/dev/null
    fi
fi

 

So there's some possibility this script will decide to just go delete /etc !!!!  WTF?

crobar
新手
5,705 檢視

For anyone else struggling with this, replace the script mentioned in the previous post with something like the following and you will be able to fix your installation. I also comment out the dangerous "rmdir /etc" to avoid that possibility.

#!/bin/bash

# Copyright Intel Corporation.
#
# This software and the related documents are Intel copyrighted materials,
# and your use of them is governed by the express license under which they
# were provided to you ("License"). Unless the License provides otherwise,
# you may not use, modify, copy, publish, distribute, disclose or transmit
# this software or the related documents without Intel's prior written
# permission.
#
# This software and the related documents are provided as is, with no express
# or implied warranties, other than those that are expressly stated in the
# License.

INSTALL_DIR=/opt/intel/oneapi/redist

#
#   If post-install script failed to install alternative, uninstalling package also fails, because
#   'update-alternatives' cannot remove non-existing alternative. Let us check the alternative
#   exists before removing it.
#
#remove_alternative() {
#    update-alternatives --display "$1" &>/dev/null
#    if [ $? = 0 ]; then
#        update-alternatives --remove "$1" "$2"
#    else
#        echo "Alternative for $1 is not found, skipping ..."
#    fi
#}

remove_alternative() {
    if update-alternatives --display "$1" &>/dev/null; then
        update-alternatives --remove "$1" "$2"
    else
        echo "Alternative for $1 is not found, skipping ..."
    fi
}

set -e

LIB_OPENCL_SO=`find "${INSTALL_DIR}" -name "libOpenCL.so"`

if [ "${LIB_OPENCL_SO}" ]; then
    remove_alternative opencl-libOpenCL.so  "${LIB_OPENCL_SO}"
fi

LIB_INSTALL_DIR="${INSTALL_DIR}"
remove_alternative opencl-intel-runtime "${LIB_INSTALL_DIR}"

if [ -e "/etc/OpenCL/vendors" ] ; then
    rmdir --ignore-fail-on-non-empty "/etc/OpenCL/vendors" 2>/dev/null
    rmdir --ignore-fail-on-non-empty "/etc/OpenCL" 2>/dev/null
    if [ -z "$(ls -A /etc)" ] ; then
#        rmdir "/etc" 2>/dev/null
    fi
fi

exit 0

 

 

captainabernathy
初學者
5,387 檢視

consider changing....

if [ -e "/etc/OpenCL/vendors" ] ; then
    rmdir --ignore-fail-on-non-empty "/etc/OpenCL/vendors" 2>/dev/null
    rmdir --ignore-fail-on-non-empty "/etc/OpenCL" 2>/dev/null
    if [ -z "$(ls -A /etc)" ] ; then
#        rmdir "/etc" 2>/dev/null
    fi
fi

to...

if [ -e "/etc/OpenCL/vendors" ] ; then
    rmdir --ignore-fail-on-non-empty "/etc/OpenCL/vendors" 2>/dev/null
    rmdir --ignore-fail-on-non-empty "/etc/OpenCL" 2>/dev/null
#    if [ -z "$(ls -A /etc)" ] ; then
#        rmdir "/etc" 2>/dev/null
#    fi
fi

just bc some shell's might get cranky

crobar
新手
5,265 檢視

Thanks, here's the full updated script for my own reference and others:

 

#!/bin/bash

# Copyright Intel Corporation.
#
# This software and the related documents are Intel copyrighted materials,
# and your use of them is governed by the express license under which they
# were provided to you ("License"). Unless the License provides otherwise,
# you may not use, modify, copy, publish, distribute, disclose or transmit
# this software or the related documents without Intel's prior written
# permission.
#
# This software and the related documents are provided as is, with no express
# or implied warranties, other than those that are expressly stated in the
# License.

INSTALL_DIR=/opt/intel/oneapi/redist

#
#   If post-install script failed to install alternative, uninstalling package also fails, because
#   'update-alternatives' cannot remove non-existing alternative. Let us check the alternative
#   exists before removing it.
#
#remove_alternative() {
#    update-alternatives --display "$1" &>/dev/null
#    if [ $? = 0 ]; then
#        update-alternatives --remove "$1" "$2"
#    else
#        echo "Alternative for $1 is not found, skipping ..."
#    fi
#}

remove_alternative() {
    if update-alternatives --display "$1" &>/dev/null; then
        update-alternatives --remove "$1" "$2"
    else
        echo "Alternative for $1 is not found, skipping ..."
    fi
}

set -e

LIB_OPENCL_SO=`find "${INSTALL_DIR}" -name "libOpenCL.so"`

if [ "${LIB_OPENCL_SO}" ]; then
    remove_alternative opencl-libOpenCL.so  "${LIB_OPENCL_SO}"
fi

LIB_INSTALL_DIR="${INSTALL_DIR}"
remove_alternative opencl-intel-runtime "${LIB_INSTALL_DIR}"

if [ -e "/etc/OpenCL/vendors" ] ; then
    rmdir --ignore-fail-on-non-empty "/etc/OpenCL/vendors" 2>/dev/null
    rmdir --ignore-fail-on-non-empty "/etc/OpenCL" 2>/dev/null
#    if [ -z "$(ls -A /etc)" ] ; then
#        rmdir "/etc" 2>/dev/null
#    fi
fi

exit 0
Deeksha_S_Intel
5,633 檢視

Hi Richard, we hope you are doing great!

 

Could you kindly confirm whether your issue has been resolved, or if you require further assistance from Intel®? This will enable us to investigate further or direct your request to the higher team for additional assistance.

 

Have a great day ahead!


crobar
新手
5,613 檢視

The immediate problem is solved for me personally, but the general issue should be escalated to the development team for investigation.

Deeksha_S_Intel
5,605 檢視

Hi Richard, thank you for your response.

 

We would like to inform you that we are routing your query to the dedicated team for further assistance.


cw_intel
主席
5,452 檢視

Thanks for your investigation. We have reported the issue to the related team and will let you know when we have any updates.


crobar
新手
5,265 檢視

New update has been pushed out, and the issue is still present, and broken my package manager again.

回覆