public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Henning Schild <henning.schild@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Cc: Henning Schild <henning.schild@siemens.com>
Subject: [PATCH 1/2] meta: recipes-support shrink with preconfig instead of postproc
Date: Tue, 23 Jul 2019 13:42:23 +0200	[thread overview]
Message-ID: <20190723114224.22776-1-henning.schild@siemens.com> (raw)

From: Henning Schild <henning.schild@siemens.com>

This adds two support packages to shrink an image and keep it small in
case apt/dpkg will be used on the system later on.
An alternative would be postprocess functions, they would be run-once
and if the system continues to receive package updates new files will
not be cleaned up.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 .../files/isar-disable-apt-cache                   |  3 +++
 .../isar-disable-apt-cache_0.1.bb                  | 13 +++++++++++++
 .../isar-exclude-docs/files/isar-exclude-docs      | 11 +++++++++++
 .../isar-exclude-docs/files/postinst               |  7 +++++++
 .../isar-exclude-docs/isar-exclude-docs_0.1.bb     | 14 ++++++++++++++
 5 files changed, 48 insertions(+)
 create mode 100644 meta/recipes-support/isar-disable-apt-cache/files/isar-disable-apt-cache
 create mode 100644 meta/recipes-support/isar-disable-apt-cache/isar-disable-apt-cache_0.1.bb
 create mode 100644 meta/recipes-support/isar-exclude-docs/files/isar-exclude-docs
 create mode 100644 meta/recipes-support/isar-exclude-docs/files/postinst
 create mode 100644 meta/recipes-support/isar-exclude-docs/isar-exclude-docs_0.1.bb

diff --git a/meta/recipes-support/isar-disable-apt-cache/files/isar-disable-apt-cache b/meta/recipes-support/isar-disable-apt-cache/files/isar-disable-apt-cache
new file mode 100644
index 0000000..ff10041
--- /dev/null
+++ b/meta/recipes-support/isar-disable-apt-cache/files/isar-disable-apt-cache
@@ -0,0 +1,3 @@
+DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };
+APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };
+Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";
diff --git a/meta/recipes-support/isar-disable-apt-cache/isar-disable-apt-cache_0.1.bb b/meta/recipes-support/isar-disable-apt-cache/isar-disable-apt-cache_0.1.bb
new file mode 100644
index 0000000..7dbd6ed
--- /dev/null
+++ b/meta/recipes-support/isar-disable-apt-cache/isar-disable-apt-cache_0.1.bb
@@ -0,0 +1,13 @@
+# This software is a part of ISAR.
+inherit dpkg-raw
+
+DESCRIPTION = "Configuration to disable apt cache"
+MAINTAINER = "isar-users <isar-users@googlegroups.com>"
+
+SRC_URI = "file://${PN}"
+
+do_install[cleandirs] += "${D}/etc/apt/apt.conf.d/"
+
+do_install() {
+    install -v -m 644 "${WORKDIR}/${PN}" "${D}/etc/apt/apt.conf.d/99${PN}"
+}
diff --git a/meta/recipes-support/isar-exclude-docs/files/isar-exclude-docs b/meta/recipes-support/isar-exclude-docs/files/isar-exclude-docs
new file mode 100644
index 0000000..5bec626
--- /dev/null
+++ b/meta/recipes-support/isar-exclude-docs/files/isar-exclude-docs
@@ -0,0 +1,11 @@
+# Drop all man pages
+path-exclude=/usr/share/man/*
+
+# Drop all documentation ...
+path-exclude=/usr/share/doc/*
+
+# ... except copyright files ...
+path-include=/usr/share/doc/*/copyright
+
+# ... and Debian changelogs
+path-include=/usr/share/doc/*/changelog.Debian.*
diff --git a/meta/recipes-support/isar-exclude-docs/files/postinst b/meta/recipes-support/isar-exclude-docs/files/postinst
new file mode 100644
index 0000000..f6c0d1b
--- /dev/null
+++ b/meta/recipes-support/isar-exclude-docs/files/postinst
@@ -0,0 +1,7 @@
+#!/bin/sh
+# we need to do this once right after install, so we can install this at any
+# time and do not need to be "the first" package
+# what we delete needs to be in sync with the dpkg configuration we ship
+
+rm -rf /usr/share/man/*
+find /usr/share/doc/ -type f ! -name "copyright" ! -name "changelog.Debian.*" -exec rm -rf {} \;
diff --git a/meta/recipes-support/isar-exclude-docs/isar-exclude-docs_0.1.bb b/meta/recipes-support/isar-exclude-docs/isar-exclude-docs_0.1.bb
new file mode 100644
index 0000000..05c8953
--- /dev/null
+++ b/meta/recipes-support/isar-exclude-docs/isar-exclude-docs_0.1.bb
@@ -0,0 +1,14 @@
+# This software is a part of ISAR.
+inherit dpkg-raw
+
+DESCRIPTION = "Configuration to exclude most documentation"
+MAINTAINER = "isar-users <isar-users@googlegroups.com>"
+
+SRC_URI = "file://${PN} \
+	   file://postinst"
+
+do_install[cleandirs] += "${D}/etc/dpkg/dpkg.conf.d/"
+
+do_install() {
+    install -v -m 644 "${WORKDIR}/${PN}" "${D}/etc/dpkg/dpkg.conf.d/99${PN}"
+}
-- 
2.21.0


             reply	other threads:[~2019-07-23 11:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23 11:42 Henning Schild [this message]
2019-07-23 11:42 ` [PATCH 2/2] ci_build: test image shrinking packages Henning Schild
2019-07-23 12:46 ` [PATCH 1/2] meta: recipes-support shrink with preconfig instead of postproc Claudius Heine
2019-07-24  7:53   ` Henning Schild
2019-07-24  7:50 ` Henning Schild
2019-08-05  9:22 ` Baurzhan Ismagulov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190723114224.22776-1-henning.schild@siemens.com \
    --to=henning.schild@siemens.com \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox