summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-05-08 14:29:30 +0200
committerMichael Vogt <mvo@debian.org>2014-05-08 14:29:30 +0200
commit070536e61cb203a9c74013be2a26322b582a9674 (patch)
tree9126356edcc1e239c6d87e3cb2921318238d501b
parent1816266852b25faec4f2ed1a67171eddb39b2102 (diff)
parent77da39b95870498431fc21df65900acc5ce2f7ea (diff)
Merge remote-tracking branch 'mvo/feature/build-dep-dsc2' into debian/experimental
Conflicts: apt-pkg/deb/debindexfile.cc apt-pkg/deb/debindexfile.h apt-pkg/deb/debsrcrecords.cc
-rw-r--r--apt-pkg/deb/debindexfile.cc65
-rw-r--r--apt-pkg/deb/debindexfile.h24
-rw-r--r--apt-pkg/deb/debmetaindex.cc4
-rw-r--r--apt-pkg/deb/debsrcrecords.cc19
-rw-r--r--apt-pkg/deb/debsrcrecords.h7
-rw-r--r--apt-pkg/indexfile.h1
-rw-r--r--apt-pkg/pkgsystem.h6
-rw-r--r--apt-pkg/sourcelist.h2
-rw-r--r--apt-pkg/tagfile.cc11
-rw-r--r--apt-pkg/tagfile.h2
-rw-r--r--cmdline/apt-get.cc27
-rwxr-xr-xtest/integration/test-apt-get-build-dep126
12 files changed, 286 insertions, 8 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index 86ef92bfb..37efa05b0 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -759,6 +759,41 @@ unsigned long debDebPkgFileIndex::Size() const
}
/*}}}*/
+// debDscFileIndex stuff
+debDscFileIndex::debDscFileIndex(std::string &DscFile)
+ : pkgIndexFile(true), DscFile(DscFile)
+{
+}
+
+bool debDscFileIndex::Exists() const
+{
+ return FileExists(DscFile);
+}
+
+unsigned long debDscFileIndex::Size() const
+{
+ struct stat buf;
+ if(stat(DscFile.c_str(), &buf) == 0)
+ return buf.st_size;
+ return 0;
+}
+
+// DscFileIndex::CreateSrcParser - Get a parser for the .dsc file /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgSrcRecords::Parser *debDscFileIndex::CreateSrcParser() const
+{
+ if (!FileExists(DscFile))
+ return NULL;
+
+ return new debDscRecordParser(DscFile,this);
+}
+ /*}}}*/
+
+
+
+
+// ---------------------------------------------------------------------
// Index File types for Debian /*{{{*/
class debIFTypeSrc : public pkgIndexFile::Type
{
@@ -800,11 +835,33 @@ class debIFTypeDebPkgFile : public pkgIndexFile::Type
};
debIFTypeDebPkgFile() {Label = "deb Package file";};
};
+class debIFTypeDscFile : public pkgIndexFile::Type
+{
+ public:
+ virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string DscFile) const
+ {
+ return new debDscRecordParser(DscFile, NULL);
+ };
+ debIFTypeDscFile() {Label = "dsc File Source Index";};
+};
+class debIFTypeDebianSourceDir : public pkgIndexFile::Type
+{
+ public:
+ virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string SourceDir) const
+ {
+ return new debDscRecordParser(SourceDir + string("/debian/control"), NULL);
+ };
+ debIFTypeDebianSourceDir() {Label = "debian/control File Source Index";};
+};
+
static debIFTypeSrc _apt_Src;
static debIFTypePkg _apt_Pkg;
static debIFTypeTrans _apt_Trans;
static debIFTypeStatus _apt_Status;
static debIFTypeDebPkgFile _apt_DebPkgFile;
+// file based pseudo indexes
+static debIFTypeDscFile _apt_DscFile;
+static debIFTypeDebianSourceDir _apt_DebianSourceDir;
const pkgIndexFile::Type *debSourcesIndex::GetType() const
{
@@ -826,4 +883,12 @@ const pkgIndexFile::Type *debDebPkgFileIndex::GetType() const
{
return &_apt_DebPkgFile;
}
+const pkgIndexFile::Type *debDscFileIndex::GetType() const
+{
+ return &_apt_DscFile;
+}
+const pkgIndexFile::Type *debDebianSourceDirIndex::GetType() const
+{
+ return &_apt_DebianSourceDir;
+}
/*}}}*/
diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h
index 69754e79d..18322dc1b 100644
--- a/apt-pkg/deb/debindexfile.h
+++ b/apt-pkg/deb/debindexfile.h
@@ -192,7 +192,29 @@ class debDebPkgFileIndex : public pkgIndexFile
debDebPkgFileIndex(std::string DebFile);
virtual ~debDebPkgFileIndex() {};
-
+};
+
+class debDscFileIndex : public pkgIndexFile
+{
+ private:
+ std::string DscFile;
+ public:
+ virtual const Type *GetType() const APT_CONST;
+ virtual pkgSrcRecords::Parser *CreateSrcParser() const;
+ virtual bool Exists() const;
+ virtual bool HasPackages() const {return false;};
+ virtual unsigned long Size() const;
+ virtual std::string Describe(bool /*Short*/) const {
+ return DscFile;
+ };
+
+ debDscFileIndex(std::string &DscFile);
+ virtual ~debDscFileIndex() {};
+};
+
+class debDebianSourceDirIndex : public debDscFileIndex
+{
+ virtual const Type *GetType() const APT_CONST;
};
#endif
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index 56eecdca1..b4839ada4 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -521,8 +521,8 @@ class debSLTypeDebFile : public pkgSourceList::Type
public:
bool CreateItem(vector<metaIndex *> &List, string const &URI,
- string const &Dist, string const &Section,
- std::map<string, string> const &Options) const
+ string const &/*Dist*/, string const &/*Section*/,
+ std::map<string, string> const &/*Options*/) const
{
metaIndex *mi = new debDebFileMetaIndex(URI);
List.push_back(mi);
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index 615f0f57d..7b9a828d3 100644
--- a/apt-pkg/deb/debsrcrecords.cc
+++ b/apt-pkg/deb/debsrcrecords.cc
@@ -19,6 +19,7 @@
#include <apt-pkg/srcrecords.h>
#include <apt-pkg/tagfile.h>
#include <apt-pkg/hashes.h>
+#include <apt-pkg/gpgv.h>
#include <ctype.h>
#include <stdlib.h>
@@ -212,3 +213,21 @@ debSrcRecordParser::~debSrcRecordParser()
delete[] Buffer;
}
/*}}}*/
+
+
+debDscRecordParser::debDscRecordParser(std::string const &DscFile, pkgIndexFile const *Index)
+ : debSrcRecordParser(DscFile, Index)
+{
+ // support clear signed files
+ if (OpenMaybeClearSignedFile(DscFile, Fd) == false)
+ {
+ _error->Error("Failed to open %s", DscFile.c_str());
+ return;
+ }
+
+ // re-init to ensure the updated Fd is used
+ Tags.Init(&Fd);
+ // read the first (and only) record
+ Step();
+
+}
diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h
index b65d1480b..a0a151875 100644
--- a/apt-pkg/deb/debsrcrecords.h
+++ b/apt-pkg/deb/debsrcrecords.h
@@ -26,6 +26,7 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
+ protected:
FileFd Fd;
pkgTagFile Tags;
pkgTagSection Sect;
@@ -60,4 +61,10 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
virtual ~debSrcRecordParser();
};
+class debDscRecordParser : public debSrcRecordParser
+{
+ public:
+ debDscRecordParser(std::string const &DscFile, pkgIndexFile const *Index);
+};
+
#endif
diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h
index b5c9ac77e..817165f08 100644
--- a/apt-pkg/indexfile.h
+++ b/apt-pkg/indexfile.h
@@ -59,6 +59,7 @@ class pkgIndexFile
const char *Label;
virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator /*File*/) const {return 0;};
+ virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string /*File*/) const {return 0;};
Type();
virtual ~Type() {};
};
diff --git a/apt-pkg/pkgsystem.h b/apt-pkg/pkgsystem.h
index 6e33c67ed..f88ffa7c8 100644
--- a/apt-pkg/pkgsystem.h
+++ b/apt-pkg/pkgsystem.h
@@ -85,10 +85,12 @@ class pkgSystem
virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List) = 0;
virtual bool FindIndex(pkgCache::PkgFileIterator File,
pkgIndexFile *&Found) const = 0;
-
+
/* Evauluate how 'right' we are for this system based on the filesystem
etc.. */
- virtual signed Score(Configuration const &/*Cnf*/) {return 0;};
+ virtual signed Score(Configuration const &/*Cnf*/) {
+ return 0;
+ };
pkgSystem();
virtual ~pkgSystem() {};
diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h
index 99e83f454..261dd8161 100644
--- a/apt-pkg/sourcelist.h
+++ b/apt-pkg/sourcelist.h
@@ -94,7 +94,7 @@ class pkgSourceList : public pkgSource
typedef std::vector<metaIndex *>::const_iterator const_iterator;
- protected:
+ public:
std::vector<metaIndex *> SrcList;
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index 91d176e3c..009ed7d74 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -51,12 +51,23 @@ public:
// ---------------------------------------------------------------------
/* */
pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long long Size)
+ : d(NULL)
+{
+ Init(pFd, Size);
+}
+
+void pkgTagFile::Init(FileFd *pFd,unsigned long long Size)
{
/* The size is increased by 4 because if we start with the Size of the
filename we need to try to read 1 char more to see an EOF faster, 1
char the end-pointer can be on and maybe 2 newlines need to be added
to the end of the file -> 4 extra chars */
Size += 4;
+ if(d != NULL)
+ {
+ free(d->Buffer);
+ delete d;
+ }
d = new pkgTagFilePrivate(pFd, Size);
if (d->Fd.IsOpen() == false)
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
index d5b62e76d..d1a24ba45 100644
--- a/apt-pkg/tagfile.h
+++ b/apt-pkg/tagfile.h
@@ -105,6 +105,8 @@ class pkgTagFile
unsigned long Offset();
bool Jump(pkgTagSection &Tag,unsigned long long Offset);
+ void Init(FileFd *F,unsigned long long Size = 32*1024);
+
pkgTagFile(FileFd *F,unsigned long long Size = 32*1024);
virtual ~pkgTagFile();
};
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index f682074a7..1148dbbf3 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -1050,7 +1050,30 @@ static bool DoBuildDep(CommandLine &CmdL)
for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
{
string Src;
- pkgSrcRecords::Parser *Last = FindSrc(*I,Recs,SrcRecs,Src,Cache);
+ pkgSrcRecords::Parser *Last = 0;
+
+ // a unpacked debian source tree
+ if (DirectoryExists(*I))
+ {
+ // FIXME: how can we make this more elegant?
+ std::string TypeName = "debian/control File Source Index";
+ pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
+ if(Type != NULL)
+ Last = Type->CreateSrcPkgParser(*I);
+ }
+ // if its a local file (e.g. .dsc) use this
+ else if (FileExists(*I))
+ {
+ // see if we can get a parser for this pkgIndexFile type
+ string TypeName = flExtension(*I) + " File Source Index";
+ pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
+ if(Type != NULL)
+ Last = Type->CreateSrcPkgParser(*I);
+ } else {
+ // normal case, search the cache for the source file
+ Last = FindSrc(*I,Recs,SrcRecs,Src,Cache);
+ }
+
if (Last == 0)
return _error->Error(_("Unable to find a source package for %s"),Src.c_str());
@@ -1068,7 +1091,7 @@ static bool DoBuildDep(CommandLine &CmdL)
}
else if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only", false), StripMultiArch) == false)
return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str());
-
+
// Also ensure that build-essential packages are present
Configuration::Item const *Opts = _config->Tree("APT::Build-Essential");
if (Opts)
diff --git a/test/integration/test-apt-get-build-dep b/test/integration/test-apt-get-build-dep
new file mode 100755
index 000000000..f71beae9c
--- /dev/null
+++ b/test/integration/test-apt-get-build-dep
@@ -0,0 +1,126 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture "i386"
+
+buildsimplenativepackage 'debhelper' 'i386' '7' 'stable'
+buildsimplenativepackage 'build-essential' 'i386' '1' 'stable'
+
+setupaptarchive
+cat > 2vcard_0.5-3.dsc <<EOF
+Format: 1.0
+Source: 2vcard
+Binary: 2vcard
+Architecture: all
+Version: 0.5-3
+Maintainer: Martin Albisetti <argentina@gmail.com>
+Uploaders: Marcela Tiznado <mlt@debian.org>
+Standards-Version: 3.8.0
+Build-Depends: debhelper (>= 5.0.37)
+Checksums-Sha1:
+ b7f1ce31ec856414a3f0f1090689f91aa7456d56 9398 2vcard_0.5.orig.tar.gz
+ 5f9acd07ebda6ab00fa6b4fe3198c13e94090862 2036 2vcard_0.5-3.diff.gz
+Checksums-Sha256:
+ efdc22859ac2f8f030d038dc4faa9020082ebae34212498c288968ffd45c9764 9398 2vcard_0.5.orig.tar.gz
+ 82673ff3456af571094066c89bcea87b25c23c87cf1d0050b731e5222563626b 2036 2vcard_0.5-3.diff.gz
+Files:
+ f73a69c170f772f3f6e75f2d11bbb792 9398 2vcard_0.5.orig.tar.gz
+ 1e806d32233af87437258d86b1561f57 2036 2vcard_0.5-3.diff.gz
+EOF
+
+testequal "Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ build-essential debhelper
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst build-essential (1 stable [i386])
+Inst debhelper (7 stable [i386])
+Conf build-essential (1 stable [i386])
+Conf debhelper (7 stable [i386])" aptget build-dep -s 2vcard_0.5-3.dsc
+
+cat > 2vcard_0.5-3.dsc <<EOF
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+Format: 1.0
+Source: 2vcard
+Binary: 2vcard
+Architecture: all
+Version: 0.5-3
+Maintainer: Martin Albisetti <argentina@gmail.com>
+Uploaders: Marcela Tiznado <mlt@debian.org>
+Standards-Version: 3.8.0
+Build-Depends: debhelper (>= 5.0.37)
+Checksums-Sha1:
+ b7f1ce31ec856414a3f0f1090689f91aa7456d56 9398 2vcard_0.5.orig.tar.gz
+ 5f9acd07ebda6ab00fa6b4fe3198c13e94090862 2036 2vcard_0.5-3.diff.gz
+Checksums-Sha256:
+ efdc22859ac2f8f030d038dc4faa9020082ebae34212498c288968ffd45c9764 9398 2vcard_0.5.orig.tar.gz
+ 82673ff3456af571094066c89bcea87b25c23c87cf1d0050b731e5222563626b 2036 2vcard_0.5-3.diff.gz
+Files:
+ f73a69c170f772f3f6e75f2d11bbb792 9398 2vcard_0.5.orig.tar.gz
+ 1e806d32233af87437258d86b1561f57 2036 2vcard_0.5-3.diff.gz
+
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.9 (GNU/Linux)
+
+iEYEARECAAYFAkijKhsACgkQsrBfRdYmq7aA2gCfaOW9riTYVQMx5ajKQVAcctlC
+z2UAn1oXgTai6opwhVfkxrlmJ+iRxzuc
+=4eRd
+-----END PGP SIGNATURE-----
+EOF
+
+testequal "Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ build-essential debhelper
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst build-essential (1 stable [i386])
+Inst debhelper (7 stable [i386])
+Conf build-essential (1 stable [i386])
+Conf debhelper (7 stable [i386])" aptget build-dep --simulate 2vcard_0.5-3.dsc
+
+
+# unpacked source dir
+mkdir -p foo-1.0/debian
+cat > foo-1.0/debian/control <<'EOF'
+Source: apturl
+Section: admin
+Priority: optional
+Maintainer: Michael Vogt <mvo@ubuntu.com>
+Build-Depends: debhelper (>= 7)
+X-Python3-Version: >= 3.2
+Standards-Version: 3.9.3
+
+Package: apturl-common
+Architecture: any
+Depends: ${python3:Depends},
+ ${shlibs:Depends},
+ ${misc:Depends},
+ python3-apt,
+ python3-update-manager
+Replaces: apturl (<< 0.3.6ubuntu2)
+Description: install packages using the apt protocol - common data
+ AptUrl is a simple graphical application that takes an URL (which follows the
+ apt-protocol) as a command line option, parses it and carries out the
+ operations that the URL describes (that is, it asks the user if he wants the
+ indicated packages to be installed and if the answer is positive does so for
+ him).
+ .
+ This package contains the common data shared between the frontends.
+
+EOF
+
+testequal "Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ build-essential debhelper
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst build-essential (1 stable [i386])
+Inst debhelper (7 stable [i386])
+Conf build-essential (1 stable [i386])
+Conf debhelper (7 stable [i386])" aptget build-dep --simulate ./foo-1.0