// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: version.cc,v 1.8 1998/12/05 01:44:57 jgg Exp $
+// $Id: version.cc,v 1.9 1999/04/19 06:03:09 jgg Exp $
/* ######################################################################
Version - Version string
return false;
}
/*}}}*/
+// BaseVersion - Return the upstream version string /*{{{*/
+// ---------------------------------------------------------------------
+/* This strips all the debian specific information from the version number */
+string pkgBaseVersion(const char *Ver)
+{
+ // Strip off the bit before the first colon
+ const char *I = Ver;
+ for (; *I != 0 && *I != ':'; I++);
+ if (*I == ':')
+ Ver = I + 1;
+
+ // Chop off the trailing -
+ I = Ver;
+ unsigned Last = strlen(Ver);
+ for (; *I != 0; I++)
+ if (*I == '-')
+ Last = I - Ver;
+
+ return string(Ver,Last);
+}
+ /*}}}*/
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: apt-get.cc,v 1.53 1999/04/18 06:51:09 jgg Exp $
+// $Id: apt-get.cc,v 1.54 1999/04/19 06:03:09 jgg Exp $
/* ######################################################################
apt-get - Cover for dpkg
// DoSource - Fetch a source archive /*{{{*/
// ---------------------------------------------------------------------
/* Fetch souce packages */
+struct DscFile
+{
+ string Package;
+ string Version;
+ string Dsc;
+};
+
bool DoSource(CommandLine &CmdL)
{
CacheFile Cache;
// Create the download object
AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));
pkgAcquire Fetcher(&Stat);
+
+ DscFile *Dsc = new DscFile[CmdL.FileSize()];
// Load the requestd sources into the fetcher
- for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+ unsigned J = 0;
+ for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
{
string Src;
// Try to guess what sort of file it is we are getting.
string Comp;
if (I->Path.find(".dsc") != string::npos)
+ {
Comp = "dsc";
+ Dsc[J].Package = Last->Package();
+ Dsc[J].Version = Last->Version();
+ Dsc[J].Dsc = flNotDir(I->Path);
+ }
+
if (I->Path.find(".tar.gz") != string::npos)
Comp = "tar";
if (I->Path.find(".diff.gz") != string::npos)
return false;
// Print error messages
+ bool Failed = false;
for (pkgAcquire::Item **I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
{
if ((*I)->Status == pkgAcquire::Item::StatDone &&
cerr << "Failed to fetch " << (*I)->DescURI() << endl;
cerr << " " << (*I)->ErrorText << endl;
+ Failed = true;
}
+ if (Failed == true)
+ return _error->Error("Failed to fetch some archives.");
+
+ if (_config->FindB("APT::Get::Download-only",false) == true)
+ return true;
+ // Unpack the sources
+ for (unsigned I = 0; I != J; I++)
+ {
+ string Dir = Dsc[I].Package + '-' + pkgBaseVersion(Dsc[I].Version.c_str());
+
+ // See if the package is already unpacked
+ struct stat Stat;
+ if (stat(Dir.c_str(),&Stat) == 0 &&
+ S_ISDIR(Stat.st_mode) != 0)
+ {
+ c0out << "Skipping unpack of already unpacked source in " << Dir << endl;
+ }
+ else
+ {
+ // Call dpkg-source
+ char S[500];
+ snprintf(S,sizeof(S),"%s -x %s",
+ _config->Find("Dir::Bin::dpkg-source","dpkg-source").c_str(),
+ Dsc[I].Dsc.c_str());
+ if (system(S) != 0)
+ return _error->Error("Unpack command '%s' failed.",S);
+ }
+
+ // Try to compile it with dpkg-buildpackage
+ if (_config->FindB("APT::Get::Compile",false) == true)
+ {
+ // Call dpkg-buildpackage
+ char S[500];
+ snprintf(S,sizeof(S),"cd %s && %s %s",
+ Dir.c_str(),
+ _config->Find("Dir::Bin::dpkg-buildpackage","dpkg-buildpackage").c_str(),
+ _config->Find("DPkg::Build-Options","-b -uc").c_str());
+
+ if (system(S) != 0)
+ return _error->Error("Build command '%s' failed.",S);
+ }
+ }
return true;
}
/*}}}*/
{'q',"quiet","quiet",CommandLine::IntLevel},
{'q',"silent","quiet",CommandLine::IntLevel},
{'d',"download-only","APT::Get::Download-Only",0},
+ {'b',"compile","APT::Get::Compile",0},
+ {'b',"build","APT::Get::Compile",0},
{'s',"simulate","APT::Get::Simulate",0},
{'s',"just-print","APT::Get::Simulate",0},
{'s',"recon","APT::Get::Simulate",0},
that source package. Source packages are tracked seperately from binary
packages via df(deb-src) type lines in the bf(/etc/apt/sources.list) file.
This probably will mean that you will not get the same source as the package
-you have installed or as you could install.
+you have installed or as you could install. If the --compile options is
+specified then the package will be compiled to a binary .deb using
+dpkg-buildpackage, if --download-only is specified then the source package
+will not be unpacked.
dit(bf(check))
bf(check) is a diagnostic tool; it updates the package cache and checks for
Show upgraded packages; Print out a list of all packages that are to be
upgraded. See bf(APT::Get::Show-Upgraded).
+dit(bf(-b, --compile, --build))
+Compile source packages after downloading them.
+
dit(bf(--ignore-hold))
Ignore package Holds; This causes bf(apt-get) to ignore a hold placed on
a package. This may be usefull in conjunction with bf(dist-upgrade) to
file (setting has no effect)
Binary programs are pointed to by bf(Dir::Bin). bf(methods) specifies the
-location of the method handlers and bf(gzip), bf(dpkg), bf(apt-get), and
+location of the method handlers and bf(gzip), bf(dpkg), bf(apt-get),
+bf(dpkg-source), bf(dpkg-buildpackage) and
bf(apt-cache) specify the location of the respective programs.
manpagesection(APT in DSelect)
dit(bf(Run-Directory))
APT chdirs to this directory before invoking dpkg, the default is /.
+dit(bf(Build-Options))
+These options are passed to dpkg-buildpackage when compiling packages,
+the default is to disable signing and produce all binaries.
+
enddit()
manpagesection(Debug Options)
-// $Id: apt.conf,v 1.31 1999/04/11 21:23:10 jgg Exp $
+// $Id: apt.conf,v 1.32 1999/04/19 06:03:09 jgg Exp $
/* This file is an index of all APT configuration directives. It should
NOT actually be used as a real config file, though it is a completely
valid file.
Show-Upgraded "false";
No-Upgrade "false";
Print-URIs "false";
+ Compile "false";
};
Cache
methods "/usr/lib/apt/methods/";
gzip "/bin/gzip";
dpkg "/usr/bin/dpkg";
+ dpkg-source "/usr/bin/dpkg-source";
+ dpkg-buildpackage "/usr/bin/dpkg-buildpackage"
apt-get "/usr/bin/apt-get";
apt-cache "/usr/bin/apt-cache";
};
// Prevents daemons from getting cwd as something mountable (default)
Run-Directory "/";
+
+ // Build options for apt-get source --compile
+ Build-Options "-b -uc";
}
/* Options you can set to see some debugging text They corrispond to names