Change installation script from Redhat to Ubuntu

A script was written for Redhat with RPM (for Microsoft® SQL Server® ODBC Driver 1.0 for Linux ).

It uses this code to check if certain packages are installed.

req_libs=( glibc e2fsprogs krb5-libs openssl )

for lib in ${req_libs[@]}
do
    local present=$(rpm -q -a $lib) >> $log_file 2>&1
    if [ "$present" == "" ]; then
        log "The $lib library was not found installed in the RPM database."
        log "See README for which libraries are required for the $driver_name."
        return 1;
    fi
done

I overcame this problem, knowing / trusting that the libraries were installed, and just uninstalling the test, but I would like to remove it now.

  • How can I find which libraries to look for on Ubuntu. Is there a translation team or webpage for Redhat -> Ubuntu
  • Is replacing rpm -q -a with dpkg -s correct?
+5
source share
1 answer

1) Finding the right packages

Ubuntu/Debian "lib", . "-dev", "-devel"

, , :

sudo apt-get update
apt-cache search <packagename>

... "lib" "dev" , . , .

2)

"dpkg -s", , , "rpm -qa", , , - . "dpkg-query -l", "grep", .

Here's what the equivalent part of the script looks like (with the correct correct package names and log_file output on a separate line):

#!/bin/bash

function stack_install()
{

log_file="$HOME/Desktop/stackoverflow/stack-log.txt"

req_libs=( libc6 e2fsprogs libkrb5-3 openssl )

for lib in ${req_libs[@]}
do
    local present=$(dpkg-query -l "$lib" | grep "$lib" 2>/dev/null)
    echo "$present" >> "$log_file"
    if [ "$present" == "" ]; then
        echo "The $lib library was not found installed in the dpkg database."
        echo "See README for which libraries are required for the $driver_name."
        return 1;
    fi
done 
}

stack_install
+6
source

All Articles