Ubuntu apt: Difference between revisions

From Lolly's Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 68: Line 68:
   };
   };
};
};
</source>
== Getting some packages from a newer release ==
In this example we are living in <i>xenial</i> and want PowerDNS from <i>zesty</i> because we need CAA records in the nameservice.
=== Pin the normal release ===
<source lang=bash>
# echo 'APT::Default-Release "xenial";' > /etc/apt/apt.conf.d/01pinning
</source>
=== Add new release to /etc/apt/sources.list ===
This is the /etc/apt/sources.list on my x86 64bit Ubuntu:
<pre>
# 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
</pre>
=== Tell apt via /etc/apt/preferences.d/... to prefer some packages from the new release ===
This is the /etc/apt/preferences.d/pdns:
<pre>
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
</pre>
=== Upgrade to the packages from the new release ===
<source lang=bash>
# apt update
...
2 packages can be upgraded. Run 'apt list --upgradable' to see them.
...
</source>
=== Check with "apt-cache policy" which version is preferred now ===
<source lang=bash>
# 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
</source>
=== Upgrade to the packages from the new release ===
<source lang=bash>
# apt upgrade
...
</source>
</source>

Revision as of 13:09, 13 October 2017

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
...