OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU.
Announcements
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.
1729 Discussions

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

crobar
Novice
761 Views

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 Kudos
1 Solution
crobar
Novice
730 Views

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

 

 

View solution in original post

0 Kudos
9 Replies
crobar
Novice
744 Views

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?

0 Kudos
crobar
Novice
731 Views

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

 

 

0 Kudos
captainabernathy
Beginner
413 Views

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

0 Kudos
crobar
Novice
291 Views

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
0 Kudos
Deeksha_S_Intel
Moderator
659 Views

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!


0 Kudos
crobar
Novice
639 Views

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

0 Kudos
Deeksha_S_Intel
Moderator
631 Views

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.


0 Kudos
cw_intel
Moderator
478 Views

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


0 Kudos
crobar
Novice
291 Views

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

0 Kudos
Reply