[Linux] Ubuntu apt-get offline installation
1 minute read
Installing apt packages offline 1
# create docker container to download the packages
docker container run -it --name u22 --platform linux/amd64 ubuntu:22.04 bash
# download wanted packages
apt-get update -y && apt-get install --download-only \
python3-dev \
build-essential \
libpq-dev
# copy "/var/cache/apt/archives" dir to the local machine and then to the target machine where installation will be done
docker cp u22:/var/cache/apt/archives/ . # move to local
# copy/scp to target machine
# cd /path/to/archives
sudo dpkg --force-all -i *.deb
# check whether installtion is done (dpkg -L package_name)
dpkg -L build-essential
dpkg -L python3-dev
dpkg -L libpq-dev
Installing apt packages offline 2
apt-get update -y && apt-get install dpkg-dev
# create temporary dir
mkdir -p /tmp/pkg
cd /tmp/pkg
# download package and its dependencies (apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances {package_name} | grep "^\w" | sort -u))
apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances libpq-dev | grep "^\w" | sort -u)
#build the index of the just downloaded packages
dpkg-scanpackages . | gzip -9c > Packages.gz
# copy "/tmp/pkg" dir to the local machine and then to the target machine where installation will be done
# add to apt source list\(echo "deb file:{your folder here}{} ./" | sudo tee -a /etc/apt/sources.list)
echo "deb [trusted=yes] file:/tmp/pkg ./" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
# install(sudo apt-get install {package_name} -y)
sudo apt-get install libpq-dev -y
# check whether installtion is done (dpkg -L {package_name})
dpkg -L libpq-dev
ref