From: Michael Vogt Date: Mon, 9 Dec 2013 10:21:14 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/feature/deb-src-bts731102' into feature/source... X-Git-Tag: 0.9.14.3.exp1~2^2~6 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/f31d34ee967cb1637c0efeb408c76a2c26bbdc07?hp=55e3b9e3ddc2a59df06e22be4efff7f72406d4ec Merge remote-tracking branch 'origin/feature/deb-src-bts731102' into feature/source-deb822 --- diff --git a/.gitignore b/.gitignore index 3e07e241b..321b15471 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,12 @@ /debian/apt-transport-https/ # generated from *.in files +/cmdline/apt-key +/doc/apt-vendor.ent /doc/examples/sources.list /debian/libapt-pkg*.install /debian/libapt-inst*.install /debian/libapt-pkg-dev.install +/vendor/current +/vendor/debian/sources.list +/vendor/ubuntu/sources.list diff --git a/Makefile b/Makefile index fb843983c..394149bf1 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ default: startup all .PHONY: headers library clean veryclean all binary program doc test update-po all headers library clean veryclean binary program doc manpages debiandoc test update-po startup dirs: + $(MAKE) -C vendor $@ $(MAKE) -C apt-pkg $@ $(MAKE) -C apt-inst $@ $(MAKE) -C apt-private $@ @@ -20,7 +21,7 @@ all headers library clean veryclean binary program doc manpages debiandoc test u $(MAKE) -C dselect $@ $(MAKE) -C doc $@ $(MAKE) -C po $@ - $(MAKE) -C test $@ + $(MAKE) -C test $@ all headers library clean veryclean binary program doc manpages debiandoc test update-po: startup dirs diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 3a6bdfe2e..7fbe4d604 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1545,6 +1545,9 @@ bool FileFd::Skip(unsigned long long Over) /* */ bool FileFd::Truncate(unsigned long long To) { + // truncating /dev/null is always successful - as we get an error otherwise + if (To == 0 && FileName == "/dev/null") + return true; #if defined HAVE_ZLIB || defined HAVE_BZ2 if (d != NULL && (d->gz != NULL || d->bz2 != NULL)) return FileFdError("Truncating compressed files is not implemented (%s)", FileName.c_str()); diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 14333c3e7..b4bfd1400 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1622,18 +1622,49 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) } // do not report out-of-memory failures - if(strstr(errormsg, strerror(ENOMEM)) != NULL) { + if(strstr(errormsg, strerror(ENOMEM)) != NULL || + strstr(errormsg, "failed to allocate memory") != NULL) { std::clog << _("No apport report written because the error message indicates a out of memory error") << std::endl; return; } - // do not report dpkg I/O errors - // XXX - this message is localized, but this only matches the English version. This is better than nothing. - if(strstr(errormsg, "short read in buffer_copy (")) { - std::clog << _("No apport report written because the error message indicates a dpkg I/O error") << std::endl; + // do not report bugs regarding inaccessible local files + if(strstr(errormsg, strerror(ENOENT)) != NULL || + strstr(errormsg, "cannot access archive") != NULL) { + std::clog << _("No apport report written because the error message indicates an issue on the local system") << std::endl; return; } + // do not report errors encountered when decompressing packages + if(strstr(errormsg, "--fsys-tarfile returned error exit status 2") != NULL) { + std::clog << _("No apport report written because the error message indicates an issue on the local system") << std::endl; + return; + } + + // do not report dpkg I/O errors, this is a format string, so we compare + // the prefix and the suffix of the error with the dpkg error message + vector io_errors; + io_errors.push_back(string("failed to read on buffer copy for %s")); + io_errors.push_back(string("failed in write on buffer copy for %s")); + io_errors.push_back(string("short read on buffer copy for %s")); + + for (vector::iterator I = io_errors.begin(); I != io_errors.end(); I++) + { + vector list = VectorizeString(dgettext("dpkg", (*I).c_str()), '%'); + if (list.size() > 1) { + // we need to split %s, VectorizeString only allows char so we need + // to kill the "s" manually + if (list[1].size() > 1) { + list[1].erase(0, 1); + if(strstr(errormsg, list[0].c_str()) && + strstr(errormsg, list[1].c_str())) { + std::clog << _("No apport report written because the error message indicates a dpkg I/O error") << std::endl; + return; + } + } + } + } + // get the pkgname and reportfile pkgname = flNotDir(pkgpath); pos = pkgname.find('_'); @@ -1721,6 +1752,24 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) if(log != NULL) { char buf[1024]; + while( fgets(buf, sizeof(buf), log) != NULL) + fprintf(report, " %s", buf); + fprintf(report, " \n"); + fclose(log); + } + } + + // attach history log it if we have it + string histfile_name = _config->FindFile("Dir::Log::History"); + if (!histfile_name.empty()) + { + FILE *log = NULL; + char buf[1024]; + + fprintf(report, "DpkgHistoryLog:\n"); + log = fopen(histfile_name.c_str(),"r"); + if(log != NULL) + { while( fgets(buf, sizeof(buf), log) != NULL) fprintf(report, " %s", buf); fclose(log); diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index 76278921f..81b601a7f 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -44,16 +44,8 @@ bool pkgInitConfig(Configuration &Cnf) Cnf.CndSet("APT::Install-Suggests", false); Cnf.CndSet("Dir","/"); - // State + // State Cnf.CndSet("Dir::State","var/lib/apt/"); - - /* Just in case something goes horribly wrong, we can fall back to the - old /var/state paths.. */ - struct stat St; - if (stat("/var/lib/apt/.",&St) != 0 && - stat("/var/state/apt/.",&St) == 0) - Cnf.CndSet("Dir::State","var/state/apt/"); - Cnf.CndSet("Dir::State::lists","lists/"); Cnf.CndSet("Dir::State::cdroms","cdroms.list"); Cnf.CndSet("Dir::State::mirrors","mirrors/"); diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 0fd237cad..99cdbe030 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -159,7 +160,6 @@ bool pkgSourceList::Type::ParseLine(vector &List, return true; } /*}}}*/ - // SourceList::pkgSourceList - Constructors /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -181,7 +181,6 @@ pkgSourceList::~pkgSourceList() delete *I; } /*}}}*/ - /*}}}*/ // SourceList::ReadMainList - Read the main source list from etc /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -216,7 +215,6 @@ bool pkgSourceList::ReadMainList() return Res; } /*}}}*/ -// CNC:2003-03-03 - Needed to preserve backwards compatibility. // SourceList::Reset - Clear the sourcelist contents /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -227,7 +225,6 @@ void pkgSourceList::Reset() SrcList.erase(SrcList.begin(),SrcList.end()); } /*}}}*/ -// CNC:2003-03-03 - Function moved to ReadAppend() and Reset(). // SourceList::Read - Parse the sourcelist file /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -241,17 +238,23 @@ bool pkgSourceList::Read(string File) // --------------------------------------------------------------------- /* */ bool pkgSourceList::ReadAppend(string File) +{ + if (_config->FindB("APT::Sources::Use-Deb822", true) == true) + if (ParseFileDeb822(File)) + return true; + return ParseFileOldStyle(File); +} + +// SourceList::ReadFileOldStyle - Read Traditional style sources.list /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool pkgSourceList::ParseFileOldStyle(string File) { // Open the stream for reading ifstream F(File.c_str(),ios::in /*| ios::nocreate*/); if (!F != 0) return _error->Errno("ifstream::ifstream",_("Opening %s"),File.c_str()); - -#if 0 // Now Reset() does this. - for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) - delete *I; - SrcList.erase(SrcList.begin(),SrcList.end()); -#endif + // CNC:2003-12-10 - 300 is too short. char Buffer[1024]; @@ -298,6 +301,73 @@ bool pkgSourceList::ReadAppend(string File) return true; } /*}}}*/ +// SourceList::ParseFileDeb822 - Parse deb822 style sources.list /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool pkgSourceList::ParseFileDeb822(string File) +{ + + pkgTagSection Tags; + map Options; + unsigned int i=0; + + // see if we can read the file + _error->PushToStack(); + FileFd Fd(File, FileFd::ReadOnly); + pkgTagFile Sources(&Fd); + if (_error->PendingError() == true) + { + _error->RevertToStack(); + return false; + } + _error->MergeWithStack(); + + // read step by step + while (Sources.Step(Tags) == true) + { + if(!Tags.Exists("Type")) + continue; + + string const type = Tags.FindS("Type"); + Type *Parse = Type::GetType(type.c_str()); + if (Parse == 0) + return _error->Error(_("Type '%s' is not known on stanza %u in source list %s"),type.c_str(),i,Fd.Name().c_str()); + + string URI = Tags.FindS("URL"); + if (!Parse->FixupURI(URI)) + return _error->Error(_("Malformed stanza %u in source list %s (URI parse)"),i,Fd.Name().c_str()); + + string Dist = Tags.FindS("Dist"); + Dist = SubstVar(Dist,"$(ARCH)",_config->Find("APT::Architecture")); + + // check if there are any options we support + const char* option_str[] = { + "arch", "arch+", "arch-", "trusted" }; + for (unsigned int j=0; j < sizeof(option_str)/sizeof(char*); j++) + if (Tags.Exists(option_str[j])) + Options[option_str[j]] = Tags.FindS(option_str[j]); + + // now create one item per section + string const Section = Tags.FindS("Section"); + std::vector list; + if (Section.find(",")) + list = StringSplit(Section, ","); + else + list = StringSplit(Section, " "); + for (std::vector::const_iterator I = list.begin(); + I != list.end(); I++) + Parse->CreateItem(SrcList, URI, Dist, (*I), Options); + + i++; + } + + // we are done + if(i>0) + return true; + + return false; +} + /*}}}*/ // SourceList::FindIndex - Get the index associated with a file /*{{{*/ // --------------------------------------------------------------------- /* */ diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h index 02e27101a..5e0d585bb 100644 --- a/apt-pkg/sourcelist.h +++ b/apt-pkg/sourcelist.h @@ -75,7 +75,10 @@ class pkgSourceList protected: std::vector SrcList; - + + bool ParseFileDeb822(std::string File); + bool ParseFileOldStyle(std::string File); + public: bool ReadMainList(); diff --git a/buildlib/po4a_manpage.mak b/buildlib/po4a_manpage.mak index 1e778cf11..b3d586b2f 100644 --- a/buildlib/po4a_manpage.mak +++ b/buildlib/po4a_manpage.mak @@ -11,7 +11,7 @@ # generate a list of accepted man page translations SOURCE = $(patsubst %.xml,%,$(wildcard *.$(LC).?.xml)) -INCLUDES = apt.ent apt-verbatim.ent +INCLUDES = apt.ent apt-verbatim.ent apt-vendor.ent manpages: @@ -29,7 +29,10 @@ clean: clean/$(LOCAL) veryclean: veryclean/$(LOCAL) apt-verbatim.ent: ../apt-verbatim.ent - cp ../apt-verbatim.ent . + cp -a ../apt-verbatim.ent . + +apt-vendor.ent: ../apt-vendor.ent + cp -a ../apt-vendor.ent . manpage-style.xsl: ../manpage-style.xsl sed "// i\ diff --git a/cmdline/apt-key b/cmdline/apt-key deleted file mode 100755 index 713a41c07..000000000 --- a/cmdline/apt-key +++ /dev/null @@ -1,336 +0,0 @@ -#!/bin/sh - -set -e -unset GREP_OPTIONS - -GPG_CMD="gpg --ignore-time-conflict --no-options --no-default-keyring" - -# gpg needs a trustdb to function, but it can't be invalid (not even empty) -# so we create a temporary directory to store our fresh readable trustdb in -TRUSTDBDIR="$(mktemp -d)" -CURRENTTRAP="${CURRENTTRAP} rm -rf '${TRUSTDBDIR}';" -trap "${CURRENTTRAP}" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM -chmod 700 "$TRUSTDBDIR" -# We also don't use a secret keyring, of course, but gpg panics and -# implodes if there isn't one available - and writeable for imports -SECRETKEYRING="${TRUSTDBDIR}/secring.gpg" -touch $SECRETKEYRING -GPG_CMD="$GPG_CMD --secret-keyring $SECRETKEYRING" -GPG_CMD="$GPG_CMD --trustdb-name ${TRUSTDBDIR}/trustdb.gpg" - -# now create the trustdb with an (empty) dummy keyring -$GPG_CMD --quiet --check-trustdb --keyring $SECRETKEYRING -# and make sure that gpg isn't trying to update the file -GPG_CMD="$GPG_CMD --no-auto-check-trustdb --trust-model always" - -GPG="$GPG_CMD" - -MASTER_KEYRING="" -#MASTER_KEYRING=/usr/share/keyrings/debian-master-keyring.gpg -eval $(apt-config shell MASTER_KEYRING APT::Key::MasterKeyring) -ARCHIVE_KEYRING_URI="" -#ARCHIVE_KEYRING_URI=http://ftp.debian.org/debian/debian-archive-keyring.gpg -eval $(apt-config shell ARCHIVE_KEYRING_URI APT::Key::ArchiveKeyringURI) - -ARCHIVE_KEYRING=/usr/share/keyrings/debian-archive-keyring.gpg -eval $(apt-config shell ARCHIVE_KEYRING APT::Key::ArchiveKeyring) -REMOVED_KEYS=/usr/share/keyrings/debian-archive-removed-keys.gpg -eval $(apt-config shell REMOVED_KEYS APT::Key::RemovedKeys) - -requires_root() { - if [ "$(id -u)" -ne 0 ]; then - echo >&1 "ERROR: This command can only be used by root." - exit 1 - fi -} - -# gpg defaults to mode 0600 for new keyrings. Create one with 0644 instead. -init_keyring() { - for path; do - if ! [ -e "$path" ]; then - touch -- "$path" - chmod 0644 -- "$path" - fi - done -} - -add_keys_with_verify_against_master_keyring() { - ADD_KEYRING=$1 - MASTER=$2 - - if [ ! -f "$ADD_KEYRING" ]; then - echo "ERROR: '$ADD_KEYRING' not found" - return - fi - if [ ! -f "$MASTER" ]; then - echo "ERROR: '$MASTER' not found" - return - fi - - # when adding new keys, make sure that the archive-master-keyring - # is honored. so: - # all keys that are exported must have a valid signature - # from a key in the $distro-master-keyring - add_keys=`$GPG_CMD --keyring $ADD_KEYRING --with-colons --list-keys | grep ^pub | cut -d: -f5` - master_keys=`$GPG_CMD --keyring $MASTER --with-colons --list-keys | grep ^pub | cut -d: -f5` - for add_key in $add_keys; do - ADDED=0 - for master_key in $master_keys; do - if $GPG_CMD --keyring $ADD_KEYRING --list-sigs --with-colons $add_key | grep ^sig | cut -d: -f5 | grep -q $master_key; then - $GPG_CMD --quiet --batch --keyring $ADD_KEYRING --export $add_key | $GPG --import - ADDED=1 - fi - done - if [ $ADDED = 0 ]; then - echo >&2 "Key '$add_key' not added. It is not signed with a master key" - fi - done -} - -# update the current archive signing keyring from a network URI -# the archive-keyring keys needs to be signed with the master key -# (otherwise it does not make sense from a security POV) -net_update() { - if [ -z "$ARCHIVE_KEYRING_URI" ]; then - echo >&2 "ERROR: Your distribution is not supported in net-update as no uri for the archive-keyring is set" - exit 1 - fi - requires_root - # in theory we would need to depend on wget for this, but this feature - # isn't useable in debian anyway as we have no keyring uri nor a master key - if ! which wget >/dev/null 2>&1; then - echo >&2 "ERROR: an installed wget is required for a network-based update" - exit 1 - fi - if [ ! -d /var/lib/apt/keyrings ]; then - mkdir -p /var/lib/apt/keyrings - fi - keyring=/var/lib/apt/keyrings/$(basename $ARCHIVE_KEYRING) - old_mtime=0 - if [ -e $keyring ]; then - old_mtime=$(stat -c %Y $keyring) - fi - (cd /var/lib/apt/keyrings; wget -q -N $ARCHIVE_KEYRING_URI) - if [ ! -e $keyring ]; then - return - fi - new_mtime=$(stat -c %Y $keyring) - if [ $new_mtime -ne $old_mtime ]; then - echo "Checking for new archive signing keys now" - add_keys_with_verify_against_master_keyring $keyring $MASTER_KEYRING - fi -} - -update() { - if [ ! -f $ARCHIVE_KEYRING ]; then - echo >&2 "ERROR: Can't find the archive-keyring" - echo >&2 "Is the debian-archive-keyring package installed?" - exit 1 - fi - requires_root - - # add new keys from the package; - - # we do not use add_keys_with_verify_against_master_keyring here, - # because "update" is run on regular package updates. A - # attacker might as well replace the master-archive-keyring file - # in the package and add his own keys. so this check wouldn't - # add any security. we *need* this check on net-update though - $GPG_CMD --quiet --batch --keyring $ARCHIVE_KEYRING --export | $GPG --import - - if [ -r "$REMOVED_KEYS" ]; then - # remove no-longer supported/used keys - keys=`$GPG_CMD --keyring $REMOVED_KEYS --with-colons --list-keys | grep ^pub | cut -d: -f5` - for key in $keys; do - if $GPG --list-keys --with-colons | grep ^pub | cut -d: -f5 | grep -q $key; then - $GPG --quiet --batch --delete-key --yes ${key} - fi - done - else - echo "Warning: removed keys keyring $REMOVED_KEYS missing or not readable" >&2 - fi -} - -remove_key_from_keyring() { - local GPG="$GPG_CMD --keyring $1" - # check if the key is in this keyring: the key id is in the 5 column at the end - if ! $GPG --with-colons --list-keys 2>&1 | grep -q "^pub:[^:]*:[^:]*:[^:]*:[0-9A-F]\+$2:"; then - return - fi - if [ ! -w "$1" ]; then - echo >&2 "Key ${2} is in keyring ${1}, but can't be removed as it is read only." - return - fi - # check if it is the only key in the keyring and if so remove the keyring alltogether - if [ '1' = "$($GPG --with-colons --list-keys | grep "^pub:[^:]*:[^:]*:[^:]*:[0-9A-F]\+:" | wc -l)" ]; then - mv -f "$1" "${1}~" # behave like gpg - return - fi - # we can't just modify pointed to files as these might be in /usr or something - local REALTARGET - if [ -L "$1" ]; then - REALTARGET="$(readlink -f "$1")" - mv -f "$1" "${1}.dpkg-tmp" - cp -a "$REALTARGET" "$1" - ls "$(dirname $1)" - fi - # delete the key from the keyring - $GPG --batch --delete-key --yes "$2" - if [ -n "$REALTARGET" ]; then - # the real backup is the old link, not the copy we made - mv -f "${1}.dpkg-tmp" "${1}~" - fi -} - -remove_key() { - requires_root - - # if a --keyring was given, just remove from there - if [ -n "$FORCED_KEYRING" ]; then - remove_key_from_keyring "$FORCED_KEYRING" "$1" - else - # otherwise all known keyrings are up for inspection - local TRUSTEDFILE="/etc/apt/trusted.gpg" - eval $(apt-config shell TRUSTEDFILE Apt::GPGV::TrustedKeyring) - eval $(apt-config shell TRUSTEDFILE Dir::Etc::Trusted/f) - remove_key_from_keyring "$TRUSTEDFILE" "$1" - TRUSTEDPARTS="/etc/apt/trusted.gpg.d" - eval $(apt-config shell TRUSTEDPARTS Dir::Etc::TrustedParts/d) - if [ -d "$TRUSTEDPARTS" ]; then - for trusted in $(run-parts --list "$TRUSTEDPARTS" --regex '^.*\.gpg$'); do - remove_key_from_keyring "$trusted" "$1" - done - fi - fi - echo "OK" -} - - -usage() { - echo "Usage: apt-key [--keyring file] [command] [arguments]" - echo - echo "Manage apt's list of trusted keys" - echo - echo " apt-key add - add the key contained in ('-' for stdin)" - echo " apt-key del - remove the key " - echo " apt-key export - output the key " - echo " apt-key exportall - output all trusted keys" - echo " apt-key update - update keys using the keyring package" - echo " apt-key net-update - update keys using the network" - echo " apt-key list - list keys" - echo " apt-key finger - list fingerprints" - echo " apt-key adv - pass advanced options to gpg (download key)" - echo - echo "If no specific keyring file is given the command applies to all keyring files." -} - -while [ -n "$1" ]; do - case "$1" in - --keyring) - shift - TRUSTEDFILE="$1" - FORCED_KEYRING="$1" - if [ -r "$TRUSTEDFILE" ] || [ "$2" = 'add' ] || [ "$2" = 'adv' ]; then - GPG="$GPG --keyring $TRUSTEDFILE --primary-keyring $TRUSTEDFILE" - else - echo >&2 "Error: The specified keyring »$TRUSTEDFILE« is missing or not readable" - exit 1 - fi - shift - ;; - --fakeroot) - requires_root() { true; } - shift - ;; - --*) - echo >&2 "Unknown option: $1" - usage - exit 1;; - *) - break;; - esac -done - -if [ -z "$TRUSTEDFILE" ]; then - TRUSTEDFILE="/etc/apt/trusted.gpg" - eval $(apt-config shell TRUSTEDFILE Apt::GPGV::TrustedKeyring) - eval $(apt-config shell TRUSTEDFILE Dir::Etc::Trusted/f) - if [ -r "$TRUSTEDFILE" ]; then - GPG="$GPG --keyring $TRUSTEDFILE" - fi - GPG="$GPG --primary-keyring $TRUSTEDFILE" - TRUSTEDPARTS="/etc/apt/trusted.gpg.d" - eval $(apt-config shell TRUSTEDPARTS Dir::Etc::TrustedParts/d) - if [ -d "$TRUSTEDPARTS" ]; then - # strip / suffix as gpg will double-slash in that case (#665411) - STRIPPED_TRUSTEDPARTS="${TRUSTEDPARTS%/}" - if [ "${STRIPPED_TRUSTEDPARTS}/" = "$TRUSTEDPARTS" ]; then - TRUSTEDPARTS="$STRIPPED_TRUSTEDPARTS" - fi - for trusted in $(run-parts --list "$TRUSTEDPARTS" --regex '^.*\.gpg$'); do - GPG="$GPG --keyring $trusted" - done - fi -fi - -command="$1" -if [ -z "$command" ]; then - usage - exit 1 -fi -shift - -if [ "$command" != "help" ] && ! which gpg >/dev/null 2>&1; then - echo >&2 "Warning: gnupg does not seem to be installed." - echo >&2 "Warning: apt-key requires gnupg for most operations." - echo >&2 -fi - -case "$command" in - add) - requires_root - init_keyring "$TRUSTEDFILE" - $GPG --quiet --batch --import "$1" - echo "OK" - ;; - del|rm|remove) - init_keyring "$TRUSTEDFILE" - remove_key "$1" - ;; - update) - init_keyring "$TRUSTEDFILE" - update - ;; - net-update) - init_keyring "$TRUSTEDFILE" - net_update - ;; - list) - init_keyring "$TRUSTEDFILE" - $GPG --batch --list-keys - ;; - finger*) - init_keyring "$TRUSTEDFILE" - $GPG --batch --fingerprint - ;; - export) - init_keyring "$TRUSTEDFILE" - $GPG --armor --export "$1" - ;; - exportall) - init_keyring "$TRUSTEDFILE" - $GPG --armor --export - ;; - adv*) - init_keyring "$TRUSTEDFILE" - echo "Executing: $GPG $*" - $GPG $* - ;; - help) - usage - ;; - *) - usage - exit 1 - ;; -esac diff --git a/cmdline/apt-key.in b/cmdline/apt-key.in new file mode 100644 index 000000000..779872b4c --- /dev/null +++ b/cmdline/apt-key.in @@ -0,0 +1,354 @@ +#!/bin/sh + +set -e +unset GREP_OPTIONS + +GPG_CMD="gpg --ignore-time-conflict --no-options --no-default-keyring" + +# gpg needs a trustdb to function, but it can't be invalid (not even empty) +# so we create a temporary directory to store our fresh readable trustdb in +TRUSTDBDIR="$(mktemp -d)" +CURRENTTRAP="${CURRENTTRAP} rm -rf '${TRUSTDBDIR}';" +trap "${CURRENTTRAP}" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM +chmod 700 "$TRUSTDBDIR" +# We also don't use a secret keyring, of course, but gpg panics and +# implodes if there isn't one available - and writeable for imports +SECRETKEYRING="${TRUSTDBDIR}/secring.gpg" +touch $SECRETKEYRING +GPG_CMD="$GPG_CMD --secret-keyring $SECRETKEYRING" +GPG_CMD="$GPG_CMD --trustdb-name ${TRUSTDBDIR}/trustdb.gpg" + +# now create the trustdb with an (empty) dummy keyring +$GPG_CMD --quiet --check-trustdb --keyring $SECRETKEYRING +# and make sure that gpg isn't trying to update the file +GPG_CMD="$GPG_CMD --no-auto-check-trustdb --trust-model always" + +GPG="$GPG_CMD" + +MASTER_KEYRING='&keyring-master-filename;' +eval $(apt-config shell MASTER_KEYRING APT::Key::MasterKeyring) +ARCHIVE_KEYRING='&keyring-filename;' +eval $(apt-config shell ARCHIVE_KEYRING APT::Key::ArchiveKeyring) +REMOVED_KEYS='&keyring-removed-filename;' +eval $(apt-config shell REMOVED_KEYS APT::Key::RemovedKeys) +ARCHIVE_KEYRING_URI='&keyring-uri;' +eval $(apt-config shell ARCHIVE_KEYRING_URI APT::Key::ArchiveKeyringURI) +TMP_KEYRING=/var/lib/apt/keyrings/maybe-import-keyring.gpg + +requires_root() { + if [ "$(id -u)" -ne 0 ]; then + echo >&1 "ERROR: This command can only be used by root." + exit 1 + fi +} + +# gpg defaults to mode 0600 for new keyrings. Create one with 0644 instead. +init_keyring() { + for path; do + if ! [ -e "$path" ]; then + touch -- "$path" + chmod 0644 -- "$path" + fi + done +} + +add_keys_with_verify_against_master_keyring() { + ADD_KEYRING=$1 + MASTER=$2 + + if [ ! -f "$ADD_KEYRING" ]; then + echo "ERROR: '$ADD_KEYRING' not found" + return + fi + if [ ! -f "$MASTER" ]; then + echo "ERROR: '$MASTER' not found" + return + fi + + # when adding new keys, make sure that the archive-master-keyring + # is honored. so: + # all keys that are exported must have a valid signature + # from a key in the $distro-master-keyring + add_keys=`$GPG_CMD --keyring $ADD_KEYRING --with-colons --list-keys | grep ^pub | cut -d: -f5` + all_add_keys=`$GPG_CMD --keyring $ADD_KEYRING --with-colons --list-keys | grep ^[ps]ub | cut -d: -f5` + master_keys=`$GPG_CMD --keyring $MASTER --with-colons --list-keys | grep ^pub | cut -d: -f5` + + # ensure there are no colisions LP: #857472 + for all_add_key in $all_add_keys; do + for master_key in $master_keys; do + if [ "$all_add_key" = "$master_key" ]; then + echo >&2 "Keyid collision for '$all_add_key' detected, operation aborted" + return 1 + fi + done + done + + for add_key in $add_keys; do + # export the add keyring one-by-one + rm -f $TMP_KEYRING + $GPG_CMD --keyring $ADD_KEYRING --output $TMP_KEYRING --export $add_key + # check if signed with the master key and only add in this case + ADDED=0 + for master_key in $master_keys; do + if $GPG_CMD --keyring $MASTER --keyring $TMP_KEYRING --check-sigs --with-colons $add_key | grep '^sig:!:' | cut -d: -f5 | grep -q $master_key; then + $GPG --import $TMP_KEYRING + ADDED=1 + fi + done + if [ $ADDED = 0 ]; then + echo >&2 "Key '$add_key' not added. It is not signed with a master key" + fi + done + rm -f $TMP_KEYRING +} + +# update the current archive signing keyring from a network URI +# the archive-keyring keys needs to be signed with the master key +# (otherwise it does not make sense from a security POV) +net_update() { + # Disabled for now as code is insecure (LP: #1013639 (and 857472, 1013128)) + exit 1 + + if [ -z "$ARCHIVE_KEYRING_URI" ]; then + echo >&2 "ERROR: Your distribution is not supported in net-update as no uri for the archive-keyring is set" + exit 1 + fi + requires_root + # in theory we would need to depend on wget for this, but this feature + # isn't useable in debian anyway as we have no keyring uri nor a master key + if ! which wget >/dev/null 2>&1; then + echo >&2 "ERROR: an installed wget is required for a network-based update" + exit 1 + fi + if [ ! -d /var/lib/apt/keyrings ]; then + mkdir -p /var/lib/apt/keyrings + fi + keyring=/var/lib/apt/keyrings/$(basename $ARCHIVE_KEYRING) + old_mtime=0 + if [ -e $keyring ]; then + old_mtime=$(stat -c %Y $keyring) + fi + (cd /var/lib/apt/keyrings; wget --timeout=90 -q -N $ARCHIVE_KEYRING_URI) + if [ ! -e $keyring ]; then + return + fi + new_mtime=$(stat -c %Y $keyring) + if [ $new_mtime -ne $old_mtime ]; then + echo "Checking for new archive signing keys now" + add_keys_with_verify_against_master_keyring $keyring $MASTER_KEYRING + fi +} + +update() { + if [ ! -f $ARCHIVE_KEYRING ]; then + echo >&2 "ERROR: Can't find the archive-keyring" + echo >&2 "Is the &keyring-package; package installed?" + exit 1 + fi + requires_root + + # add new keys from the package; + + # we do not use add_keys_with_verify_against_master_keyring here, + # because "update" is run on regular package updates. A + # attacker might as well replace the master-archive-keyring file + # in the package and add his own keys. so this check wouldn't + # add any security. we *need* this check on net-update though + $GPG_CMD --quiet --batch --keyring $ARCHIVE_KEYRING --export | $GPG --import + + if [ -r "$REMOVED_KEYS" ]; then + # remove no-longer supported/used keys + keys=`$GPG_CMD --keyring $REMOVED_KEYS --with-colons --list-keys | grep ^pub | cut -d: -f5` + for key in $keys; do + if $GPG --list-keys --with-colons | grep ^pub | cut -d: -f5 | grep -q $key; then + $GPG --quiet --batch --delete-key --yes ${key} + fi + done + else + echo "Warning: removed keys keyring $REMOVED_KEYS missing or not readable" >&2 + fi +} + +remove_key_from_keyring() { + local GPG="$GPG_CMD --keyring $1" + # check if the key is in this keyring: the key id is in the 5 column at the end + if ! $GPG --with-colons --list-keys 2>&1 | grep -q "^pub:[^:]*:[^:]*:[^:]*:[0-9A-F]\+$2:"; then + return + fi + if [ ! -w "$1" ]; then + echo >&2 "Key ${2} is in keyring ${1}, but can't be removed as it is read only." + return + fi + # check if it is the only key in the keyring and if so remove the keyring alltogether + if [ '1' = "$($GPG --with-colons --list-keys | grep "^pub:[^:]*:[^:]*:[^:]*:[0-9A-F]\+:" | wc -l)" ]; then + mv -f "$1" "${1}~" # behave like gpg + return + fi + # we can't just modify pointed to files as these might be in /usr or something + local REALTARGET + if [ -L "$1" ]; then + REALTARGET="$(readlink -f "$1")" + mv -f "$1" "${1}.dpkg-tmp" + cp -a "$REALTARGET" "$1" + ls "$(dirname $1)" + fi + # delete the key from the keyring + $GPG --batch --delete-key --yes "$2" + if [ -n "$REALTARGET" ]; then + # the real backup is the old link, not the copy we made + mv -f "${1}.dpkg-tmp" "${1}~" + fi +} + +remove_key() { + requires_root + + # if a --keyring was given, just remove from there + if [ -n "$FORCED_KEYRING" ]; then + remove_key_from_keyring "$FORCED_KEYRING" "$1" + else + # otherwise all known keyrings are up for inspection + local TRUSTEDFILE="/etc/apt/trusted.gpg" + eval $(apt-config shell TRUSTEDFILE Apt::GPGV::TrustedKeyring) + eval $(apt-config shell TRUSTEDFILE Dir::Etc::Trusted/f) + remove_key_from_keyring "$TRUSTEDFILE" "$1" + TRUSTEDPARTS="/etc/apt/trusted.gpg.d" + eval $(apt-config shell TRUSTEDPARTS Dir::Etc::TrustedParts/d) + if [ -d "$TRUSTEDPARTS" ]; then + for trusted in $(run-parts --list "$TRUSTEDPARTS" --regex '^.*\.gpg$'); do + remove_key_from_keyring "$trusted" "$1" + done + fi + fi + echo "OK" +} + + +usage() { + echo "Usage: apt-key [--keyring file] [command] [arguments]" + echo + echo "Manage apt's list of trusted keys" + echo + echo " apt-key add - add the key contained in ('-' for stdin)" + echo " apt-key del - remove the key " + echo " apt-key export - output the key " + echo " apt-key exportall - output all trusted keys" + echo " apt-key update - update keys using the keyring package" + echo " apt-key net-update - update keys using the network" + echo " apt-key list - list keys" + echo " apt-key finger - list fingerprints" + echo " apt-key adv - pass advanced options to gpg (download key)" + echo + echo "If no specific keyring file is given the command applies to all keyring files." +} + +while [ -n "$1" ]; do + case "$1" in + --keyring) + shift + TRUSTEDFILE="$1" + FORCED_KEYRING="$1" + if [ -r "$TRUSTEDFILE" ] || [ "$2" = 'add' ] || [ "$2" = 'adv' ]; then + GPG="$GPG --keyring $TRUSTEDFILE --primary-keyring $TRUSTEDFILE" + else + echo >&2 "Error: The specified keyring »$TRUSTEDFILE« is missing or not readable" + exit 1 + fi + shift + ;; + --fakeroot) + requires_root() { true; } + shift + ;; + --*) + echo >&2 "Unknown option: $1" + usage + exit 1;; + *) + break;; + esac +done + +if [ -z "$TRUSTEDFILE" ]; then + TRUSTEDFILE="/etc/apt/trusted.gpg" + eval $(apt-config shell TRUSTEDFILE Apt::GPGV::TrustedKeyring) + eval $(apt-config shell TRUSTEDFILE Dir::Etc::Trusted/f) + if [ -r "$TRUSTEDFILE" ]; then + GPG="$GPG --keyring $TRUSTEDFILE" + fi + GPG="$GPG --primary-keyring $TRUSTEDFILE" + TRUSTEDPARTS="/etc/apt/trusted.gpg.d" + eval $(apt-config shell TRUSTEDPARTS Dir::Etc::TrustedParts/d) + if [ -d "$TRUSTEDPARTS" ]; then + # strip / suffix as gpg will double-slash in that case (#665411) + STRIPPED_TRUSTEDPARTS="${TRUSTEDPARTS%/}" + if [ "${STRIPPED_TRUSTEDPARTS}/" = "$TRUSTEDPARTS" ]; then + TRUSTEDPARTS="$STRIPPED_TRUSTEDPARTS" + fi + for trusted in $(run-parts --list "$TRUSTEDPARTS" --regex '^.*\.gpg$'); do + GPG="$GPG --keyring $trusted" + done + fi +fi + +command="$1" +if [ -z "$command" ]; then + usage + exit 1 +fi +shift + +if [ "$command" != "help" ] && ! which gpg >/dev/null 2>&1; then + echo >&2 "Warning: gnupg does not seem to be installed." + echo >&2 "Warning: apt-key requires gnupg for most operations." + echo >&2 +fi + +case "$command" in + add) + requires_root + init_keyring "$TRUSTEDFILE" + $GPG --quiet --batch --import "$1" + echo "OK" + ;; + del|rm|remove) + init_keyring "$TRUSTEDFILE" + remove_key "$1" + ;; + update) + init_keyring "$TRUSTEDFILE" + update + ;; + net-update) + init_keyring "$TRUSTEDFILE" + net_update + ;; + list) + init_keyring "$TRUSTEDFILE" + $GPG --batch --list-keys + ;; + finger*) + init_keyring "$TRUSTEDFILE" + $GPG --batch --fingerprint + ;; + export) + init_keyring "$TRUSTEDFILE" + $GPG --armor --export "$1" + ;; + exportall) + init_keyring "$TRUSTEDFILE" + $GPG --armor --export + ;; + adv*) + init_keyring "$TRUSTEDFILE" + echo "Executing: $GPG $*" + $GPG $* + ;; + help) + usage + ;; + *) + usage + exit 1 + ;; +esac diff --git a/cmdline/makefile b/cmdline/makefile index e77ad5669..06f170b6a 100644 --- a/cmdline/makefile +++ b/cmdline/makefile @@ -41,6 +41,14 @@ SOURCE = apt-cdrom.cc include $(PROGRAM_H) # The apt-key program +apt-key: apt-key.in + sed -e "s#&keyring-filename;#$(shell ../vendor/getinfo keyring-filename)#" \ + -e "s#&keyring-removed-filename;#$(shell ../vendor/getinfo keyring-removed-filename)#" \ + -e "s#&keyring-master-filename;#$(shell ../vendor/getinfo keyring-master-filename)#" \ + -e "s#&keyring-uri;#$(shell ../vendor/getinfo keyring-uri)#" \ + -e "s#&keyring-package;#$(shell ../vendor/getinfo keyring-package)#" $< > $@ + chmod 755 $@ + SOURCE=apt-key TO=$(BIN) TARGET=program diff --git a/debian/control b/debian/control index 84d6155a6..c70d0e9ea 100644 --- a/debian/control +++ b/debian/control @@ -17,7 +17,7 @@ XS-Testsuite: autopkgtest Package: apt Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, debian-archive-keyring, gnupg +Depends: ${shlibs:Depends}, ${misc:Depends}, ${apt:keyring}, gnupg Replaces: manpages-pl (<< 20060617-3~), manpages-it (<< 2.80-4~) Breaks: manpages-pl (<< 20060617-3~), manpages-it (<< 2.80-4~) Conflicts: python-apt (<< 0.7.93.2~) diff --git a/debian/preinst b/debian/preinst deleted file mode 100755 index 985ad9b84..000000000 --- a/debian/preinst +++ /dev/null @@ -1,32 +0,0 @@ -#! /bin/sh - -set -e - -# dpkg does this for us while we are upgrading.. -#if [ "$1" = "upgrade" -a -L /var/state/apt -a -e /var/lib/apt -a ! -L /var/state/apt ] && dpkg --compare-versions "$2" ">=" "0.4.10"; then -# rm /var/state/apt -#fi - -if [ "$1" = "upgrade" -o "$1" = "install" -a "$2" != "" ]; then - if [ ! -e /var/lib/apt -a -e /var/state/apt ]; then - # upgrading from /var/state/apt using apt. - # it's probably running now so we want to ensure /var/state/apt - # is still valid afterwards. and since we're upgrading - - if [ -x /usr/bin/perl -a -d /var/state/apt -a ! -L /var/state/apt ] && - perl -e 'exit 1 if ((stat("/var/lib"))[0] != (stat("/var/state/apt"))[0])' - then - # same fs, we can mv it - mv /var/state/apt /var/lib/apt - ln -s ../lib/apt /var/state/apt - # note that this symlink (/var/state/apt) will be removed when - # dpkg finishes unpacking the apt we're about to install; this is okay - else - # scary, let's just symlink it and hope - ln -s /var/state/apt /var/lib/apt - fi - fi - touch /var/lib/apt/lists/partial/.delete-me-later || true -fi - -#DEBHELPER# diff --git a/debian/rules b/debian/rules index 06ccdac31..f4f7ec06b 100755 --- a/debian/rules +++ b/debian/rules @@ -3,6 +3,9 @@ # Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. # Some lines taken from debmake, by Christoph Lameter. +# build in verbose mode by default to make it easy to diangose issues +export NOISY=1 + export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) @@ -216,7 +219,7 @@ apt: build-binary build-manpages debian/apt.install dh_fixperms -p$@ dh_installdeb -p$@ dh_shlibdeps -p$@ - dh_gencontrol -p$@ + dh_gencontrol -p$@ -- -Vapt:keyring="$(shell ./vendor/getinfo keyring-package)" dh_md5sums -p$@ dh_builddeb -p$@ diff --git a/doc/apt-cache.8.xml b/doc/apt-cache.8.xml index 0955c1c9e..a53a64446 100644 --- a/doc/apt-cache.8.xml +++ b/doc/apt-cache.8.xml @@ -8,6 +8,8 @@ %aptverbatiment; + +%aptvendor; ]> diff --git a/doc/apt-cdrom.8.xml b/doc/apt-cdrom.8.xml index b076a98a3..2fcd8e494 100644 --- a/doc/apt-cdrom.8.xml +++ b/doc/apt-cdrom.8.xml @@ -8,6 +8,8 @@ %aptverbatiment; + +%aptvendor; ]> diff --git a/doc/apt-config.8.xml b/doc/apt-config.8.xml index 39205e737..b84d25f7a 100644 --- a/doc/apt-config.8.xml +++ b/doc/apt-config.8.xml @@ -8,6 +8,8 @@ %aptverbatiment; + +%aptvendor; ]> diff --git a/doc/apt-extracttemplates.1.xml b/doc/apt-extracttemplates.1.xml index 4374c5ec3..d27e05075 100644 --- a/doc/apt-extracttemplates.1.xml +++ b/doc/apt-extracttemplates.1.xml @@ -8,6 +8,8 @@ %aptverbatiment; + +%aptvendor; ]> diff --git a/doc/apt-ftparchive.1.xml b/doc/apt-ftparchive.1.xml index 91fdfe1e0..6482b4632 100644 --- a/doc/apt-ftparchive.1.xml +++ b/doc/apt-ftparchive.1.xml @@ -8,6 +8,8 @@ %aptverbatiment; + +%aptvendor; ]> diff --git a/doc/apt-get.8.xml b/doc/apt-get.8.xml index 4c050ec03..b97bc268e 100644 --- a/doc/apt-get.8.xml +++ b/doc/apt-get.8.xml @@ -8,6 +8,8 @@ %aptverbatiment; + +%aptvendor; ]> @@ -526,7 +528,7 @@ terminal window when packages are installed, upgraded or removed. For a machine parsable version of this data see README.progress-reporting in the apt doc directory. - DpkgPM::Progress. + Configuration Item: DpkgPM::Progress and Dpkg::Progress-Fancy. diff --git a/doc/apt-key.8.xml b/doc/apt-key.8.xml index 6a36d08ca..5dbbaaf26 100644 --- a/doc/apt-key.8.xml +++ b/doc/apt-key.8.xml @@ -8,6 +8,8 @@ %aptverbatiment; + +%aptvendor; ]> @@ -130,7 +132,7 @@ Update the local keyring with the archive keyring and remove from the local keyring the archive keys which are no longer valid. The archive keyring is shipped in the archive-keyring package of your - distribution, e.g. the debian-archive-keyring package in Debian. + distribution, e.g. the &keyring-package; package in &keyring-distro;. @@ -180,12 +182,12 @@ Local trust database of archive keys. - /usr/share/keyrings/debian-archive-keyring.gpg - Keyring of Debian archive trusted keys. + &keyring-filename; + Keyring of &keyring-distro; archive trusted keys. - /usr/share/keyrings/debian-archive-removed-keys.gpg - Keyring of Debian archive removed trusted keys. + &keyring-removed-filename; + Keyring of &keyring-distro; archive removed trusted keys. diff --git a/doc/apt-mark.8.xml b/doc/apt-mark.8.xml index 3503ece8f..d00e5b9e2 100644 --- a/doc/apt-mark.8.xml +++ b/doc/apt-mark.8.xml @@ -8,6 +8,8 @@ %aptverbatiment; + +%aptvendor; ]> diff --git a/doc/apt-secure.8.xml b/doc/apt-secure.8.xml index 8cdfe3ab6..981351615 100644 --- a/doc/apt-secure.8.xml +++ b/doc/apt-secure.8.xml @@ -8,6 +8,8 @@ %aptverbatiment; + +%aptvendor; ]> @@ -103,10 +105,10 @@ the maintainer signature is stripped off, and checksums of the package are computed and put in the Packages file. The checksums of all of the Packages files are then computed and put into the Release file. The - Release file is then signed by the archive key for this Debian release, + Release file is then signed by the archive key for this &keyring-distro; release, and distributed alongside the packages and the Packages files on - Debian mirrors. The keys are in the Debian archive keyring available in - the debian-archive-keyring package. + &keyring-distro; mirrors. The keys are in the &keyring-distro; archive keyring + available in the &keyring-package; package. diff --git a/doc/apt-sortpkgs.1.xml b/doc/apt-sortpkgs.1.xml index 482035b37..9bb03d624 100644 --- a/doc/apt-sortpkgs.1.xml +++ b/doc/apt-sortpkgs.1.xml @@ -8,6 +8,8 @@ %aptverbatiment; + +%aptvendor; ]> diff --git a/doc/apt-verbatim.ent b/doc/apt-verbatim.ent index 0d0d95c7a..30b0c7fe0 100644 --- a/doc/apt-verbatim.ent +++ b/doc/apt-verbatim.ent @@ -221,11 +221,11 @@ - + - + + +debian-archive-keyring"> +/usr/share/keyrings/debian-archive-keyring.gpg"> +/usr/share/keyrings/debian-archive-removed-keys.gpg"> + + diff --git a/vendor/debian/makefile b/vendor/debian/makefile new file mode 100644 index 000000000..dd35a70f0 --- /dev/null +++ b/vendor/debian/makefile @@ -0,0 +1,11 @@ +# -*- make -*- +BASE=../.. +SUBDIR=vendor/debian + +# Bring in the default rules +include ../../buildlib/defaults.mak + +doc: sources.list + +sources.list: sources.list.in ../../doc/apt-verbatim.ent + sed -e 's#&stable-codename;#$(shell ../getinfo debian-stable-codename)#g' $< > $@ diff --git a/vendor/debian/sources.list.in b/vendor/debian/sources.list.in new file mode 100644 index 000000000..745e32cbe --- /dev/null +++ b/vendor/debian/sources.list.in @@ -0,0 +1,8 @@ +# See sources.list(5) manpage for more information +# Remember that CD-ROMs, DVDs and such are managed through the apt-cdrom tool. +deb http://ftp.us.debian.org/debian &stable-codename; main contrib non-free +deb http://security.debian.org &stable-codename;/updates main contrib non-free + +# Uncomment if you want the apt-get source function to work +#deb-src http://ftp.us.debian.org/debian &stable-codename; main contrib non-free +#deb-src http://security.debian.org &stable-codename;/updates main contrib non-free diff --git a/vendor/getinfo b/vendor/getinfo new file mode 100755 index 000000000..ac816e10e --- /dev/null +++ b/vendor/getinfo @@ -0,0 +1,36 @@ +#!/bin/sh +# small helper to extract information form *.ent files + +BASEDIR="$(readlink -f "$(dirname $0)")" +INFO="$(readlink -f "${BASEDIR}/current/apt-vendor.ent")" + +if [ -z "$INFO" ] || [ ! -e "$INFO" ]; then + echo >&2 'The current vendor is not valid or not chosen by the buildsystem yet.' + exit 1 +fi + +getrawfield() { + grep --max-count=1 "^}" + echo "${FIELD%<*}" +} + +case "$1" in +debian-stable-codename) + getrawfield 'stable-codename' "${BASEDIR}/../doc/apt-verbatim.ent" + ;; +ubuntu-codename) + getrawfield 'stable-codename' "${BASEDIR}/../doc/apt-verbatim.ent" + ;; +keyring-package|keyring-filename|keyring-master-filename|keyring-removed-filename|keyring-uri) + getfield "$1" + ;; +*) + echo >&2 "Unknown data field $1 requested" + exit 2 + ;; +esac diff --git a/vendor/makefile b/vendor/makefile new file mode 100644 index 000000000..a6d53abd0 --- /dev/null +++ b/vendor/makefile @@ -0,0 +1,42 @@ +# -*- make -*- +BASE=.. +SUBDIR=vendor + +# Bring in the default rules +include ../buildlib/defaults.mak + +all headers library binary program doc manpages debiandoc test update-po startup dirs: current +all: all/subdirs +binary: binary/subdirs +doc: doc/subdirs +clean: clean/subdirs +veryclean: veryclean/subdirs +dirs: dirs/subdirs + +all/subdirs binary/subdirs doc/subdirs dirs/subdirs: + $(MAKE) -C current $(patsubst %/subdirs,%,$@) + +clean/subdirs veryclean/subdirs: + test ! -e current || $(MAKE) -C current $(patsubst %/subdirs,%,$@) + +current: + rm -f $@ + # search for an exact match to use the correct sources.list example + find -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 2 | while read DISTRO; do \ + if dpkg-vendor --is $$DISTRO; then \ + ln -s $$DISTRO $@; \ + break; \ + fi; \ + done + # if we haven't found a specific, look for a deriving in hardcoded order + test -e $@ || \ + (dpkg-vendor --derives-from ubuntu && cp ln -s ubuntu $@ ) || \ + ln -s debian $@ + +.PHONY: clean veryclean all binary vendor + +clean: clean/current + +clean/current: + test ! -e current || $(MAKE) -C current clean + rm -f current diff --git a/vendor/ubuntu/apt-vendor.ent b/vendor/ubuntu/apt-vendor.ent new file mode 100644 index 000000000..caa532699 --- /dev/null +++ b/vendor/ubuntu/apt-vendor.ent @@ -0,0 +1,7 @@ + + +ubuntu-keyring"> +/usr/share/keyrings/ubuntu-archive-keyring.gpg"> +/usr/share/keyrings/ubuntu-archive-removed-keys.gpg"> + + diff --git a/vendor/ubuntu/makefile b/vendor/ubuntu/makefile new file mode 100644 index 000000000..ea67e6e63 --- /dev/null +++ b/vendor/ubuntu/makefile @@ -0,0 +1,11 @@ +# -*- make -*- +BASE=../.. +SUBDIR=vendor/ubuntu + +# Bring in the default rules +include ../../buildlib/defaults.mak + +doc: sources.list + +sources.list: sources.list.in ../../doc/apt-verbatim.ent + sed -e 's#&ubuntu-codename;#$(shell ../getinfo ubuntu-codename)#g' $< > $@ diff --git a/vendor/ubuntu/sources.list.in b/vendor/ubuntu/sources.list.in new file mode 100644 index 000000000..b9aa8c3d0 --- /dev/null +++ b/vendor/ubuntu/sources.list.in @@ -0,0 +1,10 @@ + # See sources.list(5) manpage for more information + # Remember that CD-ROMs, DVDs and such are managed through the apt-cdrom tool. +deb http://us.archive.ubuntu.com/ubuntu &ubuntu-codename; main restricted +deb-src http://us.archive.ubuntu.com/ubuntu &ubuntu-codename; main restricted + +deb http://security.ubuntu.com/ubuntu &ubuntu-codename;-security main restricted +deb-src http://security.ubuntu.com/ubuntu &ubuntu-codename;-security main restricted + +deb http://us.archive.ubuntu.com/ubuntu &ubuntu-codename;-updates main restricted +deb-src http://us.archive.ubuntu.com/ubuntu &ubuntu-codename;-updates main restricted