Created
July 30, 2022 08:03
-
-
Save AndrDm/c1fcd72fafdb27fc7d7bc24f4b3c0704 to your computer and use it in GitHub Desktop.
LabVIEW 2022 install script modified for Pop!_OS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ ! "$BASH_VERSION" ]; then | |
echo "Please do not use sh to run this script ${0}, just execute it directly" 1>&2 | |
exit 1 | |
fi | |
# | |
# LabVIEW 2022 installation script. | |
# Copyright (c) 2022 National Instruments Corporation | |
# Pop!_OS added by Andrey | |
# If ni-wine, which requires libldap-2.4-2 then execute sudo apt-get install libldap2-dev | |
# | |
# Install Script Constants | |
FEED_DIST=bionic | |
FEED_NAME=ni-labview-2022 | |
LV_MAJOR_VER=22 | |
LV_MINOR_VER=3 | |
LV_UPDATE_VER=0 | |
LV_MAJ_DOT_MIN=22.0 | |
LV_VERS=22.3.0 | |
LV_YEAR=2022 | |
PUB_KEY=ni-linux-desktop-2019.pub | |
BETA= | |
QTR_NUM=" Q3" | |
R_NUM="" | |
DASH_R_NUM="" | |
R_NUM_NOSP="" | |
DASH64=-64 | |
NUM64=64 | |
declare -l R_NUM_LOWER="$R_NUM_NOSP" | |
LV_YEAR_RNUM=${LV_YEAR}${R_NUM_LOWER} | |
PRO_PKG=ni-labview-2022-pro | |
PRO_VERS=22.3.0.49364-0+f212 | |
FULL_PKG=ni-labview-2022-full | |
FULL_VERS=22.3.0.49363-0+f211 | |
COMMUNITY_PKG=ni-labview-2022-community | |
COMMUNITY_VERS=22.3.0.49364-0+f212 | |
VIA_PKG= | |
VIA_VERS= | |
RTE_PKG=__RTE_PKG__ | |
RTE_VERS=__RTE_VER__ | |
LV_FLAVOR=community | |
LV_REPO_REG_FILE_BASENAME=LV${LV_YEAR}_${LV_FLAVOR}_Offline | |
LV_REPO_ID=${LV_REPO_REG_FILE_BASENAME} | |
APT_PUB_KEY_DIR=/user/share/keyrings | |
APT_PUB_KEY_NAME=${LV_REPO_REG_FILE_BASENAME}.asc | |
APT_PUB_KEY_TARGET=${APT_PUB_KEY_DIR}/${APT_PUB_KEY_NAME} | |
PKI_PUB_KEY_DIR=/etc/pki/rpm-gpg | |
PKI_PUB_KEY_NAME=RPM-GPG-KEY-${LV_REPO_REG_FILE_BASENAME} | |
PKI_PUB_KEY_TARGET=${PKI_PUB_KEY_DIR}/${PKI_PUB_KEY_NAME} | |
get_current_directory() { | |
cd_path="$(dirname $0)" | |
case "$(dirname $0)" in | |
/*) ;; | |
.) cd_path="`pwd`" ;; | |
*) cd_path="`pwd`/$cd_path" ;; | |
esac | |
} | |
get_current_directory | |
source "${cd_path}/utils/install_helpers.sh" | |
INSTALL_SCRIPT_INSTALLABLE=0 | |
rpm_installability_check() { | |
rpm_version=$(rpm -q --queryformat "\%{VERSION}-\%{RELEASE}" "$1" 2>/dev/null) | |
if [ $? -ne ${INSTALL_SCRIPT_ERROR_SUCCESS} ]; then | |
return ${INSTALL_SCRIPT_INSTALLABLE} | |
else | |
ver_cmp "$rpm_version" "$2" | |
retval=$? | |
if [ ${retval} -ne 0 -a ${retval} -ne 1 ]; then | |
return ${INSTALL_SCRIPT_INSTALLABLE} | |
else | |
return ${INSTALL_SCRIPT_ERROR_PKG_INSTALLED} | |
fi | |
fi | |
} | |
dpkg_installability_check() { | |
deb_version=$(dpkg-query --show --showformat='${Version}' "$1" 2>/dev/null) | |
if [ $? -ne ${INSTALL_SCRIPT_ERROR_SUCCESS} ]; then | |
return ${INSTALL_SCRIPT_INSTALLABLE} | |
else | |
dpkg --compare-versions "${deb_version}" "<<" "$2" | |
if [ $? -ne 0 ]; then | |
return ${INSTALL_SCRIPT_ERROR_PKG_INSTALLED} | |
fi | |
fi | |
} | |
installability_check() { | |
case "${distro_id}" in | |
ubuntu|pop) dpkg_installability_check $1 $2;; | |
centos|rhel|opensuse-leap) rpm_installability_check $1 $2;; | |
*) error_handler ${INSTALL_SCRIPT_ERROR_INCOMPATIBLE};; | |
esac | |
} | |
pub_key_import() { | |
# Typically basepath will exist, however, there is a known issue in | |
# newer openSUSE versions that the gpg path is not created. | |
basepath="$(dirname $2)" | |
if [ ! -d "${basepath}" ]; then | |
mkdir -p ${basepath} | |
fi | |
cp -f "$1" "$2" | |
} | |
apt_register() { | |
pub_key_import "${cd_path}/${PUB_KEY}" "${APT_PUB_KEY_TARGET}" | |
cat << EOF > /etc/apt/sources.list.d/$1.list | |
deb [signed-by=${APT_PUB_KEY_TARGET}] file://$2/deb $3 $4 | |
EOF | |
apt update -o Dir::Etc::sourcelist=/etc/apt/sources.list.d/$1.list | |
} | |
apt_unregister() { | |
list_file=/etc/apt/sources.list.d/$1.list | |
if [ -f "${list_file}" ]; then | |
rm -f "${list_file}" | |
fi | |
} | |
yum_register() { | |
yum_id=$1 | |
pub_key_import "${cd_path}/${PUB_KEY}" "${PKI_PUB_KEY_TARGET}" | |
cat << EOF > /etc/yum.repos.d/$1.repo | |
[$1] | |
name=$1 | |
baseurl=file://$2/rpm | |
enabled=0 | |
gpgcheck=0 | |
repo_gpgcheck=1 | |
gpgkey=file://${PKI_PUB_KEY_TARGET} | |
EOF | |
} | |
yum_unregister() { | |
conf_file=/etc/yum.repos.d/$1.repo | |
if [ -f "${conf_file}" ]; then | |
rm -f "${conf_file}" | |
fi | |
} | |
zypper_register() { | |
zypper_uri="file://$2/rpm" | |
pub_key_import "${cd_path}/${PUB_KEY}" "${PKI_PUB_KEY_TARGET}" | |
rpm --import "${PKI_PUB_KEY_TARGET}" | |
cat << EOF > /etc/zypp/vendors.d/$1.conf | |
[main] | |
vendors = National Instruments Corporation,National Instruments <LinuxMaintainers@ni.com> | |
EOF | |
} | |
zypper_unregister() { | |
vendor_file=/etc/zypp/vendors.d/$1.conf | |
if [ -f "${vendor_file}" ]; then | |
rm -f "${vendor_file}" | |
fi | |
} | |
register_feed() { | |
echo "Registering $1 Feed" | |
reg_basename="${LV_REPO_REG_FILE_BASENAME}" | |
case "$1" in | |
ubuntu|pop) apt_register ${reg_basename} ${cd_path} ${FEED_DIST} ${FEED_NAME};; | |
centos|rhel) yum_register ${reg_basename} ${cd_path};; | |
opensuse-leap) zypper_register ${reg_basename} ${cd_path};; | |
*) error_handler ${INSTALL_SCRIPT_ERROR_INCOMPATIBLE};; | |
esac | |
} | |
unregister_feed() { | |
echo "Un-registering $1 Feed" | |
reg_basename="${LV_REPO_REG_FILE_BASENAME}" | |
case "$1" in | |
ubuntu|pop) | |
apt_unregister ${reg_basename} ${cd_path} ${FEED_DIST} ${FEED_NAME};; | |
centos|rhel) | |
yum_unregister ${reg_basename} ${cd_path};; | |
opensuse-leap) | |
zypper_unregister ${reg_basename} ${cd_path};; | |
*) error_handler ${INSTALL_SCRIPT_ERROR_INCOMPATIBLE};; | |
esac | |
} | |
prereq_check() { | |
if [ "`whoami`" != root ]; then | |
error_handler ${INSTALL_SCRIPT_ERROR_NOT_ROOT} | |
fi | |
get_bitness | |
if [ "${os_bitness}" -eq "32" ]; then | |
error_handler ${INSTALL_SCRIPT_ERROR_INCOMPATIBLE} | |
fi | |
get_distro | |
case "${distro_id}" in | |
ubuntu|pop) | |
util_check "apt" | |
util_check "dpkg-query" | |
util_check "dpkg" | |
;; | |
centos|rhel) | |
util_check "yum" | |
util_check "rpm" | |
;; | |
opensuse-leap) | |
util_check "zypper" | |
util_check "rpm" | |
;; | |
*) error_handler ${INSTALL_SCRIPT_ERROR_INCOMPATIBLE};; | |
esac | |
return ${INSTALL_SCRIPT_ERROR_SUCCESS} | |
} | |
feed_install() { | |
echo "Install $1 from Feed" | |
assumeyes="" | |
forceyes="" | |
if [ "$NO_PROMPT" = "y" ]; then | |
assumeyes="--assumeyes" | |
forceyes="--assume-yes" | |
notinteractive="-n" | |
fi | |
skip_string= | |
if [ "$2" = "y" ]; then | |
skip_string="-y" | |
fi | |
centos_reinstall="" | |
opensuse_reinstall="" | |
if [ -n "${RTE_ONLY}" -o "${LV_FLAVOR}" = "runtime-engine" ]; then | |
uninstalloldvicompare="" | |
else | |
uninstalloldvicompare="rpm -ev --nodeps nilvcompare" | |
fi | |
case "${distro_id}" in | |
ubuntu|pop) apt ${forceyes} install ${skip_string} $1;; | |
centos|rhel) ${uninstalloldvicompare} | |
yum ${skip_string} install --enablerepo ${yum_id} ${assumeyes} ${skip_string} --obsoletes $1 && ${centos_reinstall};; | |
opensuse-leap) ${uninstalloldvicompare} | |
zypper ${notinteractive} --plus-repo "${zypper_uri}" --gpg-auto-import-keys install --allow-unsigned-rpm ${skip_string} $1 && ${opensuse_reinstall};; | |
*) return 1;; | |
esac | |
} | |
reset_link() { | |
LVRTLINK=$LIBDIR/lib${NUM64}/liblvrt.so | |
DARKLINK=$LIBDIR/lib${NUM64}/liblvrtdark.so | |
RTELOADERLINK=$LIBDIR/lib${NUM64}/libNILVRuntimeManager.so | |
askresetlnk= | |
# If they've installed an older RTE more recently than this one, offer | |
# to recreate the 'current' link | |
echo "" | |
if [ ! -e $LIBDIR/lib${NUM64}/liblvrt.so.$LV_MAJ_DOT_MIN ]; then | |
: | |
elif [ ! -e $LVRTLINK ]; then | |
askresetlnk=y | |
echo "Run-time engine link $LVRTLINK does not exist." | |
echon "Create it? [Yn] " | |
elif [ -L $LVRTLINK ]; then | |
LTARG= | |
TMPLVRTLINK=$LVRTLINK | |
while [[ "$LTARG" != *LabVIEW-*/* ]]; do | |
LTARG=`ls -l $TMPLVRTLINK | sed 's,^.* -> ,,'` | |
TMPLVRTLINK="$LIBDIR/lib${NUM64}/$LTARG" | |
done | |
LTARGVERS=`echo $LTARG | sed 's,.*liblvrt\.so\.,,'` | |
if [ -n "$LTARGVERS" ]; then | |
vercmp $LV_VERS $LTARGVERS | |
cmp=$? | |
if [[ $cmp -eq 0 ]] ; then | |
RTELINKCURRENT=y | |
elif [[ $cmp -eq 1 ]] ; then | |
askresetlnk=y | |
echo "Run-time engine link $LVRTLINK exists but points to an older" | |
echo "version ($LTARGVERS). This link determines which version of the LabVIEW" | |
echo "run-time to use when building C/C++ applications. Do you want to recreate" | |
echon "the link to make $LV_YEAR$R_NUM$QTR_NUM the default run-time engine? [Yn] " | |
fi | |
fi | |
fi | |
if [ -n "$askresetlnk" ]; then | |
read ans | |
test -z "$ans" && ans=y | |
case "$ans" in | |
[yY]*) | |
rm -f $LVRTLINK $DARKLINK | |
echo "Recreating link to LabVIEW $LV_YEAR$R_NUM$QTR_NUM run-time engine." | |
echo "" | |
ln -s liblvrt.so.$LV_MAJ_DOT_MIN $LVRTLINK | |
test -f $LIBDIR/lib${NUM64}/liblvrtdark.so.$LV_MAJ_DOT_MIN && ln -s liblvrtdark.so.$LV_MAJ_DOT_MIN $DARKLINK | |
test -f $LIBDIR/lib${NUM64}/libNILVRuntimeManager.so.$LV_MAJ_DOT_MIN && ln -s libNILVRuntimeManager.so.$LV_MAJ_DOT_MIN $RTELOADERLINK | |
;; | |
esac | |
fi | |
} | |
get_package_list() | |
{ | |
if [ "${LV_FLAVOR}" = "pro" ]; then | |
installability_check ${PRO_PKG} ${PRO_VERS} | |
if [ $? -eq ${INSTALL_SCRIPT_INSTALLABLE} ]; then | |
pkg_list="${PRO_PKG}" | |
fi | |
installability_check ${VIA_PKG} ${VIA_VERS} | |
if [ $? -eq ${INSTALL_SCRIPT_INSTALLABLE} ]; then | |
pkg_list="${pkg_list} ${VIA_PKG}" | |
fi | |
fi | |
if [ "${LV_FLAVOR}" = "community" ]; then | |
installability_check ${COMMUNITY_PKG} ${COMMUNITY_VERS} | |
if [ $? -eq ${INSTALL_SCRIPT_INSTALLABLE} ]; then | |
pkg_list="${COMMUNITY_PKG}" | |
fi | |
fi | |
if [ -n "${FULL_ONLY}" -o "${LV_FLAVOR}" = "full" ]; then | |
installability_check ${FULL_PKG} ${FULL_VERS} | |
if [ $? -eq ${INSTALL_SCRIPT_INSTALLABLE} ]; then | |
pkg_list="${FULL_PKG}" | |
fi | |
fi | |
if [ -n "${RTE_ONLY}" -o "${LV_FLAVOR}" = "runtime-engine" ]; then | |
installability_check ${RTE_PKG} ${RTE_VERS} | |
if [ $? -eq ${INSTALL_SCRIPT_INSTALLABLE} ]; then | |
pkg_list="${RTE_PKG}" | |
fi | |
fi | |
if [ -z "${pkg_list}" ]; then | |
return ${INSTALL_SCRIPT_ERROR_GENERAL} | |
fi | |
return ${INSTALL_SCRIPT_ERROR_SUCCESS} | |
} | |
install() { | |
echo "Preparing for installation..." | |
register_feed "${distro_id}" | |
ans="" | |
asked="" | |
if [ -z "$NO_PROMPT" ]; then | |
echo "Please indicate whether you would like to install the following components:" | |
echo "" | |
fi | |
get_package_list | |
if [ $? -eq ${INSTALL_SCRIPT_ERROR_SUCCESS} ]; then | |
error_handler $? | |
fi | |
for pkg in $pkg_list | |
do | |
while : | |
do | |
asked=y | |
if [ -n "$installpkg" ]; then | |
summary $pkg | |
ans=y | |
elif [ -n "$NO_PROMPT" ]; then | |
ans=A | |
else | |
summary $pkg | |
echon "[Ynasq?] " | |
read ans | |
test -z "$ans" && ans=y | |
fi | |
case "$ans" in | |
[yY]*) | |
packages="$packages $pkg" | |
break ;; | |
[aA]*) | |
packages="$packages $pkg" | |
echo "Selecting all packages..." | |
if [ "$ans" = "A" ]; then | |
skipconfirm=y | |
fi | |
installpkg=y | |
break ;; | |
[hH?]*) | |
info $pkg | |
echo "" | |
echo "Enter 'y' to install this package, 'n' to skip, 'a' to install all LabVIEW" | |
echo "packages, 's' to skip all, or 'q' to abort installation entirely." | |
echo "" ;; | |
[qQ]*) | |
echo "Installation aborted." | |
exit 1 ;; | |
[sS]*) | |
echo "Skipping LabVIEW installation." | |
packages= | |
break 2 ;; | |
[fF]*) | |
echo "Proceeding." | |
skipconfirm=y | |
break 2 ;; | |
*) break ;; | |
esac | |
done | |
done | |
if [ -z "$asked" ]; then | |
echo "All available LabVIEW packages have already been installed or cannot" | |
echo "be installed due to package conflicts." | |
elif [ -z "$packages" ]; then | |
echo "No LabVIEW packages were selected." | |
else | |
echo "" | |
echo "" | |
if [ $? = ${INSTALL_SCRIPT_ERROR_SUCCESS} ]; then | |
echo "Installing..." | |
feed_install $packages $skip_confirm | |
lvstat=$? | |
fi | |
fi | |
unregister_feed "${distro_id}" | |
} | |
parse_options() { | |
echo "$@" | |
if [ -z $1 ]; then | |
return ${INSTALL_SCRIPT_ERROR_SUCCESS} | |
fi | |
for arg in "$@" | |
do | |
case "$arg" in | |
--accept-license|-al) | |
ACCEPT_LICENSE=y ;; | |
--no-prompt|-np) | |
NO_PROMPT=y ;; | |
--full-only) | |
FULL_ONLY=y ;; | |
*) echo "Unrecognized option $arg" | |
exit ${INSTALL_SCRIPT_ERROR_GENERAL};; | |
esac | |
done | |
if [ -n "$NO_PROMPT" -a -z "$ACCEPT_LICENSE" ]; then | |
echo ""; echo "*** ERROR ***" | |
echo "In order to use the --no-prompt option, you must also use the --accept-license" | |
echo "option to indicate you have read and accepted the terms of the " | |
echo "National Instruments Software License Agreement, found in LICENSE.txt." | |
exit ${INSTALL_SCRIPT_ERROR_GENERAL} | |
fi | |
} | |
main() { | |
get_current_directory | |
cd "$cd_path" | |
prereq_check | |
if [ -f COPYRIGHT ]; then | |
cat COPYRIGHT | |
else | |
echo "LabVIEW $LV_YEAR$R_NUM$QTR_NUM for ${distro_name}" | |
echo "" | |
fi | |
parse_options "$@" | |
instdir=$BASEDIR | |
LVDIR=$instdir/$DDIR | |
cd "$cd_path" | |
if [ -z "$ACCEPT_LICENSE" -a -f LICENSE.txt ]; then | |
ACCEPT_LICENSE= | |
licloop=y | |
while [ "$licloop" = y ]; do | |
echo "By installing LabVIEW software packages, you agree to the terms of the included" | |
echo "NI Software License Agreement \(LICENSE.txt\). Type 'v' to view the agreement," | |
echo "'y' to consent to the agreement, or 'n' to decline the agreement and skip" | |
echon "LabVIEW installation. " | |
if [ x"$licview" = x ]; then | |
echon "[Vynq] " | |
else | |
echon "[ynvq] " | |
fi | |
read ans | |
case "$ans" in | |
[yY]*) | |
ACCEPT_LICENSE=y | |
licloop=n | |
;; | |
[nN]*) | |
licloop=n | |
;; | |
[vV]*) | |
${PAGER:-more} LICENSE.txt | |
licview=y | |
;; | |
[qQ]*) | |
echo "Installation aborted." | |
exit 1 | |
;; | |
"") | |
if [ x"$licview" = x ]; then | |
${PAGER:-more} LICENSE.txt | |
licview=y | |
fi | |
;; | |
esac | |
echo "" | |
done | |
fi | |
if [ "$ACCEPT_LICENSE" = y ]; then | |
install | |
echo "" | |
fi | |
cd "$cd_path" | |
find_acrobat_reader | |
if [ -z "$ACROREAD" ]; then | |
echo "Note: This product contains online reference manuals in Adobe PDF format." | |
echo "The installer was not able to locate a PDF viewer on your system. To view these" | |
echo "documents, either install a viewer such as evince, epdfview, ggv, kpdf, or xpdf," | |
echo "or visit http://www.adobe.com to download Adobe Acrobat Reader." | |
echo "\(Adobe and Reader are registered trademarks of Adobe Systems Inc.\)" | |
fi | |
echo "" | |
echo "================================================================================" | |
echo "" | |
echo "To install the latest NI-VISA and NI-488.2, visit" | |
echo "http://www.ni.com/en-us/support/downloads/drivers/download.ni-linux-device-drivers.html" | |
echo "" | |
if [ -n "$LVDIR" -a -d "$LVDIR" ]; then | |
UPNOTES="$LVDIR/manuals/LV_Upgrade_Notes.pdf" | |
if [ -f "$LVDIR/help/betadoc.chm/betadoc.html" ]; then | |
echo "" | |
echo "Please see the LabVIEW Beta Documentation in $LVDIR/help/betadoc.chm/betadoc.html." | |
elif [ -f "$UPNOTES" ]; then | |
if [ -n "$DISPLAY" ]; then | |
echo "" | |
echon "View the LabVIEW $LV_YEAR$R_NUM$QTR_NUM Upgrade Notes now? [Yn] " | |
read ans | |
case "$ans" in | |
""|y|Y) | |
if [ -n "$ACROREAD" -a -x "$ACROREAD" ]; then | |
echo "Launching $ACROREAD..." | |
$ACROREAD "$UPNOTES" 2>/dev/null & | |
else | |
echo "Sorry, okular, evince, xpdf, ggv, kpdf, epdfview or Adobe Acrobat Reader must be installed to view PDF files." | |
fi | |
;; | |
esac | |
else | |
echo "" | |
echo "Please see the LabVIEW $LV_YEAR$R_NUM$QTR_NUM Upgrade Notes in $UPNOTES" | |
echo "for information about new features in LabVIEW $LV_YEAR$R_NUM$QTR_NUM." | |
fi | |
else | |
echo "" | |
echo "Please see the LabVIEW Upgrade Notes \(in the labview-$LV_YEAR_RNUM-ref package\) for" | |
echo "information about new features in LabVIEW $LV_YEAR$R_NUM$QTR_NUM." | |
fi | |
fi | |
echo "" | |
echo "Installation complete." | |
exit ${INSTALL_SCRIPT_ERROR_SUCCESS} | |
} | |
main "$@" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On POP!_OS 22.04 sudo apt-get install libldap2-dev didn't work.
I had two use an older one:
sudo wget http://http.us.debian.org/debian/pool/main/o/openldap/libldap-2.4-2_2.4.47+dfsg-3+deb10u7_amd64.deb
sudo apt install ./libldap-2.4-2_2.4.47+dfsg-3+deb10u7_amd64.deb