3 \�me� � @ s� U d Z ddlZddlZddlZddlZddlZddlZddlZddlm Z m Z ddlmZm Z mZmZ ddlmZmZmZmZmZ ddlmZ ddlmZ ddlmZmZ dd lmZ eje �Z!d Z"dZ#dZ$d Z%dZ&eZ'ddgZ(ddd�Z)ee*e*f )ddde d�e(e d�e d�ge'g d�Z+e+ee+�Z dZ,dZ-dZ.dZ/dd d!�Z0d"d"d!�Z1d#d$gZ2d%d&d'd(d)d*gZ3d}d+d,�Z4e*eee5dd-�d.d/�Z6d0d1� Z7d2d3� Z8d~d4d5�Z9dd6d7�Z:d�d8d9�Z;d:d;� Z<d<d=� Z=d>d?� Z>d@dA� Z?e*e*dB�dCdD�Z@e*dE�dFdG�ZAe*dE�dHdI�ZBdJdK� ZCe*eDdL�dMdN�ZEdOdPdQdR�ZFdSZGee*e*f dE�dTdU�ZHdVdW� ZId�dYdZ�ZJd[d\� ZKd�d]d^�ZLd_d`� ZMd�dadb�ZNdcdd� ZOdedf� ZPdgdh� ZQdidj� ZRdkdl� ZSdmdn� ZTdodp� ZUdqdr� ZVdsdt� ZWd�dudv�ZXdwdx� ZYd�dzd{�ZZd|e<iZ[dS )�z*Apt Configure: Configure apt for the user.� N)�dedent�indent)�Dict�Iterable�List�Mapping)�features�gpg�subp� templater�util)�Cloud)�Config)� MetaSchema�get_meta_doc)�PER_INSTANCEz ^[\w-]+:\wz/etc/apt/trusted.gpgz/etc/apt/trusted.gpg.d/z/etc/apt/cloud-init.gpg.d/z&# cloud-init disable_suites redacted: ZubuntuZdebianzsoftware-properties-commonZgnupg)zadd-apt-repositoryr Zcc_apt_configurez Apt ConfigurezConfigure apt for the useraT This module handles both configuration of apt options and adding source lists. There are configuration options such as ``apt_get_wrapper`` and ``apt_get_command`` that control how cloud-init invokes apt-get. These configuration options are handled on a per-distro basis, so consult documentation for cloud-init's distro support for instructions on using these config options. By default, cloud-init will generate default apt sources information in deb822 format at :file:`/etc/apt/sources.list.d/<distro>.sources`. When the value of `sources_list` does not appear to be deb822 format, or stable distribution releases disable deb822 format, :file:`/etc/apt/sources.list` will be written instead. .. note:: To ensure that apt configuration is valid yaml, any strings containing special characters, especially ``:`` should be quoted. .. note:: For more information about apt configuration, see the ``Additional apt configuration`` example.a- apt: preserve_sources_list: false disable_suites: - $RELEASE-updates - backports - $RELEASE - mysuite primary: - arches: - amd64 - i386 - default uri: 'http://us.archive.ubuntu.com/ubuntu' search: - 'http://cool.but-sometimes-unreachable.com/ubuntu' - 'http://us.archive.ubuntu.com/ubuntu' search_dns: false - arches: - s390x - arm64 uri: 'http://archive-to-use-for-arm64.example.com/ubuntu' security: - arches: - default search_dns: true sources_list: | deb $MIRROR $RELEASE main restricted deb-src $MIRROR $RELEASE main restricted deb $PRIMARY $RELEASE universe restricted deb $SECURITY $RELEASE-security multiverse debconf_selections: set1: the-package the-package/some-flag boolean true conf: | APT { Get { Assume-Yes 'true'; Fix-Broken 'true'; } } proxy: 'http://[[user][:pass]@]host[:port]/' http_proxy: 'http://[[user][:pass]@]host[:port]/' ftp_proxy: 'ftp://[[user][:pass]@]host[:port]/' https_proxy: 'https://[[user][:pass]@]host[:port]/' sources: source1: keyid: 'keyid' keyserver: 'keyserverurl' source: 'deb [signed-by=$KEY_FILE] http://<url>/ bionic main' source2: source: 'ppa:<ppa-name>' source3: source: 'deb $MIRROR $RELEASE multiverse' key: | ------BEGIN PGP PUBLIC KEY BLOCK------- <key data> ------END PGP PUBLIC KEY BLOCK------- source4: source: 'deb $MIRROR $RELEASE multiverse' append: false key: | ------BEGIN PGP PUBLIC KEY BLOCK------- <key data> ------END PGP PUBLIC KEY BLOCK-------a� # cloud-init version 23.4 will generate a deb822 formatted sources # file at /etc/apt/sources.list.d/<distro>.sources instead of # /etc/apt/sources.list when `sources_list` content is deb822 # format. apt: sources_list: | Types: deb URIs: http://archive.ubuntu.com/ubuntu/ Suites: $RELEASE Components: main )�id�name�title�description�distrosZexamples� frequencyZactivate_by_schema_keysz/var/lib/apt/listsz'/etc/apt/apt.conf.d/94cloud-init-configz)/etc/apt/apt.conf.d/90cloud-init-aptproxyzkeyserver.ubuntu.comz!http://archive.ubuntu.com/ubuntu/z"http://security.ubuntu.com/ubuntu/)�PRIMARY�SECURITYz$http://ports.ubuntu.com/ubuntu-ports�amd64Zi386Zs390xZarm64ZarmhfZpowerpcZppc64elZriscv64c C sB | dkrt j|�} | tkr"tj� S | tkr2tj� S td| ��dS )z�returns the default mirrors for the target. These depend on the architecture, for more see: https://wiki.ubuntu.com/UbuntuDevelopment/PackageArchive#PortsNz#No default mirror known for arch %s)r �get_dpkg_architecture�PRIMARY_ARCHES�PRIMARY_ARCH_MIRRORS�copy�PORTS_ARCHES� PORTS_MIRRORS� ValueError)�arch�target� r$ �&/usr/lib/python3.6/cc_apt_configure.py�get_default_mirrors� s r&