From 54676e1a82f400e37879bc931b6db0c13b8ebb3f Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Mon, 20 Sep 2004 16:53:38 +0000 Subject: Working apt-get source build stuff Author: jgg Date: 1999-04-20 05:02:09 GMT Working apt-get source build stuff --- cmdline/apt-get.cc | 95 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 34 deletions(-) (limited to 'cmdline/apt-get.cc') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 504cde33e..41d089d76 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: apt-get.cc,v 1.54 1999/04/19 06:03:09 jgg Exp $ +// $Id: apt-get.cc,v 1.55 1999/04/20 05:02:09 jgg Exp $ /* ###################################################################### apt-get - Cover for dpkg @@ -51,6 +51,7 @@ #include #include #include +#include /*}}}*/ ostream c0out; @@ -1214,42 +1215,68 @@ bool DoSource(CommandLine &CmdL) return true; // Unpack the sources - for (unsigned I = 0; I != J; I++) + pid_t Process = ExecFork(); + + if (Process == 0) { - 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 + for (unsigned I = 0; I != J; I++) { - // 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()); + string Dir = Dsc[I].Package + '-' + pkgBaseVersion(Dsc[I].Version.c_str()); - if (system(S) != 0) - return _error->Error("Build command '%s' failed.",S); - } - } + // 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) + { + cerr << "Unpack command '" << S << "' failed." << endl; + _exit(1); + } + } + + // 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) + { + cerr << "Build command '" << S << "' failed." << endl; + _exit(1); + } + } + } + + _exit(0); + } + + // Wait for the subprocess + int Status = 0; + while (waitpid(Process,&Status,0) != Process) + { + if (errno == EINTR) + continue; + return _error->Errno("waitpid","Couldn't wait for subprocess"); + } + + if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0) + return _error->Error("Child process failed"); + return true; } /*}}}*/ -- cgit v1.2.3