Skip to content

Commit

Permalink
Merge 5f75b35 into bef02bb
Browse files Browse the repository at this point in the history
  • Loading branch information
aciba90 committed Sep 27, 2024
2 parents bef02bb + 5f75b35 commit d8432ed
Show file tree
Hide file tree
Showing 17 changed files with 229 additions and 65 deletions.
29 changes: 29 additions & 0 deletions debian/NEWS
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cloud-init (24.4~4gc9dce94d-0ubuntu2) UNRELEASED; urgency=medium

Cloud-init added cloud-specific metapackages to better express
cloud-specific dependencies and reduce image size.

The original cloud-init is still available as a metapackage and a smaller
version (called cloud-init-base) has been created to include just the
essential dependencies.

A few specific metapackages have been created, while more cloud-specific
ones are under development. The current set include:

* cloud-init-base - package that contains the cloud-init code along with
the minimal set of dependencies
* cloud-init - is a metapackage that retains every previous dependency
* cloud-init-cloud-sigma and cloud-init-smart-os - metapackages with an
additional dependency on python3-serial. They can be installed if the
target platform is CloudSigma or SmartOS

If you are an image builder:

* Install ``cloud-init``, containing all dependencies, if the target
platform is unknown
* Install ``cloud-init-base`` if the target platform(s) are known and do
not require specific dependencies
* Install a cloud-specific metapackage if the target platform has some
specific dependency requirements.

-- Alberto Contreras <alberto.contreras@canonical.com> Tue, 17 Sep 2024 11:02:35 +0200
24 changes: 21 additions & 3 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
cloud-init (24.4~4gc9dce94d-0ubuntu1) UNRELEASED; urgency=medium
cloud-init (24.4~4gc9dce94d-0ubuntu2) UNRELEASED; urgency=medium

* Upstream snapshot based on upstream/main at c9dce94d.

