The default Debian installation only provide software from the “main” repository. In order to have access to all Debian software, contrib and non-free repositories must be configured. This howto describe an automated process to enable the contrib and non-free repositories in Apt.
This howto is tested on:
- Debian 6.0 Squeeze
- Debian 7.0 Wheezy
- Debian 8.0 Jessie
- Debian 10.0 Buster
Installation
Detect if sudo is available (“command” is used if not):
cmdProxy='command'
command type -f 'sudo' &>'/dev/null' && cmdProxy='sudo'
Install the required software:
${cmdProxy} apt-get install 'lsb-release'
Detect the distribution version name:
debianVersion="$(command lsb_release -cs)"
Detect the currently used download mirror:
mirror="$(awk "/^deb[ \t].*[ \t]${debianVersion}[ \t].*main[\t ].*/ { print \$2; exit }" '/etc/apt/sources.list')"
Add the contrib repositories to Apt configuration, if needed:
command egrep -qr "^deb[\t ].*[\t ]${debianVersion}[\t ].*contrib" '/etc/apt/sources.list'* \
|| ${cmdProxy} tee "/etc/apt/sources.list.d/contrib.list" \
<<< "# Debian non-free repository.
deb ${mirror} ${debianVersion} contrib
deb-src ${mirror} ${debianVersion} contrib
deb http://security.debian.org/ ${debianVersion}/updates contrib
deb-src http://security.debian.org/ ${debianVersion}/updates contrib"
Add the non-free repositories to Apt configuration, if needed:
command egrep -qr "^deb[\t ].*[\t ]${debianVersion}[\t ].*non-free" '/etc/apt/sources.list'* \
|| ${cmdProxy} tee "/etc/apt/sources.list.d/non-free.list" \
<<< "# Debian non-free repository.
deb ${mirror} ${debianVersion} non-free
deb-src ${mirror} ${debianVersion} non-free
deb http://security.debian.org/ ${debianVersion}/updates non-free
deb-src http://security.debian.org/ ${debianVersion}/updates non-free"
Update the list of available packages:
${cmdProxy} apt update
0 Comments