From 61159a9be93f930066ad39e4f8eb658e18853b8e Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 2 Apr 2019 17:03:04 +0200 Subject: Add test case for local-only packages pinned to never Test from the fix for the regression in trusty for LP #1821308. --- test/integration/test-policy-pinning | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/integration/test-policy-pinning b/test/integration/test-policy-pinning index 35e178871..b871f724b 100755 --- a/test/integration/test-policy-pinning +++ b/test/integration/test-policy-pinning @@ -407,7 +407,20 @@ testsuccessequal "coolstuff: 500 file:${tmppath}/aptarchive stable/main all Packages" aptcache policy coolstuff - +msgmsg "Check that local-only versions can be pinned correctly (LP: #1821308)" +echo "Package: coolstuff +Pin: version 2.0~bpo1 +Pin-Priority: 1000" > rootdir/etc/apt/preferences +testsuccessequal "coolstuff: + Installed: 2.0~bpo1 + Candidate: 2.0~bpo1 + Version table: + 2.0~bpo2 100 + 100 file:${tmppath}/aptarchive backports/main all Packages + *** 2.0~bpo1 1000 + 100 ${tmppath}/rootdir/var/lib/dpkg/status + 1.0 500 + 500 file:${tmppath}/aptarchive stable/main all Packages" aptcache policy coolstuff # Check for 0 echo "Package: coolstuff -- cgit v1.2.3 From 96aef11a5cf400377a52f7e93e70944b17e249d1 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 15 Apr 2019 11:32:50 +0200 Subject: Prevent shutdown while running dpkg As long as we are running dpkg, keep an inhibitor that blocks us from shutting down. LP: #1820886 --- CMake/FindSystemd.cmake | 24 ++++++++++++++++++++++ CMake/config.h.in | 3 +++ CMakeLists.txt | 5 +++++ apt-pkg/CMakeLists.txt | 2 ++ apt-pkg/contrib/fileutl.cc | 48 ++++++++++++++++++++++++++++++++++++++++++++ apt-pkg/contrib/fileutl.h | 2 ++ apt-pkg/deb/dpkgpm.cc | 15 ++++++++++++++ debian/control | 1 + doc/examples/configure-index | 3 +++ 9 files changed, 103 insertions(+) create mode 100644 CMake/FindSystemd.cmake diff --git a/CMake/FindSystemd.cmake b/CMake/FindSystemd.cmake new file mode 100644 index 000000000..1c7a7debf --- /dev/null +++ b/CMake/FindSystemd.cmake @@ -0,0 +1,24 @@ +# - Try to find SYSTEMD +# Once done, this will define +# +# SYSTEMD_FOUND - system has SYSTEMD +# SYSTEMD_INCLUDE_DIRS - the SYSTEMD include directories +# SYSTEMD_LIBRARIES - the SYSTEMD library +find_package(PkgConfig) + +pkg_check_modules(SYSTEMD_PKGCONF libsystemd) + +find_path(SYSTEMD_INCLUDE_DIRS + NAMES systemd/sd-bus.h + PATHS ${SYSTEMD_PKGCONF_INCLUDE_DIRS} +) + +find_library(SYSTEMD_LIBRARIES + NAMES systemd + PATHS ${SYSTEMD_PKGCONF_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Systemd DEFAULT_MSG SYSTEMD_INCLUDE_DIRS SYSTEMD_LIBRARIES) + +mark_as_advanced(SYSTEMD_INCLUDE_DIRS SYSTEMD_LIBRARIES) diff --git a/CMake/config.h.in b/CMake/config.h.in index 74d78fdb2..a9528ccfa 100644 --- a/CMake/config.h.in +++ b/CMake/config.h.in @@ -20,6 +20,9 @@ /* Define if we have the zstd library for zst */ #cmakedefine HAVE_ZSTD +/* Define if we have the systemd library */ +#cmakedefine HAVE_SYSTEMD + /* Define if we have the udev library */ #cmakedefine HAVE_UDEV diff --git a/CMakeLists.txt b/CMakeLists.txt index 60f329078..500186105 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,11 @@ if (UDEV_FOUND) set(HAVE_UDEV 1) endif() +find_package(Systemd) +if (SYSTEMD_FOUND) + set(HAVE_SYSTEMD 1) +endif() + find_package(Seccomp) if (SECCOMP_FOUND) set(HAVE_SECCOMP 1) diff --git a/apt-pkg/CMakeLists.txt b/apt-pkg/CMakeLists.txt index 64709ce34..ce73c6a34 100644 --- a/apt-pkg/CMakeLists.txt +++ b/apt-pkg/CMakeLists.txt @@ -46,6 +46,7 @@ target_include_directories(apt-pkg ${LZ4_INCLUDE_DIRS} $<$:${ZSTD_INCLUDE_DIRS}> $<$:${UDEV_INCLUDE_DIRS}> + $<$:${SYSTEMD_INCLUDE_DIRS}> ${ICONV_INCLUDE_DIRS} ) @@ -58,6 +59,7 @@ target_link_libraries(apt-pkg ${LZ4_LIBRARIES} $<$:${ZSTD_LIBRARIES}> $<$:${UDEV_LIBRARIES}> + $<$:${SYSTEMD_LIBRARIES}> ${ICONV_LIBRARIES} ) set_target_properties(apt-pkg PROPERTIES VERSION ${MAJOR}.${MINOR}) diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 0c0cb05ea..4f123491b 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -71,6 +71,9 @@ #ifdef HAVE_ZSTD #include #endif +#ifdef HAVE_SYSTEMD +#include +#endif #include #include @@ -3393,3 +3396,48 @@ bool OpenConfigurationFileFd(std::string const &File, FileFd &Fd) /*{{{*/ return true; } /*}}}*/ +int Inhibit(const char *what, const char *who, const char *why, const char *mode) /*{{{*/ +{ +#ifdef HAVE_SYSTEMD + sd_bus_error error = SD_BUS_ERROR_NULL; + sd_bus_message *m = NULL; + sd_bus *bus = NULL; + int fd; + int r; + + r = sd_bus_open_system(&bus); + if (r < 0) + goto out; + + r = sd_bus_call_method(bus, + "org.freedesktop.login1", + "/org/freedesktop/login1", + "org.freedesktop.login1.Manager", + "Inhibit", + &error, + &m, + "ssss", + what, + who, + why, + mode); + if (r < 0) + goto out; + + r = sd_bus_message_read(m, "h", &fd); + if (r < 0) + goto out; + + // We received a file descriptor, return it - systemd will close the read fd + // on free, so let's duplicate it here. + r = dup(fd); +out: + sd_bus_error_free(&error); + sd_bus_message_unref(m); + sd_bus_unref(bus); + return r; +#else + return -ENOTSUP; +#endif +} + /*}}}*/ diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 862880c31..9005b81b5 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -300,4 +300,6 @@ bool Popen(const char* Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode); APT_HIDDEN bool OpenConfigurationFileFd(std::string const &File, FileFd &Fd); +APT_HIDDEN int Inhibit(const char *what, const char *who, const char *why, const char *mode); + #endif diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 3c707e220..ffa880df2 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1463,6 +1463,21 @@ bool pkgDPkgPM::ExpandPendingCalls(std::vector &List, pkgDepCache &Cache) } bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress) { + struct Inhibitor + { + int Fd = -1; + Inhibitor() + { + if (_config->FindB("DPkg::Inhibit-Shutdown", true)) + Fd = Inhibit("shutdown", "APT", "APT is installing or removing packages", "block"); + } + ~Inhibitor() + { + if (Fd > 0) + close(Fd); + } + } inhibitor; + // explicitly remove&configure everything for hookscripts and progress building // we need them only temporarily through, so keep the length and erase afterwards decltype(List)::const_iterator::difference_type explicitIdx = diff --git a/debian/control b/debian/control index 18b38ad39..a61210127 100644 --- a/debian/control +++ b/debian/control @@ -21,6 +21,7 @@ Build-Depends: cmake (>= 3.4), liblz4-dev (>= 0.0~r126), liblzma-dev, libseccomp-dev [amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x hppa powerpc powerpcspe ppc64 x32], + libsystemd-dev [linux-any], libudev-dev [linux-any], libzstd-dev (>= 1.0), ninja-build, diff --git a/doc/examples/configure-index b/doc/examples/configure-index index 743e676de..5e317d7e0 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -503,6 +503,9 @@ DPkg progress-bg ""; progress-bar ""; }; + + // Set a shutdown block inhibitor on systemd systems while running dpkg + Inhibit-Shutdown ""; } /* Options you can set to see some debugging text They correspond to names -- cgit v1.2.3 From d409b63f0124258cb2c28dee0798520207ede57f Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 6 May 2019 10:35:28 +0200 Subject: Add linux-{buildinfo,image-unsigned,source} versioned kernel pkgs LP: #1821640 (cherry picked from commit 507124fd81066536c7c01a2039fcc6ee9f02a234) --- debian/apt.conf.autoremove | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debian/apt.conf.autoremove b/debian/apt.conf.autoremove index f7775b183..f9d9e85d4 100644 --- a/debian/apt.conf.autoremove +++ b/debian/apt.conf.autoremove @@ -17,6 +17,7 @@ APT "linux-modules"; "linux-modules-extra"; "linux-signed-image"; + "linux-image-unsigned"; # kfreebsd kernels "kfreebsd-image"; "kfreebsd-headers"; @@ -30,6 +31,10 @@ APT # tools "linux-tools"; "linux-cloud-tools"; + # build info + "linux-buildinfo"; + # source code + "linux-source"; }; Never-MarkAuto-Sections -- cgit v1.2.3 From 1444a54094f0995c44337d9b3b2850e5192215d2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 6 May 2019 10:42:00 +0200 Subject: Release 1.8.1 --- CMakeLists.txt | 2 +- debian/changelog | 9 +++++++++ doc/apt-verbatim.ent | 2 +- doc/po/apt-doc.pot | 2 +- po/apt-all.pot | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 500186105..864d7d474 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,7 +193,7 @@ check_cxx_target(HAVE_FMV_SSE42_AND_CRC32DI "sse4.2" "__builtin_ia32_crc32di(0, # Configure some variables like package, version and architecture. set(PACKAGE ${PROJECT_NAME}) set(PACKAGE_MAIL "APT Development Team ") -set(PACKAGE_VERSION "1.8.0") +set(PACKAGE_VERSION "1.8.1") if (NOT DEFINED DPKG_DATADIR) execute_process(COMMAND ${PERL_EXECUTABLE} -MDpkg -e "print $Dpkg::DATADIR;" diff --git a/debian/changelog b/debian/changelog index ea66922bf..4c6e0fa5f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +apt (1.8.1) unstable; urgency=medium + + * Add test case for local-only packages pinned to never + * Prevent shutdown while running dpkg (LP: #1820886) + * Add linux-{buildinfo,image-unsigned,source} versioned kernel pkgs + (LP: #1821640) + + -- Julian Andres Klode Mon, 06 May 2019 10:41:52 +0200 + apt (1.8.0) unstable; urgency=medium [ David Kalnischkies ] diff --git a/doc/apt-verbatim.ent b/doc/apt-verbatim.ent index c2227ad04..7e16eaab3 100644 --- a/doc/apt-verbatim.ent +++ b/doc/apt-verbatim.ent @@ -268,7 +268,7 @@ "> - + diff --git a/doc/po/apt-doc.pot b/doc/po/apt-doc.pot index 37287d045..ff243104b 100644 --- a/doc/po/apt-doc.pot +++ b/doc/po/apt-doc.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: apt-doc 1.8.0\n" "Report-Msgid-Bugs-To: APT Development Team \n" -"POT-Creation-Date: 2019-03-08 09:41+0100\n" +"POT-Creation-Date: 2019-05-06 10:41+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/po/apt-all.pot b/po/apt-all.pot index e424d23b9..bf9439d93 100644 --- a/po/apt-all.pot +++ b/po/apt-all.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: apt 1.8.0\n" "Report-Msgid-Bugs-To: APT Development Team \n" -"POT-Creation-Date: 2019-03-08 09:41+0100\n" +"POT-Creation-Date: 2019-05-06 10:41+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" -- cgit v1.2.3