I have a bash file with a list of packages to install for a new Ubuntu installation using apt install however, not all the packages in the list are installing. Repos are included in the script as necessary.
I've tried the 2 methods below:
Method 1:
apt install [pkg1] [pkg2] [pkg3] ... [pkgn]
Method 2 - (pseudo code):
String pkgs_list[] = {"pkg1" "pkg2" "pkg3" "pkgn"}
for each pkg in pkg_list {
if pkg exists then {
"do nothing"
else
apt install pkg
}
}
Here is the complete bash code:
#***********************#
#*** Keys ***#
#***********************#
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
wget -O - https://dl.sinew.in/keys/enpass-linux.key | apt-key add -
wget -nc https://dl.winehq.org/wine-builds/Release.key | apt-key add -
#***********************#
#*** Repositories ***#
#***********************#
echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list
echo "deb http://repo.sinew.in/ stable main" > \
/etc/apt/sources.list.d/enpass.list
add-apt-repository -y ppa:webupd8team/gnome3 #This is for gnome tweak tool extensions (source: https://www.wikihow.com/Change-Themes-on-Ubuntu-with-Gnome-Tweak-Tool)
add-apt-repository -y ppa:notepadqq-team/notepadqq
add-apt-repository https://dl.winehq.org/wine-builds/ubuntu/
apt -y update
#WinHQ enables 32bit architecture
dpkg --add-architecture i386
#***********************#
#*** apt install ***#
#***********************#
#apt -y install \
# nemo \
# google-chrome-stable \
# notepadqq dconf-editor \
# nfs-common \
# enpass \
# virtualbox \
# virtualbox-guest-additions-iso \
# gnome-tweak-tool \
#gnome-shell-extensions-user-themes \
# vlc \
# gimp \
# winehq-stable \
# synaptic
declare -a alist=("nemo"
"google-chrome-stable"
"notepadqq"
"dconf-editor"
"nfs-common"
"enpass"
"virtualbox"
"virtualbox-guest-additions-iso"
"gnome-tweak-tool"
"vlc"
"gimp"
"winehq-stable"
"synaptic"
"usb-creator-gtk"
"libreoffice"
"chromium-browser"
"thunderbird"
"shotwell"
"gnome-calendar")
for application in "${alist[@]}"
do
dpkg -l $application
if [ $? = '0' ]; then
echo "***************************************************************************"
echo "*****Application "$application" package is installed, no action taken.*****"
echo "***************************************************************************"
elif [ $? = '1' ]; then
echo "******************************************"
echo "*****Installing package $application.*****"
echo "******************************************"
#Add an if to match dock favorites and add to the dock .desktop file
apt install $application -y
fi
done
Here's the list of applications and there status after the script ran:
- nemo - ok
- google-chrome-stable - ok
- notepadqq - did not install
- dconf-editor - ok
- nfs-common - did not install
- enpass - ok
- virtualbox - ok
- virtualbox-guest-additions-iso - don't know
- gnome-tweak-tool - did not install
- vlc - ok
- gimp - did not install
- winehq-stable - did not install
- synaptic - did not install
- usb-creator-gtk - did not install
- libreoffice - ok
- chromium-browser - did not install
- thunderbird - did not install
- shotwell - did not install
- gnome-calendar - did not install
I can provide more information for each package is needed.
Thanks for your help.
EDIT
The log file generated by using the command $ sudo ./my_script.sh >> my_script.log
is to large so I will post what I think is the problem and we can go from there.
Below is the output for gimp, one that did not install. When my code checks if the package is installed by using the command dpkg -l [package_name]
it returns the following when checking for gimp and the others.
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
un gimp <none> <none> (no description available)
ALL the packages that did not install return this with Version and Architecture as <none>
which tells me there's no package install, right? But when the bash script runs, the command return '0' making my statements believe the package is installed which does not seem to be the case according to dpkg. Instead, dpkg is supposed to return something like this: ...
$ dpkg -l package
dpkg-query: no packages found matching package
... when a package` is not installed.
I don't understand what is happening here with dpkg
returning the information posted. What does this mean? What's happening?
Thanks,
EDIT
Additionally, if I try to remove the package with apt
I get:
$ sudo apt autoremove gimp
[sudo] password for alex2wr:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'gimp' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
0 Answers