From 12c4e7c92a8909130ce9af17ef68d7383b57b1f6 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 27 Mar 2014 08:42:25 +0100 Subject: fix documentation for APT::Periodic::MaxSize "0" (closes: #740551) --- debian/apt.cron.daily | 2 +- doc/examples/configure-index | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/apt.cron.daily b/debian/apt.cron.daily index 71ac76555..d949e303a 100644 --- a/debian/apt.cron.daily +++ b/debian/apt.cron.daily @@ -41,7 +41,7 @@ # APT::Periodic::MaxSize "0"; (new) # - Set maximum size of the cache in MB (0=disable). If the cache # is bigger, cached package files are deleted until the size -# requirement is met (the biggest packages will be deleted +# requirement is met (the oldest packages will be deleted # first). # # APT::Periodic::Update-Package-Lists "0"; diff --git a/doc/examples/configure-index b/doc/examples/configure-index index 93e96cf16..020f0d2ce 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -149,7 +149,7 @@ APT MaxSize "0"; // (new) // - Set maximum size of the cache in MB (0=disable). If the cache // is bigger, cached package files are deleted until the size - // requirement is met (the biggest packages will be deleted + // requirement is met (the oldest packages will be deleted // first). Update-Package-Lists "0"; -- cgit v1.2.3 From 8d50b63f28f0d68ca72b6dc6e50e09cfec9842be Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 27 Mar 2014 10:14:30 +0100 Subject: Use mkstemp() in apt-extracttemplaes (closes: #741627) Use mkstemp() in apt-extractemplates and add a integrationtest for apt-extracttemplates too. Thanks to Steve Kemp for the report. --- cmdline/apt-extracttemplates.cc | 15 ++++++---- doc/apt-extracttemplates.1.xml | 4 +-- test/integration/framework | 1 + test/integration/test-apt-extracttemplates | 45 ++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 8 deletions(-) create mode 100755 test/integration/test-apt-extracttemplates diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc index a82623444..e4428e051 100644 --- a/cmdline/apt-extracttemplates.cc +++ b/cmdline/apt-extracttemplates.cc @@ -37,6 +37,7 @@ #include #include #include +#include #include "apt-extracttemplates.h" @@ -239,23 +240,25 @@ static int ShowHelp(void) static string WriteFile(const char *package, const char *prefix, const char *data) { char fn[512]; - static int i; std::string tempdir = GetTempDir(); - snprintf(fn, sizeof(fn), "%s/%s.%s.%u%d", + snprintf(fn, sizeof(fn), "%s/%s.%s.XXXXXX", _config->Find("APT::ExtractTemplates::TempDir", tempdir.c_str()).c_str(), - package, prefix, getpid(), i++); + package, prefix); FileFd f; if (data == NULL) data = ""; - - if (!f.Open(fn, FileFd::WriteTemp, 0600)) + int fd = mkstemp(fn); + if (fd < 0) { + _error->Errno("ofstream::ofstream",_("Unable to mkstemp %s"),fn); + return string(); + } + if (!f.OpenDescriptor(fd, FileFd::WriteOnly, FileFd::None, true)) { _error->Errno("ofstream::ofstream",_("Unable to write to %s"),fn); return string(); } - f.Write(data, strlen(data)); f.Close(); return fn; diff --git a/doc/apt-extracttemplates.1.xml b/doc/apt-extracttemplates.1.xml index d27e05075..9f9888069 100644 --- a/doc/apt-extracttemplates.1.xml +++ b/doc/apt-extracttemplates.1.xml @@ -47,8 +47,8 @@ template-file and config-script are written to the temporary directory specified by the or (APT::ExtractTemplates::TempDir) directory, - with filenames of the form package.template.XXXX and - package.config.XXXX + with filenames of the form package.template.XXXXXX and + package.config.XXXXXX options diff --git a/test/integration/framework b/test/integration/framework index 8e401cb5f..1c6f041b0 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -118,6 +118,7 @@ apt() { runapt apt "$@"; } apthelper() { runapt "${APTHELPERBINDIR}/apt-helper" "$@"; } aptwebserver() { runapt "${APTWEBSERVERBINDIR}/aptwebserver" "$@"; } aptitude() { runapt aptitude "$@"; } +aptextracttemplates() { runapt apt-extracttemplates "$@"; } dpkg() { command dpkg --root=${TMPWORKINGDIRECTORY}/rootdir --force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log "$@" diff --git a/test/integration/test-apt-extracttemplates b/test/integration/test-apt-extracttemplates new file mode 100755 index 000000000..ae2cc8bc2 --- /dev/null +++ b/test/integration/test-apt-extracttemplates @@ -0,0 +1,45 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment +configarchitecture 'amd64' + +# apt-extracttemplates needs this +insertinstalledpackage 'debconf' 'amd64' '1.5' +insertinstalledpackage 'pkg-with-template' 'amd64' '1.0' + +# build a simple package that contains a config and a tempalte +mkdir -p DEBIAN +TEMPLATE_STR="Template: foo/bar +Type: string +Description: Some bar var +" +echo "$TEMPLATE_STR" > DEBIAN/templates + +CONFIG_STR="#!/bin/sh +random shell stuff +" +echo "$CONFIG_STR" > DEBIAN/config + +buildsimplenativepackage 'pkg-with-template' 'amd64' '0.8.15' 'stable' '' 'pkg with template' '' '' './DEBIAN' + +# ensure we get the right stuff out of the file +mkdir extracttemplates-out +OUT="$(aptextracttemplates -t ./extracttemplates-out incoming/pkg-with-template*.deb)" + +PKG=$(printf "$OUT" | cut -f1 -d' ') +INSTALLED_VER=$(printf "$OUT" | cut -f2 -d' ') +TEMPLATE=$(printf "$OUT" | cut -f3 -d' ') +CONFIG=$(printf "$OUT" | cut -f4 -d' ') + +testequal "$CONFIG_STR" cat $CONFIG +testequal "$TEMPLATE_STR" cat $TEMPLATE + +# ensure that the format of the output string has the right number of dots +for s in "$CONFIG" "$TEMPLATE"; do + NR_DOTS=$(basename "$s" | tr -c -d .) + testequal ".." echo $NR_DOTS +done -- cgit v1.2.3