Ubuntu apt

From Lolly's Wiki
Revision as of 12:09, 13 October 2017 by Lollypop (talk | contribs)
Jump to navigationJump to search

apt

Get all non LTS packages

# dpkg --list | awk '/^ii/ {print $2}' | xargs apt-cache show | awk '
BEGIN{
  support="none";
}
/^Package:/,/^$/{
  if(/^Package:/){ pkg=$2; }
  if(/^Supported:/){ support=$2; }
  if(/^$/ && support != "5y"){ printf "%s:\t%s\n", pkg, support; }
}
/^$/ {
  support="none";
}'

Configuring a proxy for apt

Put this into your /etc/apt/apt.conf.d/00proxy :

// Options for the downloading routines
Acquire
{
  Queue-Mode "host";       // host|access
  Retries "0";
  Source-Symlinks "true";

  // HTTP method configuration
  http
  {
    //Proxy::http.us.debian.org "DIRECT";  // Specific per-host setting
    Proxy "http://<user>:<password>@<proxy-host>:<proxy-port>";
    Timeout "120";
    Pipeline-Depth "5";

    // Cache Control. Note these do not work with Squid 2.0.2
    No-Cache "false";
    Max-Age "86400";     // 1 Day age on index files
    No-Store "false";    // Prevent the cache from storing archives
  };

  ftp
  {
    Proxy "http://<user>:<password>@<proxy-host>:<proxy-port>";
    //Proxy::http.us.debian.org "DIRECT"; // Specific per-host setting

    Timeout "120";

    /* Passive mode control, proxy, non-proxy and per-host. Pasv mode
       is prefered if possible */
    Passive "true";
    Proxy::Passive "true";
    Passive::http.us.debian.org "true"; // Specific per-host setting
  };

  cdrom
  {
    mount "/cdrom";

    // You need the trailing slash!
    "/cdrom"
    {
       Mount "sleep 1000";
       UMount "sleep 500";
    }
  };
};

Getting some packages from a newer release

In this example we are living in xenial and want PowerDNS from zesty because we need CAA records in the nameservice.

Pin the normal release

# echo 'APT::Default-Release "xenial";' > /etc/apt/apt.conf.d/01pinning

Add new release to /etc/apt/sources.list

This is the /etc/apt/sources.list on my x86 64bit Ubuntu:

# Xenial
deb [arch=amd64] http://de.archive.ubuntu.com/ubuntu/ xenial main restricted universe
deb [arch=amd64] http://de.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu xenial-security main restricted universe
# Zesty
deb [arch=amd64] http://de.archive.ubuntu.com/ubuntu/ zesty main restricted universe
deb [arch=amd64] http://de.archive.ubuntu.com/ubuntu/ zesty-updates main restricted universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu zesty-security main restricted universe

Tell apt via /etc/apt/preferences.d/... to prefer some packages from the new release

This is the /etc/apt/preferences.d/pdns:

Package: pdns-*
Pin: release a=zesty, l=Ubuntu
Pin-Priority: 1000

Package: pdns-*
Pin: release a=zesty-updates, l=Ubuntu
Pin-Priority: 1000

Package: pdns-*
Pin: release a=zesty-security, l=Ubuntu
Pin-Priority: 1000

Upgrade to the packages from the new release

# apt update
...
2 packages can be upgraded. Run 'apt list --upgradable' to see them.
...

Check with "apt-cache policy" which version is preferred now

# apt-cache policy pdns-server pdns-tools
pdns-server:
  Installed: 4.0.3-1
  Candidate: 4.0.3-1
  Version table:
 *** 4.0.3-1 1000
        500 http://de.archive.ubuntu.com/ubuntu zesty/universe amd64 Packages
        100 /var/lib/dpkg/status
     4.0.0~alpha2-3build1 990
        990 http://de.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
pdns-tools:
  Installed: (none)
  Candidate: 4.0.3-1
  Version table:
     4.0.3-1 1000
        500 http://de.archive.ubuntu.com/ubuntu zesty/universe amd64 Packages
     4.0.0~alpha2-3build1 990
        990 http://de.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages

Upgrade to the packages from the new release

# apt upgrade
...