Installing local .deb packages with sudo apt install

skylight_12

New Member
Joined
Sep 25, 2023
Messages
7
Reaction score
3
Credits
93
Hey everyone!

I am trying to install a bunch of .deb packages (local ones that I 100% trust) from a USB to Ubuntu 22.04 (server not desktop so the tty1 console is what i am working with). I mounted the USB to a specific directory (created with mkdir command) and tried using:

sudo apt install -y --no-install-recommends /path/to/usb/directory/with/packages/*.deb

and my output is saying:

Reading package lists... Done
Building dependency tree...Done
Reading state information... Done
Note, selecting 'package-x' instead of '/path/to/usb/directory/with/packages/package-x.deb'
..... (this outputs for all 42 .deb packages)
Some packages could not be installed. [...]
The following information may help to resolve the situation:
(tells me there is an unmet dependency which "is to be installed" followed by E: Unable to correct problems, you have held broken packages).

Can anyone guide me on what I am doing wrong or how it should be done to correctly install all the .deb packages that are located in the usb drive (local folder) because all the dependencies are there?

I have tried to follow: https://askubuntu.com/questions/170348/how-to-create-a-local-apt-repository but still do not get them installed. I am trying to avoid sudo dpkg -i, doing it manually, since I read that it skips dependency checking unlike apt-get/apt.

Thank you in advance community!
 


Try this command see if it corrects the problem.
Code:
sudo dpkg --configure -a
(note: if that does not work try this)
sudo apt install -f
 
Hey everyone!

I am trying to install a bunch of .deb packages (local ones that I 100% trust) from a USB to Ubuntu 22.04 (server not desktop so the tty1 console is what i am working with). I mounted the USB to a specific directory (created with mkdir command) and tried using:

sudo apt install -y --no-install-recommends /path/to/usb/directory/with/packages/*.deb

and my output is saying:

Reading package lists... Done
Building dependency tree...Done
Reading state information... Done
Note, selecting 'package-x' instead of '/path/to/usb/directory/with/packages/package-x.deb'
..... (this outputs for all 42 .deb packages)
Some packages could not be installed. [...]
The following information may help to resolve the situation:
(tells me there is an unmet dependency which "is to be installed" followed by E: Unable to correct problems, you have held broken packages).

Can anyone guide me on what I am doing wrong or how it should be done to correctly install all the .deb packages that are located in the usb drive (local folder) because all the dependencies are there?

I have tried to follow: https://askubuntu.com/questions/170348/how-to-create-a-local-apt-repository but still do not get them installed. I am trying to avoid sudo dpkg -i, doing it manually, since I read that it skips dependency checking unlike apt-get/apt.

Thank you in advance community!
There is an apparent contradictions in the issue. The apt program is saying there are unmet dependencies, and you are saying that "all the dependencies are there". How can both be true?

The .deb packages you are trying to install, you trust "100%", but there is no information provided to enable the reader to have a similar level of trust.

Nevertheless, the following may be of interest, though I'm unable to help with the creation of a local repo.

If you have the aptitude program installed, it may be able to provide some information as to what is available and happening and provide some options, which it does.

For example, to get some information on the installation of a package, one can run:
Code:
aptitude why <pkg>
The output usually explains the reason that a particular package should or cannot be installed on the system and prints it to screen. By contrast, there is this command:
Code:
aptitude why-not <pkg>
which finds a dependency chain leading to a conflict with the target package, and prints it's finding to screen.

In the case where a package does have dependencies not already on the system, the approach of using dpkg on a locally downloaded or created <pkg>.deb, and then using apt-get with the -f flag to fix dependencies, is unnecessary since one can just run 'apt install <pkg>.deb' and accomplish installation all in one go. The dpkg command is useful when something is broken, and often apt will tell the user to invoke it when there's an issue.

If the <pkg>.deb is local, but needs to gather dependencies from repositories other than those which come standard with the installation, then those repositories need to be specified in the sources.list, which may mean that the sources.list includes more repositories than the default that is provided by the original installation.

If one has created a local repository which replaces online repositories altogether, then that "home" repository would need to include all the dependencies of packages that are going to be installed from it since the system is not going to access the standard, or configured, online repositories.

One can check for half-installed packages by hunting in /var/log/apt/history.log for the terms: half-installed or half-configured.

If it gets to the point where you might consider using the option to force things, run:
Code:
dpkg --force-help
to see what the options are.
 
There is an apparent contradictions in the issue. The apt program is saying there are unmet dependencies, and you are saying that "all the dependencies are there". How can both be true?

The .deb packages you are trying to install, you trust "100%", but there is no information provided to enable the reader to have a similar level of trust.

Nevertheless, the following may be of interest, though I'm unable to help with the creation of a local repo.

If you have the aptitude program installed, it may be able to provide some information as to what is available and happening and provide some options, which it does.

For example, to get some information on the installation of a package, one can run:
Code:
aptitude why <pkg>
The output usually explains the reason that a particular package should or cannot be installed on the system and prints it to screen. By contrast, there is this command:
Code:
aptitude why-not <pkg>
which finds a dependency chain leading to a conflict with the target package, and prints it's finding to screen.

In the case where a package does have dependencies not already on the system, the approach of using dpkg on a locally downloaded or created <pkg>.deb, and then using apt-get with the -f flag to fix dependencies, is unnecessary since one can just run 'apt install <pkg>.deb' and accomplish installation all in one go. The dpkg command is useful when something is broken, and often apt will tell the user to invoke it when there's an issue.

If the <pkg>.deb is local, but needs to gather dependencies from repositories other than those which come standard with the installation, then those repositories need to be specified in the sources.list, which may mean that the sources.list includes more repositories than the default that is provided by the original installation.

If one has created a local repository which replaces online repositories altogether, then that "home" repository would need to include all the dependencies of packages that are going to be installed from it since the system is not going to access the standard, or configured, online repositories.

One can check for half-installed packages by hunting in /var/log/apt/history.log for the terms: half-installed or half-configured.

If it gets to the point where you might consider using the option to force things, run:
Code:
dpkg --force-help
to see what the options are.
 
I cannot elaborate much further on the .deb packages since they are from a project in Gitlab (which happens to be private). Hence, why I said that I trust them. Sorry for not including any other necessary information as I am pretty new to this procedure.

What I was trying to do altogether is to create a local repository, where I want to add the folder from the usb drive to the debian package handler. I just connected the usb drive to the computer (it has the directory /os/packages/ and in the "packages" folder are 42 .deb packages). I added a .list called "os-local.list" to the sources.list.d directory by

$ sudo nano /etc/apt/sources.list.d/os-local.list

deb file:/mnt/<USB path>/os/packages ./ #pointing to the usb packages folder

$ sudo apt update --> tells me 'E: The repository 'file:/mnt/usb/os/packages ./ Release' does not have a Release file. Updating from such a repository cannot be done securely [...].

Side question before I proceed: Is my <USB path> incorrect? I mounted the usb drive /dev/sdc1 to a created directory /mnt/usb and assume that the <USB path> should then be the mountpoint? Please tell me if I am wrong in this.

The output from sudo apt update is understandable to me because the usb local directory /os/packages/ has indeed no Packages.gz or Release file that sudo apt-get can read from, it only has 42 .deb packages. I have already tried to add either Packages.gz and Release by dpkg-scanpackages (I was following https://askubuntu.com/questions/170348/how-to-create-a-local-apt-repository and https://www.percona.com/blog/how-to-create-your-own-repositories-for-packages/) yet still cannot get a clean $ sudo apt update output. If I could get past this point, the next step is to have one particular .deb package installed by

$ sudo apt install -y --no-install-recommends <pkg name>

This particular .deb (config) package is already configured to pull in the rest of the dependencies from the usb folder....but I get the unmet dependency I first told you about which is weird to me because the package it is asking for is already in the usb folder too.

Like I said, I have not done this before, therefore, I really appreciate your comments of assistance and guidance because I am eager to learn the correct way!
 
Last edited:
I cannot elaborate much further on the .deb packages since they are from a project in Gitlab (which happens to be private). Hence, why I said that I trust them. Sorry for not including any other necessary information as I am pretty new to this procedure.

What I was trying to do altogether is to create a local repository, where I want to add the folder from the usb drive to the debian package handler. I just connected the usb drive to the computer (it has the directory /os/packages/ and in the "packages" folder are 42 .deb packages). I added a .list called "os-local.list" to the sources.list.d directory by

$ sudo nano /etc/apt/sources.list.d/os-local.list

deb file:/mnt/<USB path>/os/packages ./ #pointing to the usb packages folder

$ sudo apt update --> tells me 'E: The repository 'file:/mnt/usb/os/packages ./ Release' does not have a Release file. Updating from such a repository cannot be done securely [...].

Side question before I proceed: Is my <USB path> incorrect? I mounted the usb drive /dev/sdc1 to a created directory /mnt/usb and assume that the <USB path> should then be the mountpoint? Please tell me if I am wrong in this.

The output from sudo apt update is understandable to me because the usb local directory /os/packages/ has indeed no Packages.gz or Release file that sudo apt-get can read from, it only has 42 .deb packages. I have already tried to add either Packages.gz and Release by dpkg-scanpackages (I was following https://askubuntu.com/questions/170348/how-to-create-a-local-apt-repository and https://www.percona.com/blog/how-to-create-your-own-repositories-for-packages/) yet still cannot get a clean $ sudo apt update output. If I could get past this point, the next step is to have one particular .deb package installed by

$ sudo apt install -y --no-install-recommends <pkg name>

This particular .deb (config) package is already configured to pull in the rest of the dependencies from the usb folder....but I get the unmet dependency I first told you about which is weird to me because the package it is asking for is already in the usb folder too.

Like I said, I have not done this before, therefore, I really appreciate your comments of assistance and guidance because I am eager to learn the correct way!
Ps: If you are wondering how on Earth I could get to the point of the unmet dependency output when I say I do not get a clean output from sudo apt update.. When I add a Packages.gz and Release file to the usb local folder via dpkg-scanpackages and finally run sudo apt update..the output does read, build, and read state information good. However, I say it is not clean because I have a bunch of translation entries that are being ignored and registered as Err. I am not sure if this means that everything is correct but even now when I try
$ sudo apt install -y --no-install-recommends <pkg name>
I get that the following package has an unmet dependency. And now we are here again to this problem...the unmet dependency is already in the usb folder and the package I called to install should be able to pull in the rest.
 
Ps: If you are wondering how on Earth I could get to the point of the unmet dependency output when I say I do not get a clean output from sudo apt update.. When I add a Packages.gz and Release file to the usb local folder via dpkg-scanpackages and finally run sudo apt update..the output does read, build, and read state information good. However, I say it is not clean because I have a bunch of translation entries that are being ignored and registered as Err. I am not sure if this means that everything is correct but even now when I try

I get that the following package has an unmet dependency. And now we are here again to this problem...the unmet dependency is already in the usb folder and the package I called to install should be able to pull in the rest.
Update: I just installed the unmet dependency by $ sudo apt install -y --no-install-recommends <missing pkg name> and when i now try installing the initial package...I still get the same unmet dependency "but is still going to be installed" error message. I just installed that missing package though...so I am not sure why it is asking for it again.

Doing as you suggested Osprey:

$ sudo aptitude why <initial package> tells me:
Not currently installed.
The candidate version <full name of the initial package> has priority extra.
No dependencies require to install <initial package>.


Still puzzling to me... has anyone seen this output before from aptitude as an explanation to why a package could not get installed? $ sudo aptitude why-not gives the same explanation.

Thank you.
 
Last edited:
That aptitude output is saying the package is not installed, and further, that it found that nothing is dependent on that package ... which is different to what the package itself depends upon.

To find what a .deb package depends upon there are a few useful commands. For example, in the case of the curl package:
Code:
[flip@flop ~]$ apt-cache depends curl
curl
  Depends: libc6
  Depends: libcurl4
  Depends: zlib1g

More precisely, the version information is also relevant:
Code:
[flip@flop ~]$ apt-cache show curl
Package: curl
Version: 8.2.1-2
Installed-Size: 482
Maintainer: Alessandro Ghedini <[email protected]>
Architecture: amd64
Depends: libc6 (>= 2.34), libcurl4 (= 8.2.1-2), zlib1g (>= 1:1.1.4
<snip>

If you haven't investigated this angle before, it may be useful to see what apt-cache sees as the dependencies with the relevant versions, to check whether these particular dependencies have been met. You may of course have done this, but it occurred to me in this case, so I've mentioned it. Still thinking.
 
There are some .deb packages that may require what are now depleted [no longe in the software manager] some Epsom printers for example require lsb which has to be installed from a legacy repository. I can't help with installing/using local software repositories, but it may help if you tell our programming bods, WHICH .deb files you are having problems with.
 
I am using local repository though...these are packages that are built by ourselves and I wanted to run them from a local repository (created by myself in a similar fashion as the links I provided and like in https://help.ubuntu.com/community/Repositories/Personal) on my computer which uses LEGACY BIOS mode. The idea is to add them to my computer with Ubuntu 22.04 minimal server (server install) on it. I cannot get into detail about the .deb files other than that they are not part of the Ubuntu software repositories that are available to all. This is why I made my own repository. To make another attempt at installing the .deb package(s), I have transferred all the .deb packages to the another created repository (on the computer) instead of using the usb drive as the local repository to fetch packages from.

Calling that package now still gives me the same unmet dependency issue even though I have clearly stated in the .list file in sources.list.d directory where the repository is "deb: [trusted=yes] file:/opt/debs ./".

I shall battle with this more and not give up! I appreciate the help so far and if the information that I have provided has not been sufficient then I apologise again in advance. I may have to just manually install each package in the end but let's see.

Thanks anyway for all the comments provided, community!
 
I am using local repository though...these are packages that are built by ourselves and I wanted to run them from a local repository (created by myself in a similar fashion as the links I provided and like in https://help.ubuntu.com/community/Repositories/Personal) on my computer which uses LEGACY BIOS mode. The idea is to add them to my computer with Ubuntu 22.04 minimal server (server install) on it. I cannot get into detail about the .deb files other than that they are not part of the Ubuntu software repositories that are available to all. This is why I made my own repository. To make another attempt at installing the .deb package(s), I have transferred all the .deb packages to the another created repository (on the computer) instead of using the usb drive as the local repository to fetch packages from.

Calling that package now still gives me the same unmet dependency issue even though I have clearly stated in the .list file in sources.list.d directory where the repository is "deb: [trusted=yes] file:/opt/debs ./".

I shall battle with this more and not give up! I appreciate the help so far and if the information that I have provided has not been sufficient then I apologise again in advance. I may have to just manually install each package in the end but let's see.

Thanks anyway for all the comments provided, community!

Solved dependency issue now. The .deb package's "control" file needed to be modified, had a minor typo there.

Thanks again, community, for your fast replies and efforts to help!
 

Members online


Top