From 5de346684f6777eb9e2ac1a38d687c1bc50f35b0 Mon Sep 17 00:00:00 2001 From: Johan Kiviniemi Date: Wed, 22 May 2013 21:06:26 +0300 Subject: cmdline/apt-key: Create new keyrings with mode 0644 instead of 0600 --- cmdline/apt-key | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'cmdline') diff --git a/cmdline/apt-key b/cmdline/apt-key index c184e3e75..309c51b13 100755 --- a/cmdline/apt-key +++ b/cmdline/apt-key @@ -32,6 +32,16 @@ requires_root() { 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 @@ -198,33 +208,42 @@ fi case "$command" in add) requires_root + init_keyring "$TRUSTEDFILE" $GPG --quiet --batch --import "$1" echo "OK" ;; del|rm|remove) requires_root + init_keyring "$TRUSTEDFILE" $GPG --quiet --batch --delete-key --yes "$1" echo "OK" ;; 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 $* ;; -- cgit v1.2.3 From ecc46c1c42bb1aa59a0c8f0fb3eb12a5938da6ca Mon Sep 17 00:00:00 2001 From: Johan Kiviniemi Date: Wed, 22 May 2013 21:14:33 +0300 Subject: cmdline/apt-key: Accept nonexistent --keyring file with adv as well --- cmdline/apt-key | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-key b/cmdline/apt-key index 309c51b13..2c087acbc 100755 --- a/cmdline/apt-key +++ b/cmdline/apt-key @@ -163,7 +163,7 @@ if [ "$1" = "--keyring" ]; then #echo "keyfile given" shift TRUSTEDFILE="$1" - if [ -r "$TRUSTEDFILE" ] || [ "$2" = 'add' ]; then + 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" -- cgit v1.2.3 From 3a61adbba8bfc9ba76d1262e0e8118f78920f9fe Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 19 May 2013 18:53:19 +0200 Subject: remove -ldl from cdrom and -lutil from apt-get linkage Building src:apt shows: dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/apt/usr/lib/apt/methods/cdrom was not linked against libdl.so.2 (it uses none of the library's symbols) dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/apt/usr/bin/apt-get was not linked against libutil.so.1 (it uses none of the library's symbols) --- cmdline/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/makefile b/cmdline/makefile index f3712232a..460a71240 100644 --- a/cmdline/makefile +++ b/cmdline/makefile @@ -14,7 +14,7 @@ include $(PROGRAM_H) # The apt-get program PROGRAM=apt-get -SLIBS = -lapt-pkg -lutil $(INTLLIBS) +SLIBS = -lapt-pkg $(INTLLIBS) LIB_MAKES = apt-pkg/makefile SOURCE = apt-get.cc acqprogress.cc include $(PROGRAM_H) -- cgit v1.2.3 From f3c736f9b6fdef1d8045846c465d675858eb1471 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 24 May 2013 10:20:38 +0200 Subject: deprecate InstallProtect as a cpu-eating no-op In the past packages were flagged "Protected" so that install/ remove markings where issued before the ProblemResolver. Nowadays, the marking methods check if they are allowed to modify the marking of a package instead, so that markings set by FromUser calls are not overwritten anymore by automatic calls which elimates the need for InstallProtect which just eats CPU now. The method itself is left untouched for now in case frontend needs it still for some wierd usecase, but they should be eliminated. --- cmdline/apt-get.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 999f2a6a7..85ed80a95 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1962,7 +1962,6 @@ bool DoInstall(CommandLine &CmdL) if (Fix != NULL) { // Call the scored problem resolver - Fix->InstallProtect(); Fix->Resolve(true); delete Fix; } @@ -3123,8 +3122,7 @@ bool DoBuildDep(CommandLine &CmdL) } } } - - Fix.InstallProtect(); + if (Fix.Resolve(true) == false) _error->Discard(); -- cgit v1.2.3 From 991e690a693cf3724b815c1fb358aa033af73c03 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 25 May 2013 19:47:28 +0200 Subject: initialize the whole search array with zero Git-Dch: Ignore --- cmdline/apt-cache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 0a2c28d23..de263a300 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1247,7 +1247,7 @@ bool Search(CommandLine &CmdL) } ExDescFile *DFList = new ExDescFile[Cache->HeaderP->GroupCount+1]; - memset(DFList,0,sizeof(*DFList)*Cache->HeaderP->GroupCount+1); + memset(DFList, 0, sizeof(*DFList) * (Cache->HeaderP->GroupCount + 1)); // Map versions that we want to write out onto the VerList array. for (pkgCache::GrpIterator G = Cache->GrpBegin(); G.end() == false; ++G) -- cgit v1.2.3 From 8ba17539a3ec33abc283ca382cca6e59876a0f07 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 25 May 2013 19:57:48 +0200 Subject: fix support for multiple patterns in apt-cache search Patterns can appear in the name as well as in the description, they don't have to match all in the name/description only. Closes: 691453 --- cmdline/apt-cache.cc | 79 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 28 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index de263a300..bda09a5a1 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1203,7 +1203,7 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V) struct ExDescFile { pkgCache::DescFile *Df; - bool NameMatch; + map_ptrloc ID; }; // Search - Perform a search /*{{{*/ @@ -1246,37 +1246,48 @@ bool Search(CommandLine &CmdL) return false; } - ExDescFile *DFList = new ExDescFile[Cache->HeaderP->GroupCount+1]; - memset(DFList, 0, sizeof(*DFList) * (Cache->HeaderP->GroupCount + 1)); + size_t const descCount = Cache->HeaderP->GroupCount + 1; + ExDescFile *DFList = new ExDescFile[descCount]; + memset(DFList,0,sizeof(*DFList) * descCount); + + bool PatternMatch[descCount * NumPatterns]; + memset(PatternMatch,false,sizeof(PatternMatch)); // Map versions that we want to write out onto the VerList array. for (pkgCache::GrpIterator G = Cache->GrpBegin(); G.end() == false; ++G) { - if (DFList[G->ID].NameMatch == true) - continue; - - DFList[G->ID].NameMatch = true; - for (unsigned I = 0; I != NumPatterns; I++) + size_t const PatternOffset = G->ID * NumPatterns; + size_t unmatched = 0, matched = 0; + for (unsigned I = 0; I < NumPatterns; ++I) { - if (regexec(&Patterns[I],G.Name(),0,0,0) == 0) - continue; - DFList[G->ID].NameMatch = false; - break; + if (PatternMatch[PatternOffset + I] == true) + ++matched; + else if (regexec(&Patterns[I],G.Name(),0,0,0) == 0) + PatternMatch[PatternOffset + I] = true; + else + ++unmatched; } - - // Doing names only, drop any that dont match.. - if (NamesOnly == true && DFList[G->ID].NameMatch == false) + + // already dealt with this package? + if (matched == NumPatterns) continue; - + + // Doing names only, drop any that don't match.. + if (NamesOnly == true && unmatched == NumPatterns) + continue; + // Find the proper version to use pkgCache::PkgIterator P = G.FindPreferredPkg(); if (P.end() == true) continue; pkgCache::VerIterator V = Plcy->GetCandidateVer(P); if (V.end() == false) + { DFList[G->ID].Df = V.TranslatedDescription().FileList(); + DFList[G->ID].ID = G->ID; + } - if (DFList[G->ID].NameMatch == false) + if (unmatched == NumPatterns) continue; // Include all the packages that provide matching names too @@ -1288,33 +1299,45 @@ bool Search(CommandLine &CmdL) unsigned long id = Prv.OwnerPkg().Group()->ID; DFList[id].Df = V.TranslatedDescription().FileList(); - DFList[id].NameMatch = true; + DFList[id].ID = id; + + size_t const PrvPatternOffset = id * NumPatterns; + for (unsigned I = 0; I < NumPatterns; ++I) + PatternMatch[PrvPatternOffset + I] = PatternMatch[PatternOffset + I]; } } - + LocalitySort(&DFList->Df,Cache->HeaderP->GroupCount,sizeof(*DFList)); // Create the text record parser pkgRecords Recs(*Cache); // Iterate over all the version records and check them - for (ExDescFile *J = DFList; J->Df != 0; J++) + for (ExDescFile *J = DFList; J->Df != 0; ++J) { pkgRecords::Parser &P = Recs.Lookup(pkgCache::DescFileIterator(*Cache,J->Df)); + size_t const PatternOffset = J->ID * NumPatterns; - if (J->NameMatch == false && NamesOnly == false) + if (NamesOnly == false) { string const LongDesc = P.LongDesc(); - J->NameMatch = true; - for (unsigned I = 0; I != NumPatterns; I++) + for (unsigned I = 0; I < NumPatterns; ++I) { - if (regexec(&Patterns[I],LongDesc.c_str(),0,0,0) == 0) + if (PatternMatch[PatternOffset + I] == true) continue; - J->NameMatch = false; - break; + else if (regexec(&Patterns[I],LongDesc.c_str(),0,0,0) == 0) + PatternMatch[PatternOffset + I] = true; } } - - if (J->NameMatch == true) + + bool matchedAll = true; + for (unsigned I = 0; I < NumPatterns; ++I) + if (PatternMatch[PatternOffset + I] == false) + { + matchedAll = false; + break; + } + + if (matchedAll == true) { if (ShowFull == true) { -- cgit v1.2.3 From 99359751efb1ad84e877219639030feb47fb28f7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 16 Jun 2013 15:42:31 +0200 Subject: handle missing "Description" in apt-cache show do not blindly assume that all packages stanzas have a "Description:" field in 'apt-cache show' as well as in the cache creation itself. We instead assume now that if the stanza has a Description, it will not be the first field as we look out for "\nDescription" to take care of MD5sum as well as (maybe ignored) translated Descriptions embedded in the package stanza. Closes: #712435 --- cmdline/apt-cache.cc | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index bda09a5a1..fb4467c2c 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1161,7 +1161,11 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V) } // Get a pointer to start of Description field - const unsigned char *DescP = (unsigned char*)strstr((char*)Buffer, "Description:"); + const unsigned char *DescP = (unsigned char*)strstr((char*)Buffer, "\nDescription"); + if (DescP != NULL) + ++DescP; + else + DescP = Buffer + V.FileList()->Size; // Write all but Description if (fwrite(Buffer,1,DescP - Buffer,stdout) < (size_t)(DescP - Buffer)) @@ -1173,25 +1177,38 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V) // Show the right description pkgRecords Recs(*Cache); pkgCache::DescIterator Desc = V.TranslatedDescription(); - pkgRecords::Parser &P = Recs.Lookup(Desc.FileList()); - cout << "Description" << ( (strcmp(Desc.LanguageCode(),"") != 0) ? "-" : "" ) << Desc.LanguageCode() << ": " << P.LongDesc(); - - // Find the first field after the description (if there is any) - for(DescP++;DescP != &Buffer[V.FileList()->Size];DescP++) + if (Desc.end() == false) { - if(*DescP == '\n' && *(DescP+1) != ' ') + pkgRecords::Parser &P = Recs.Lookup(Desc.FileList()); + cout << "Description" << ( (strcmp(Desc.LanguageCode(),"") != 0) ? "-" : "" ) << Desc.LanguageCode() << ": " << P.LongDesc(); + cout << std::endl << "Description-md5: " << Desc.md5() << std::endl; + + // Find the first field after the description (if there is any) + while ((DescP = (unsigned char*)strchr((char*)DescP, '\n')) != NULL) { - // write the rest of the buffer - const unsigned char *end=&Buffer[V.FileList()->Size]; - if (fwrite(DescP,1,end-DescP,stdout) < (size_t)(end-DescP)) - { - delete [] Buffer; - return false; - } + if (DescP[1] == ' ') + DescP += 2; + else if (strncmp((char*)DescP, "\nDescription", strlen("\nDescription")) == 0) + DescP += strlen("\nDescription"); + else + break; + } + if (DescP != NULL) + ++DescP; + } + // if we have no translation, we found a lonely Description-md5, so don't skip it - break; + if (DescP != NULL) + { + // write the rest of the buffer + const unsigned char *end=&Buffer[V.FileList()->Size]; + if (fwrite(DescP,1,end-DescP,stdout) < (size_t)(end-DescP)) + { + delete [] Buffer; + return false; } } + // write a final newline (after the description) cout< Date: Sun, 16 Jun 2013 18:28:45 +0200 Subject: try defaults if auto-detection failed in apt-cdrom The default is to ask udev for location and mountpoints of CD-ROMs, but the old way of specifying the mountpoint is still available and is tried now in case udev doesn't find any CD-ROM. It probably fails, too, but we get a bunch of error messages this way and the user can get an idea of how to make his setup work even if udev can't be convienced to return something useful. Closes: #712433 --- cmdline/apt-cdrom.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 2551f4916..70e49910c 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -150,14 +150,12 @@ bool DoAdd(CommandLine &) bool res = true; bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect", true); + unsigned int count = 0; if (AutoDetect && UdevCdroms.Dlopen()) - { - unsigned int count = 0; while (AutoDetectCdrom(UdevCdroms, count)) res &= cdrom.Add(&log); - } else { + if (count == 0) res = cdrom.Add(&log); - } if(res) cout << _("Repeat this process for the rest of the CDs in your set.") << endl; @@ -178,15 +176,12 @@ bool DoIdent(CommandLine &) bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect"); + unsigned int count = 0; if (AutoDetect && UdevCdroms.Dlopen()) - { - unsigned int count = 0; while (AutoDetectCdrom(UdevCdroms, count)) res &= cdrom.Ident(ident, &log); - } else { + if (count == 0) return cdrom.Ident(ident, &log); - } - return res; } /*}}}*/ -- cgit v1.2.3 From 0a83556bf3ed33c95f39dd1063c4e745aaaeac9e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 22 Jun 2013 10:03:24 +0200 Subject: Improve the apt-cdrom output when no CD-ROM can be auto-detected (closes: #712433) --- cmdline/apt-cdrom.cc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 70e49910c..520b1e0a0 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -39,6 +39,12 @@ #include /*}}}*/ +static const char *W_NO_CDROM_FOUND = \ + N_("No CD-ROM could be auto-detected or found using " + "the default mount path.\n" + "You may try the --cdrom option to set the CD-ROM mount path. " + "See 'man apt-cdrom' for more " + "information about the CD-ROM auto-detection and mount path."); using namespace std; @@ -135,7 +141,6 @@ bool AutoDetectCdrom(pkgUdevCdromDevices &UdevCdroms, unsigned int &i) return true; } /*}}}*/ - // DoAdd - Add a new CDROM /*{{{*/ // --------------------------------------------------------------------- /* This does the main add bit.. We show some status and things. The @@ -154,8 +159,12 @@ bool DoAdd(CommandLine &) if (AutoDetect && UdevCdroms.Dlopen()) while (AutoDetectCdrom(UdevCdroms, count)) res &= cdrom.Add(&log); - if (count == 0) + if (count == 0) { res = cdrom.Add(&log); + if (res == false) { + _error->Warning(_(W_NO_CDROM_FOUND)); + } + } if(res) cout << _("Repeat this process for the rest of the CDs in your set.") << endl; @@ -180,8 +189,12 @@ bool DoIdent(CommandLine &) if (AutoDetect && UdevCdroms.Dlopen()) while (AutoDetectCdrom(UdevCdroms, count)) res &= cdrom.Ident(ident, &log); - if (count == 0) - return cdrom.Ident(ident, &log); + if (count == 0) { + res = cdrom.Ident(ident, &log); + if (res == false) { + _error->Warning(_(W_NO_CDROM_FOUND)); + } + } return res; } /*}}}*/ @@ -213,7 +226,7 @@ int ShowHelp() " -m No mounting\n" " -f Fast mode, don't check package files\n" " -a Thorough scan mode\n" - " --auto-detect Auto detect drive and mount point\n" + " --no-auto-detect Do not try to auto detect drive and mount point\n" " -c=? Read this configuration file\n" " -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp\n" "See fstab(5)\n"; @@ -224,7 +237,7 @@ int main(int argc,const char *argv[]) /*{{{*/ { CommandLine::Args Args[] = { {'h',"help","help",0}, - { 0,"auto-detect","Acquire::cdrom::AutoDetect",0}, + { 0,"auto-detect","Acquire::cdrom::AutoDetect", CommandLine::Boolean}, {'v',"version","version",0}, {'d',"cdrom","Acquire::cdrom::mount",CommandLine::HasArg}, {'r',"rename","APT::CDROM::Rename",0}, -- cgit v1.2.3 From 9d0c9e70494abe789490cd3b76b67d2927e410e7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 26 Jun 2013 07:35:16 +0200 Subject: "mount path"->"mount point" and also make the warning a error when no CD-ROM is found --- cmdline/apt-cdrom.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 520b1e0a0..3f53e16ee 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -41,10 +41,10 @@ /*}}}*/ static const char *W_NO_CDROM_FOUND = \ N_("No CD-ROM could be auto-detected or found using " - "the default mount path.\n" - "You may try the --cdrom option to set the CD-ROM mount path. " + "the default mount point.\n" + "You may try the --cdrom option to set the CD-ROM mount point. " "See 'man apt-cdrom' for more " - "information about the CD-ROM auto-detection and mount path."); + "information about the CD-ROM auto-detection and mount point."); using namespace std; @@ -162,7 +162,7 @@ bool DoAdd(CommandLine &) if (count == 0) { res = cdrom.Add(&log); if (res == false) { - _error->Warning(_(W_NO_CDROM_FOUND)); + _error->Error(_(W_NO_CDROM_FOUND)); } } @@ -192,7 +192,7 @@ bool DoIdent(CommandLine &) if (count == 0) { res = cdrom.Ident(ident, &log); if (res == false) { - _error->Warning(_(W_NO_CDROM_FOUND)); + _error->Error(_(W_NO_CDROM_FOUND)); } } return res; -- cgit v1.2.3 From 4ff028826ef0fa500b7717415be4109c2ac1da1d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 2 Jul 2013 08:45:03 +0200 Subject: fix format string error --- cmdline/apt-cdrom.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 3f53e16ee..c153cca85 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -162,7 +162,7 @@ bool DoAdd(CommandLine &) if (count == 0) { res = cdrom.Add(&log); if (res == false) { - _error->Error(_(W_NO_CDROM_FOUND)); + _error->Error("%s", _(W_NO_CDROM_FOUND)); } } @@ -192,7 +192,7 @@ bool DoIdent(CommandLine &) if (count == 0) { res = cdrom.Ident(ident, &log); if (res == false) { - _error->Error(_(W_NO_CDROM_FOUND)); + _error->Error("%s", _(W_NO_CDROM_FOUND)); } } return res; -- cgit v1.2.3