Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions hooks/040-remove-slices.chroot
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ rm /usr/bin/pipesz
rm /usr/bin/lslogins
rm /usr/bin/newgrp
#rm /usr/sbin/ctrlaltdel

# remove changelogs
rm -f /usr/share/doc/*/changelog.gz
rm -f /usr/share/doc/*/changelog.Debian.gz
55 changes: 49 additions & 6 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ parts:
wpasupplicant_services
)


. "$CRAFT_STAGE"/build-env
SNAP_BUILD_VARIANT=${SNAP_BUILD_VARIANT:-}
if [ "$SNAP_BUILD_VARIANT" = cloud-init ]; then
Expand All @@ -246,7 +247,11 @@ parts:
# add architecture specific slices
case "$(dpkg --print-architecture)" in
amd64|arm64)
SLICES+=(secureboot-db_services nvidia-kernel-common-595_bins nvidia-kernel-common-595_modprobe-d-kms)
SLICES+=(
secureboot-db_services
nvidia-kernel-common-595_bins
nvidia-kernel-common-595_modprobe-d-kms
)
;;
i386)
SLICES+=(secureboot-db_services)
Expand Down Expand Up @@ -276,7 +281,43 @@ parts:
libnss-mdns_mdns4-minimal libc6_libs libc6_gconv libc6_config libgcc-s1_libs
;;
esac


# Derive changelog slices from the manifest to automatically cover
# all packages, including their dependencies.
CHANGELOG_SLICES=()
python3 "${CRAFT_PROJECT_DIR}/tools/wall2dpkg.py" \
"${CRAFT_PART_INSTALL}/base/var/lib/chisel/manifest.wall" \
"${CRAFT_PART_BUILD}/dpkg-for-changelogs.yaml" 2>/dev/null || true

while IFS='= ' read -r pkg _; do
case "$pkg" in
# Skip packages known to not have a changelog slice
openssh-server |\
kmod |\
libatomic1 |\
libgcc-s1 |\
libncursesw6 |\
Comment on lines +295 to +299
libpython3.14-stdlib |\
libstdc++6 |\
openssh-sftp-server |\
p11-kit-modules)
continue ;;
esac
CHANGELOG_SLICES+=("${pkg}_changelog")
done < <(grep '^- ' "${CRAFT_PART_BUILD}/dpkg-for-changelogs.yaml" | sed 's/^- //')

# We are sure to have changelog slices, it's likely a bug if there are
# none.
if [ ${#CHANGELOG_SLICES[@]} -eq 0 ]; then
echo "No changelogs?"
exit 1
fi

chisel cut \
--release="${CRAFT_PART_SRC}" \
--root "${CRAFT_PART_INSTALL}"/base \
"${CHANGELOG_SLICES[@]}"

# https://ubuntu.com/chisel/docs/latest/reference/manifest/
# chisel automatically generates a manifest for the cut slices here:
# $rootfs/var/lib/chisel/manifest.wall
Expand Down Expand Up @@ -363,8 +404,9 @@ parts:

# Generate the dpkg.yaml for compatability purposes. Scanning tools still expect
# this file to be present, and they move slowly in terms of support for the new chisel format.
mkdir -p "${CRAFT_PART_INSTALL}/usr/share/snappy"
python3 ./tools/wall2dpkg.py "${CRAFT_STAGE}/var/lib/chisel/manifest.wall" "${CRAFT_PART_INSTALL}/usr/share/snappy/dpkg.yaml"
mkdir -p "${CRAFT_PART_BUILD}/sysroot/usr/share/snappy"
cp -avT "${CRAFT_STAGE}/base/usr/share/doc" "${CRAFT_PART_BUILD}/sysroot/usr/share/doc"
python3 ./tools/wall2dpkg.py "${CRAFT_STAGE}/var/lib/chisel/manifest.wall" "${CRAFT_PART_BUILD}/sysroot/usr/share/snappy/dpkg.yaml"

# When building through spread there is no .git, which means we cannot
# generate the changelog in this case, ensure that the current folder is
Expand All @@ -375,11 +417,12 @@ parts:
if [ -e /build/core26 ]; then
CHG_PARAMS=--launchpad
fi
mkdir -p "${CRAFT_PART_INSTALL}/usr/share/doc"
./tools/generate-changelog.py "/snap/core26/current" "${CRAFT_PART_INSTALL}" core26 $CHG_PARAMS
./tools/generate-changelog.py "/snap/core26/current" "${CRAFT_PART_BUILD}/sysroot" core26 $CHG_PARAMS
install -D "${CRAFT_PART_BUILD}/sysroot/usr/share/doc/ChangeLog" "${CRAFT_PART_INSTALL}/usr/share/doc/ChangeLog"
else
echo "WARNING: changelog will not be generated for this build"
fi
install -D "${CRAFT_PART_BUILD}/sysroot/usr/share/snappy/dpkg.yaml" "${CRAFT_PART_INSTALL}/usr/share/snappy/dpkg.yaml"

publish-artifacts-lp:
after:
Expand Down
2 changes: 1 addition & 1 deletion tools/generate-changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# to generate changelogs
pkg_allowed_list = [
'dpkg', # is removed during hook
'openssl' # contains a symlink which is broken currently
'openssl', # contains a symlink which is broken currently

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neither kmod, nor openssh-server have their slices defined. The changelog.gz is owned by a different package (e.g. openssh-client) or has no associated package ownership at all (kmod)

]

# List of packages with no valid changelog. We only have gnutls-bin for the
Expand Down
Loading