How to use a .iso image as a CD-ROM/DVD Repository? And how to install packages using the repository?
First create a sources.list file anywhere; like e.g.: /home/$USER/dvd_repo.sources.list by:
echo 'deb [trusted=yes] file:/media/cdrom ./' > /home/$USER/dvd_repo.sources.list
where, /media/cdrom
is the mount point of your repository ISO (sudo mkdir /media/cdrom
to create if it does not exist; mounted with e.g. sudo mount /home/$USER/wkhtmltopdf_repository.iso /media/cdrom
).
After you have your sources.list file, and mounted the repository .ISO file, you should update with:
sudo apt-get -o Dir::Etc::SourceList=/home/$USER/dvd_repo.sources.list update
This skips the default /etc/apt/sources.list
. It might take a few moments (took 2 minutes for me) for the repository query to timeout when we are not connected to internet, and if additional repository are configured in sources.list.d
directory (I had Waydroid in mine). The log for mine is:
Get:1 file:/media/cdrom ./ InRelease
Ign:1 file:/media/cdrom ./ InRelease
Get:2 file:/media/cdrom ./ Release
Ign:2 file:/media/cdrom ./ Release
Get:3 file:/media/cdrom ./ Packages [2,148 B]
Get:4 file:/media/cdrom ./ Translation-en
Ign:4 file:/media/cdrom ./ Translation-en
Get:5 file:/media/cdrom ./ Translation-en_US
Ign:5 file:/media/cdrom ./ Translation-en_US
Get:4 file:/media/cdrom ./ Translation-en
Ign:4 file:/media/cdrom ./ Translation-en
Get:5 file:/media/cdrom ./ Translation-en_US
Ign:5 file:/media/cdrom ./ Translation-en_US
Get:4 file:/media/cdrom ./ Translation-en
Ign:4 file:/media/cdrom ./ Translation-en
Get:5 file:/media/cdrom ./ Translation-en_US
Ign:5 file:/media/cdrom ./ Translation-en_US
Get:4 file:/media/cdrom ./ Translation-en
Ign:4 file:/media/cdrom ./ Translation-en
Get:5 file:/media/cdrom ./ Translation-en_US
Ign:5 file:/media/cdrom ./ Translation-en_US
Get:4 file:/media/cdrom ./ Translation-en
Ign:4 file:/media/cdrom ./ Translation-en
Get:5 file:/media/cdrom ./ Translation-en_US
Ign:5 file:/media/cdrom ./ Translation-en_US
Get:4 file:/media/cdrom ./ Translation-en
Ign:4 file:/media/cdrom ./ Translation-en
Get:5 file:/media/cdrom ./ Translation-en_US
Ign:5 file:/media/cdrom ./ Translation-en_US
Get:4 file:/media/cdrom ./ Translation-en
Ign:4 file:/media/cdrom ./ Translation-en
Get:5 file:/media/cdrom ./ Translation-en_US
Ign:5 file:/media/cdrom ./ Translation-en_US
Ign:6 https://repo.waydro.id lunar InRelease
Ign:6 https://repo.waydro.id lunar InRelease
Ign:6 https://repo.waydro.id lunar InRelease
Err:6 https://repo.waydro.id lunar InRelease
Could not connect to repo.waydro.id:443 (205.185.118.53). - connect (101: Network is unreachable)
Reading package lists... Done
W: Failed to fetch https://repo.waydro.id/dists/lunar/InRelease Could not connect to repo.waydro.id:443 (205.185.118.53). - connect (101: Network is unreachable)
W: Some index files failed to download. They have been ignored, or old ones used instead.
Though the available package is not reflected in apt-cache policy pkg_name
, you can now successfully install the package with apt-get
. E.g. to install the package wkhtmltopdf
:
sudo apt-get -o Dir::Etc::SourceList=/home/$USER/dvd_repo.sources.list install wkhtmltopdf
You can override the sources.list.d
by:
sudo apt-get -o Dir::Etc::SourceList=/home/$USER/dvd_repo.sources.list -o Dir::Etc::SourceParts=/dev/null update
This overrides both /etc/apt/sources.list
and /etc/apt/sources.list.d/
and results in faster update of index files in /var/lib/apt/lists
, however all other cached index files are removed which results in not being able to query for available packages in web repositories, until you connect to internet and update the package indexes again. (I've assigned Dir::Etc::SourceParts
to /dev/null
file while you may assign to an empty existing directory, say, /var/empty/
.)
After installation, unmount the ISO file with sudo umount /media/cdrom
.
Links: