Skip to content

Commit

Permalink
kernel plugin: change location where snapd deb is unpacked
Browse files Browse the repository at this point in the history
`ubnutu-core-initramfs` tool changed where `snap-boostrap` is fetched from.
It assumes `snap-bootstrap` from passed `--root` to be used.
Unpack the downloaded snapd debian package to the same directory where
"ubnutu-core-initramfs" debian package is unpacked.
This directory is already passed to the `ubnutu-core-initramfs` tool as `--root`

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
  • Loading branch information
kubiko committed Jun 6, 2023
1 parent af87aa0 commit 8f6333a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 27 deletions.
1 change: 0 additions & 1 deletion snapcraft/parts/plugins/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ def get_build_environment(self) -> Dict[str, str]:
"ARCH": self._kernel_arch,
"DEB_ARCH": "${CRAFT_TARGET_ARCH}",
"UC_INITRD_DEB": "${CRAFT_PART_BUILD}/ubuntu-core-initramfs",
"SNAPD_UNPACKED_SNAP": "${CRAFT_PART_BUILD}/unpacked_snapd",
"KERNEL_BUILD_ARCH_DIR": f"${{CRAFT_PART_BUILD}}/arch/{self._kernel_arch}/boot",
"KERNEL_IMAGE_TARGET": self.kernel_image_target,
}
Expand Down
10 changes: 5 additions & 5 deletions snapcraft_legacy/plugins/v2/_kernel_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ def _download_snap_bootstrap_cmd(target_arch: str) -> List[str]:
echo "Getting snapd deb for snap bootstrap..."
# only download again if files does not exist, otherwise
# assume we are re-running build
if [ ! -e ${{SNAPD_UNPACKED_SNAP}} ]; then
download_snap_bootstrap {arch} ${{SNAPD_UNPACKED_SNAP}}
if [ ! -e ${{UC_INITRD_DEB}}/usr/lib/snapd ]; then
download_snap_bootstrap {arch} ${{UC_INITRD_DEB}}
fi
""".format(
arch=target_arch
Expand Down Expand Up @@ -709,23 +709,23 @@ def _make_initrd_cmd(
" ".join(
[
"link_files",
'"${SNAPD_UNPACKED_SNAP}"',
'"${UC_INITRD_DEB}"',
'"usr/lib/snapd/snap-bootstrap"',
'"${uc_initrd_feature_snap_bootstratp}"',
]
),
" ".join(
[
"link_files",
'"${SNAPD_UNPACKED_SNAP}"',
'"${UC_INITRD_DEB}"',
'"usr/lib/snapd/info"',
'"${uc_initrd_feature_snap_bootstratp}"',
]
),
" ".join(
[
"cp",
"${SNAPD_UNPACKED_SNAP}/usr/lib/snapd/info",
"${UC_INITRD_DEB}/usr/lib/snapd/info",
f"{install_dir}/snapd-info",
]
),
Expand Down
1 change: 0 additions & 1 deletion snapcraft_legacy/plugins/v2/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ def get_build_environment(self) -> Dict[str, str]:
"ARCH": self._kernel_arch,
"DEB_ARCH": "${SNAPCRAFT_TARGET_ARCH}",
"UC_INITRD_DEB": "${SNAPCRAFT_PART_BUILD}/ubuntu-core-initramfs",
"SNAPD_UNPACKED_SNAP": "${SNAPCRAFT_PART_BUILD}/unpacked_snapd",
"KERNEL_BUILD_ARCH_DIR": f"${{SNAPCRAFT_PART_BUILD}}/arch/{self._kernel_arch}/boot",
"KERNEL_IMAGE_TARGET": self.kernel_image_target,
}
Expand Down
17 changes: 7 additions & 10 deletions tests/legacy/unit/plugins/v2/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@ def test_check_get_build_environment(self):
"ARCH": plugin._kernel_arch,
"DEB_ARCH": "${SNAPCRAFT_TARGET_ARCH}",
"UC_INITRD_DEB": "${SNAPCRAFT_PART_BUILD}/ubuntu-core-initramfs",
"SNAPD_UNPACKED_SNAP": "${SNAPCRAFT_PART_BUILD}/unpacked_snapd",
"KERNEL_BUILD_ARCH_DIR": f"${{SNAPCRAFT_PART_BUILD}}/arch/{plugin._kernel_arch}/boot",
"KERNEL_IMAGE_TARGET": plugin.kernel_image_target,
},
Expand All @@ -524,7 +523,6 @@ def test_check_get_build_environment_compiler_paths_cross(self):
"ARCH": "arm",
"DEB_ARCH": "${SNAPCRAFT_TARGET_ARCH}",
"UC_INITRD_DEB": "${SNAPCRAFT_PART_BUILD}/ubuntu-core-initramfs",
"SNAPD_UNPACKED_SNAP": "${SNAPCRAFT_PART_BUILD}/unpacked_snapd",
"KERNEL_BUILD_ARCH_DIR": "${SNAPCRAFT_PART_BUILD}/arch/arm/boot",
"KERNEL_IMAGE_TARGET": "Image.gz",
"PATH": "${SNAPCRAFT_STAGE}/gcc-11/bin:${PATH}",
Expand All @@ -544,7 +542,6 @@ def test_check_get_build_environment_compiler_paths(self):
"ARCH": plugin._kernel_arch,
"DEB_ARCH": "${SNAPCRAFT_TARGET_ARCH}",
"UC_INITRD_DEB": "${SNAPCRAFT_PART_BUILD}/ubuntu-core-initramfs",
"SNAPD_UNPACKED_SNAP": "${SNAPCRAFT_PART_BUILD}/unpacked_snapd",
"KERNEL_BUILD_ARCH_DIR": f"${{SNAPCRAFT_PART_BUILD}}/arch/{plugin._kernel_arch}/boot",
"KERNEL_IMAGE_TARGET": plugin.kernel_image_target,
"PATH": "${SNAPCRAFT_STAGE}/gcc-11/bin:${SNAPCRAFT_STAGE}/gcc-11/sbin:${PATH}",
Expand Down Expand Up @@ -1237,8 +1234,8 @@ def _is_sub_array(array, sub_array):
echo "Getting snapd deb for snap bootstrap..."
# only download again if files does not exist, otherwise
# assume we are re-running build
if [ ! -e ${{SNAPD_UNPACKED_SNAP}} ]; then
download_snap_bootstrap {arch} ${{SNAPD_UNPACKED_SNAP}}
if [ ! -e ${{UC_INITRD_DEB}}/usr/lib/snapd ]; then
download_snap_bootstrap {arch} ${{UC_INITRD_DEB}}
fi
""".format(
arch=_DEB_ARCH_TRANSLATIONS[platform.machine()]
Expand All @@ -1252,8 +1249,8 @@ def _is_sub_array(array, sub_array):
echo "Getting snapd deb for snap bootstrap..."
# only download again if files does not exist, otherwise
# assume we are re-running build
if [ ! -e ${{SNAPD_UNPACKED_SNAP}} ]; then
download_snap_bootstrap {arch} ${{SNAPD_UNPACKED_SNAP}}
if [ ! -e ${{UC_INITRD_DEB}}/usr/lib/snapd ]; then
download_snap_bootstrap {arch} ${{UC_INITRD_DEB}}
fi
""".format(
arch="armhf"
Expand Down Expand Up @@ -1662,12 +1659,12 @@ def _is_sub_array(array, sub_array):
" ".join(
[
"link_files",
'"${SNAPD_UNPACKED_SNAP}" "usr/lib/snapd/snap-bootstrap"',
'"${UC_INITRD_DEB}" "usr/lib/snapd/snap-bootstrap"',
'"${uc_initrd_feature_snap_bootstratp}"',
],
),
'link_files "${SNAPD_UNPACKED_SNAP}" "usr/lib/snapd/info" "${uc_initrd_feature_snap_bootstratp}"',
"cp ${SNAPD_UNPACKED_SNAP}/usr/lib/snapd/info ${SNAPCRAFT_PART_INSTALL}/snapd-info",
'link_files "${UC_INITRD_DEB}" "usr/lib/snapd/info" "${uc_initrd_feature_snap_bootstratp}"',
"cp ${UC_INITRD_DEB}/usr/lib/snapd/info ${SNAPCRAFT_PART_INSTALL}/snapd-info",
]

_clean_old_initrd_cmd = [
Expand Down
17 changes: 7 additions & 10 deletions tests/unit/parts/plugins/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ def test_check_get_build_environment(self, setup_method_fixture, new_dir):
"ARCH": plugin._kernel_arch,
"DEB_ARCH": "${CRAFT_TARGET_ARCH}",
"UC_INITRD_DEB": "${CRAFT_PART_BUILD}/ubuntu-core-initramfs",
"SNAPD_UNPACKED_SNAP": "${CRAFT_PART_BUILD}/unpacked_snapd",
"KERNEL_BUILD_ARCH_DIR": f"${{CRAFT_PART_BUILD}}/arch/{plugin._kernel_arch}/boot",
"KERNEL_IMAGE_TARGET": plugin.kernel_image_target,
}
Expand All @@ -404,7 +403,6 @@ def test_check_get_build_environment_compiler_paths_cross(
"ARCH": "arm",
"DEB_ARCH": "${CRAFT_TARGET_ARCH}",
"UC_INITRD_DEB": "${CRAFT_PART_BUILD}/ubuntu-core-initramfs",
"SNAPD_UNPACKED_SNAP": "${CRAFT_PART_BUILD}/unpacked_snapd",
"KERNEL_BUILD_ARCH_DIR": "${CRAFT_PART_BUILD}/arch/arm/boot",
"KERNEL_IMAGE_TARGET": "Image.gz",
"PATH": "${CRAFT_STAGE}/gcc-11/bin:${PATH}",
Expand All @@ -426,7 +424,6 @@ def test_check_get_build_environment_compiler_paths(
"ARCH": plugin._kernel_arch,
"DEB_ARCH": "${CRAFT_TARGET_ARCH}",
"UC_INITRD_DEB": "${CRAFT_PART_BUILD}/ubuntu-core-initramfs",
"SNAPD_UNPACKED_SNAP": "${CRAFT_PART_BUILD}/unpacked_snapd",
"KERNEL_BUILD_ARCH_DIR": f"${{CRAFT_PART_BUILD}}/arch/{plugin._kernel_arch}/boot",
"KERNEL_IMAGE_TARGET": plugin.kernel_image_target,
"PATH": "${CRAFT_STAGE}/gcc-11/bin:${CRAFT_STAGE}/gcc-11/sbin:${PATH}",
Expand Down Expand Up @@ -1340,8 +1337,8 @@ def _is_sub_array(array, sub_array):
echo "Getting snapd deb for snap bootstrap..."
# only download again if files does not exist, otherwise
# assume we are re-running build
if [ ! -e ${{SNAPD_UNPACKED_SNAP}} ]; then
download_snap_bootstrap {_machine_arch} ${{SNAPD_UNPACKED_SNAP}}
if [ ! -e ${{UC_INITRD_DEB}}/usr/lib/snapd ]; then
download_snap_bootstrap {_machine_arch} ${{UC_INITRD_DEB}}
fi
"""
)
Expand All @@ -1353,8 +1350,8 @@ def _is_sub_array(array, sub_array):
echo "Getting snapd deb for snap bootstrap..."
# only download again if files does not exist, otherwise
# assume we are re-running build
if [ ! -e ${SNAPD_UNPACKED_SNAP} ]; then
download_snap_bootstrap armhf ${SNAPD_UNPACKED_SNAP}
if [ ! -e ${UC_INITRD_DEB}/usr/lib/snapd ]; then
download_snap_bootstrap armhf ${UC_INITRD_DEB}
fi
"""
)
Expand Down Expand Up @@ -1772,13 +1769,13 @@ def _is_sub_array(array, sub_array):
" ".join(
[
"link_files",
'"${SNAPD_UNPACKED_SNAP}" "usr/lib/snapd/snap-bootstrap"',
'"${UC_INITRD_DEB}" "usr/lib/snapd/snap-bootstrap"',
'"${uc_initrd_feature_snap_bootstratp}"',
],
),
'link_files "${SNAPD_UNPACKED_SNAP}" "usr/lib/snapd/info"'
'link_files "${UC_INITRD_DEB}" "usr/lib/snapd/info"'
' "${uc_initrd_feature_snap_bootstratp}"',
"cp ${SNAPD_UNPACKED_SNAP}/usr/lib/snapd/info ${CRAFT_PART_INSTALL}/snapd-info",
"cp ${UC_INITRD_DEB}/usr/lib/snapd/info ${CRAFT_PART_INSTALL}/snapd-info",
]

_clean_old_initrd_cmd = [
Expand Down

0 comments on commit 8f6333a

Please sign in to comment.