-- James Falcon <james.falcon@canonical.com> Thu, 26 Sep 2024 10:37:10 -0500
* debian: Rename cloud-init to cloud-init-base
+ Add infrastructure to be able to express cloud-specific cloud-init
binary packages.
+ Keep a cloud-init metapackage to install every possible dependency and
be able to operate on any platform
+ Add `Breaks:` and `Replaces:` dependency with
cloud-init <= 24.4~2g2e4c39b7-0ubuntu1
to adopt and own files from cloud-init in cloud-init-base.
* d/cloud-init-base.{config,postinst}:
+ Handle migration of debconf values migrating cloud-init/* values to
cloud-init-base/*.
* d/control: add cloud-sigma and smart-os packages
+ Add cloud-init-cloud-sigma and cloud-init-smart-os binary packages
depending on cloud-init-base and python3-serial.
+ Removes python3-serial from cloud-init-base and add it to cloud-init.
* d/cloud-init-base.templates:
+ Add warning about image portability to dpkg-reconfigure.
* d/NEWS: add news about cloud-specific packages

-- Alberto Contreras <alberto.contreras@canonical.com> Fri, 27 Sep 2024 10:10:16 +0200

cloud-init (24.4~3+really24.3.1-0ubuntu4) oracular; urgency=medium

Expand Down
35 changes: 30 additions & 5 deletions debian/cloud-init.config → debian/cloud-init-base.config
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ get_yaml_list() {
[ -n "$RET" ] || RET="$default"
}

# Migrate a debconf value from cloud-init/* to cloud-init-base/*
# cleaning up the old value.
#
# Arguments:
# Name of the debconf question
migrate_debconf_to_cloud_init_base() {
local old="cloud-init/$1" new="cloud-init-base/$1"
if db_get "$new"; then
# cloud-init-base/* win against cloud-init/* values
if db_get "$old"; then
echo "Removing ${old} in favor of ${new}" 1>&2 || :
db_unregister "$old" || :
fi
return 0
fi
if db_get "$old"; then
echo "Migrating debconf value: ${old} -> ${new}" 1>&2 || :
db_set "$new" "$RET"
db_unregister "$old" || :
fi
}

# old_dpkg_cfg is very old file that is no longer read by cloud-init.
# it gets re-named to cloud.cfg.d/90_dpkg.cfg in the preinst.
dpkg_cfg="/etc/cloud/cloud.cfg.d/90_dpkg.cfg"
Expand All @@ -52,28 +74,31 @@ if [ -f "${old_dpkg_cfg}" -a ! -f "$dpkg_cfg" ]; then
dpkg_cfg="${old_dpkg_cfg}"
echo "WARN: reading value from ${old_dpkg_cfg}" 1>&2
fi

migrate_debconf_to_cloud_init_base datasources

if [ -f "$dpkg_cfg" ]; then
if get_yaml_list "$dpkg_cfg" datasource_list NOTFOUND &&
val="$RET" && [ "$val" != "NOTFOUND" ]; then
db_set cloud-init/datasources $val
db_set cloud-init-base/datasources "$val"
else
echo "WARN: failed to read datasource_list from $dpkg_cfg" 1>&2
fi
elif { db_fget cloud-init/datasources seen || : ; } &&
elif { db_fget cloud-init-base/datasources seen || : ; } &&
[ "${RET}" = "false" ]; then
# this is the first time this we've run (installation or re-install after
# purge). try to determine if the Ec2 datasource is there.
# if it is, and Ec2 was not in the default list, then add it.
db_get cloud-init/datasources
db_get cloud-init-base/datasources
def="${RET}"
case " ${def}," in
*\ Ec2,*) :;;
*) hasEc2Md &&
db_set cloud-init/datasources "${def:+${def}, }Ec2";;
db_set cloud-init-base/datasources "${def:+${def}, }Ec2";;
esac
fi

db_input low cloud-init/datasources || true
db_input low cloud-init-base/datasources || true
db_go

exit 0
5 changes: 5 additions & 0 deletions debian/cloud-init-base.lintian-overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# cloud-init.target should not be considered as unusual
cloud-init-base binary: systemd-service-file-refers-to-unusual-wantedby-target cloud-init.target [lib/systemd/system/cloud-config.service]
cloud-init-base binary: systemd-service-file-refers-to-unusual-wantedby-target cloud-init.target [lib/systemd/system/cloud-final.service]
cloud-init-base binary: systemd-service-file-refers-to-unusual-wantedby-target cloud-init.target [lib/systemd/system/cloud-init-local.service]
cloud-init-base binary: systemd-service-file-refers-to-unusual-wantedby-target cloud-init.target [lib/systemd/system/cloud-init.service]
File renamed without changes.
File renamed without changes.
File renamed without changes.
50 changes: 42 additions & 8 deletions debian/cloud-init.postinst → debian/cloud-init-base.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ handle_preseed_maas() {
local cfg_file="/etc/cloud/cloud.cfg.d/90_dpkg_maas.cfg"
local md_url="" creds_all="" c_key="" t_key="" t_sec="" c_sec="";

db_get "cloud-init/maas-metadata-url" && md_url="$RET" || :
db_get "cloud-init/maas-metadata-credentials" && creds_all="$RET" || :
db_get "cloud-init-base/maas-metadata-url" && md_url="$RET" || :
db_get "cloud-init-base/maas-metadata-credentials" && creds_all="$RET" || :

# nothing to do
[ -n "$md_url" -o -n "$creds_all" ] || return 0
Expand Down Expand Up @@ -86,7 +86,7 @@ for k in sys.argv[2:]:
rm -f "$cfg_file"
else
local header="# written by cloud-init debian package per preseed entries
# cloud-init/{maas-metadata-url,/maas-metadata-credentials}"
# cloud-init-base/{maas-metadata-url,/maas-metadata-credentials}"

local pair="" k="" v="" pload="" orig_umask=""
for pair in "metadata_url:$md_url" "consumer_key:${c_key}" \
Expand All @@ -105,12 +105,12 @@ for k in sys.argv[2:]:
fi

# now clear the database of the values, as they've been consumed
db_unregister "cloud-init/maas-metadata-url" || :
db_unregister "cloud-init/maas-metadata-credentials" || :
db_unregister "cloud-init-base/maas-metadata-url" || :
db_unregister "cloud-init-base/maas-metadata-credentials" || :
}

handle_preseed_local_cloud_config() {
local ccfg="" debconf_name="cloud-init/local-cloud-config"
local ccfg="" debconf_name="cloud-init-base/local-cloud-config"
local cfg_file="/etc/cloud/cloud.cfg.d/90_dpkg_local_cloud_config.cfg"
local header="# written by cloud-init debian package per preseed entry
# $debconf_name"
Expand Down Expand Up @@ -250,14 +250,48 @@ rename_hook_hotplug_udev_rule() {
fi
}

# Migrate a debconf value from cloud-init/* to cloud-init-base/*
# cleaning up the old value.
#
# Arguments:
# Name of the debconf question
migrate_debconf_to_cloud_init_base() {
local old="cloud-init/$1" new="cloud-init-base/$1"
if db_get "$new"; then
# cloud-init-base/* win against cloud-init/* values
if db_get "$old"; then
echo "Removing ${old} in favor of ${new}" 1>&2 || :
db_unregister "$old" || :
fi
return 0
fi
if db_get "$old"; then
echo "Migrating debconf value: ${old} -> ${new}" 1>&2 || :
db_set "$new" "$RET"
db_unregister "$old" || :
fi
}

upgrade_to_cloud_init_base() {
migrate_debconf_to_cloud_init_base local-cloud-config
migrate_debconf_to_cloud_init_base maas-metadata-credentials
migrate_debconf_to_cloud_init_base maas-metadata-url

local oldver="$1" last_ver="24.4~3+really24.3.1-0ubuntu4"
dpkg --compare-versions "$oldver" le-nl "$last_ver" || return 0

migrate_debconf_to_cloud_init_base datasources
}

if [ "$1" = "configure" ]; then
if db_get cloud-init/datasources; then
upgrade_to_cloud_init_base "$2"

if db_get cloud-init-base/datasources; then
values="$RET"
if [ "${values#*MaaS}" != "${values}" ]; then
# if db had old MAAS spelling, fix it.
values=$(echo "$values" | sed 's,MaaS,MAAS,g')
db_set cloud-init/datasources "$values"
db_set cloud-init-base/datasources "$values"
fi
cat > /etc/cloud/cloud.cfg.d/90_dpkg.cfg <<EOF
# to update this file, run dpkg-reconfigure cloud-init
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 10 additions & 1 deletion debian/cloud-init.templates → debian/cloud-init-base.templates
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Template: cloud-init/datasources
Template: cloud-init-base/datasources
Type: multiselect
Default: NoCloud, ConfigDrive, OpenNebula, DigitalOcean, Azure, AltCloud, OVF, MAAS, GCE, OpenStack, CloudSigma, SmartOS, Bigstep, Scaleway, AliYun, Ec2, CloudStack, Hetzner, IBMCloud, Oracle, Exoscale, RbxCloud, UpCloud, VMware, Vultr, LXD, NWCS, Akamai, WSL, None
Choices-C: NoCloud, ConfigDrive, OpenNebula, DigitalOcean, Azure, AltCloud, OVF, MAAS, GCE, OpenStack, CloudSigma, SmartOS, Bigstep, Scaleway, AliYun, Ec2, CloudStack, Hetzner, IBMCloud, Oracle, Exoscale, RbxCloud, UpCloud, VMware, Vultr, LXD, NWCS, Akamai, WSL, None
Expand All @@ -10,3 +10,12 @@ _Description: Which data sources should be searched?
Warning: Only select 'Ec2' if this system will be run on a system with
the EC2 metadata service present. Doing so incorrectly will result in
a substantial timeout on boot.
.
Warning: If this system is intended to run on a cloud / platform
different than the original one, then make sure to install the correct
cloud-init package:
.
- Install a cloud-specific cloud-init package if the target platform
requires one.
- Install cloud-init, containing all dependencies, if the target is
unknown.
5 changes: 0 additions & 5 deletions debian/cloud-init.lintian-overrides

This file was deleted.

34 changes: 32 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Vcs-Git: https://github.com/canonical/cloud-init -b ubuntu/devel
Standards-Version: 4.5.0
Rules-Requires-Root: no

Package: cloud-init
Package: cloud-init-base
Architecture: all
Depends: cloud-guest-utils | cloud-utils,
dhcpcd-base,
Expand All @@ -39,11 +39,39 @@ Depends: cloud-guest-utils | cloud-utils,
python3,
python3-debconf,
python3-requests,
python3-serial,
${misc:Depends},
${python3:Depends}
Recommends: eatmydata, gdisk, gnupg, python3-apt, software-properties-common
Suggests: openssh-server, ssh-import-id
Replaces: cloud-init (<= 24.4~3+really24.3.1-0ubuntu4)
Breaks: cloud-init (<= 24.4~3+really24.3.1-0ubuntu4)
Description: initialization and customization tool for cloud instances
Cloud-init with minimal dependencies, refer to cloud-init for more
information.

Package: cloud-init-cloud-sigma
Architecture: all
Depends: cloud-init-base,
python3-serial,
${misc:Depends},
Description: Cloud Sigma specific cloud-init
This metapackage depends on cloud-init-base and additional packages for
Cloud Sigma.

Package: cloud-init-smart-os
Architecture: all
Depends: cloud-init-base,
python3-serial,
${misc:Depends},
Description: Smart OS specific cloud-init
This metapackage depends on cloud-init-base and additional packages for
Smart OS.

Package: cloud-init
Architecture: all
Depends: cloud-init-base,
python3-serial,
${misc:Depends},
Description: initialization and customization tool for cloud instances
Cloud-init is the industry standard multi-distribution method for
cross-platform cloud instance initialization. It is supported across all major
Expand All @@ -62,3 +90,5 @@ Description: initialization and customization tool for cloud instances
access key and many other aspects of a system. Later on the cloud-init will
also parse and process any optional user or vendor data that was passed to
the instance.
.
This is a metapackage that includes every cloud-init dependency.
2 changes: 1 addition & 1 deletion debian/po/POTFILES.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[type: gettext/rfc822deb] cloud-init.templates
[type: gettext/rfc822deb] cloud-init-base.templates
Loading

0 comments on commit d8432ed

Please sign in to comment.