"Fossies" - the Fresh Open Source Software Archive

Member "apt-1.9.4/apt-pkg/deb/dpkgpm.h" (19 Sep 2019, 4225 Bytes) of package /linux/misc/apt-1.9.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "dpkgpm.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.8.2_vs_1.9.2.

    1 // -*- mode: cpp; mode: fold -*-
    2 // Description                              /*{{{*/
    3 /* ######################################################################
    4 
    5    DPKG Package Manager - Provide an interface to dpkg
    6    
    7    ##################################################################### */
    8                                     /*}}}*/
    9 #ifndef PKGLIB_DPKGPM_H
   10 #define PKGLIB_DPKGPM_H
   11 
   12 #include <apt-pkg/macros.h>
   13 #include <apt-pkg/packagemanager.h>
   14 #include <apt-pkg/pkgcache.h>
   15 
   16 #include <map>
   17 #include <string>
   18 #include <vector>
   19 #include <stdio.h>
   20 
   21 
   22 class pkgDepCache;
   23 namespace APT { namespace Progress { class PackageManager; } }
   24 
   25 
   26 class pkgDPkgPMPrivate;
   27 
   28 
   29 class pkgDPkgPM : public pkgPackageManager
   30 {
   31    private:
   32    pkgDPkgPMPrivate * const d;
   33 
   34    /** \brief record the disappear action and handle accordingly
   35 
   36       dpkg let packages disappear then they have no files any longer and
   37       nothing depends on them. We need to collect this as dpkg as well as
   38       APT doesn't know beforehand that the package will disappear, so the
   39       only possible option is to tell the user afterwards about it.
   40       To enhance the experience we also try to forward the auto-install
   41       flag so the disappear-causer(s) are not autoremoved next time -
   42       for the transfer to happen the disappeared version needs to depend
   43       on the package the flag should be forwarded to and this package
   44       needs to declare a Replaces on the disappeared package.
   45       \param pkgname Name of the package that disappeared
   46    */
   47    APT_HIDDEN void handleDisappearAction(std::string const &pkgname);
   48    APT_HIDDEN void handleCrossUpgradeAction(std::string const &pkgname);
   49 
   50    protected:
   51    int pkgFailures;
   52 
   53    // progress reporting
   54    struct DpkgState 
   55    {
   56       const char *state;     // the dpkg state (e.g. "unpack")
   57       const char *str;       // the human readable translation of the state
   58    };
   59 
   60    // the dpkg states that the pkg will run through, the string is 
   61    // the package, the vector contains the dpkg states that the package
   62    // will go through
   63    std::map<std::string,std::vector<struct DpkgState> > PackageOps;
   64    // the dpkg states that are already done; the string is the package
   65    // the int is the state that is already done (e.g. a package that is
   66    // going to be install is already in state "half-installed")
   67    std::map<std::string,unsigned int> PackageOpsDone;
   68 
   69    // progress reporting
   70    unsigned int PackagesDone;
   71    unsigned int PackagesTotal;
   72 
   73    public:
   74    struct Item
   75    {
   76       enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending,
   77          RemovePending, PurgePending } Op;
   78       std::string File;
   79       PkgIterator Pkg;
   80       Item(Ops Op,PkgIterator Pkg,std::string File = "") : Op(Op),
   81             File(File), Pkg(Pkg) {};
   82       Item() {};
   83    };
   84    protected:
   85    std::vector<Item> List;
   86 
   87    // Helpers
   88    bool RunScriptsWithPkgs(const char *Cnf);
   89    bool SendPkgsInfo(FILE * const F, unsigned int const &Version);
   90    void WriteHistoryTag(std::string const &tag, std::string value);
   91    std::string ExpandShortPackageName(pkgDepCache &Cache,
   92                                       const std::string &short_pkgname);
   93 
   94    // Terminal progress 
   95    void SendTerminalProgress(float percentage);
   96 
   97    // apport integration
   98    void WriteApportReport(const char *pkgpath, const char *errormsg);
   99 
  100    // dpkg log
  101    bool OpenLog();
  102    bool CloseLog();
  103 
  104    // helper
  105    void BuildPackagesProgressMap();
  106    void StartPtyMagic();
  107    void SetupSlavePtyMagic();
  108    void StopPtyMagic();
  109    
  110    // input processing
  111    void DoStdin(int master);
  112    void DoTerminalPty(int master);
  113    void DoDpkgStatusFd(int statusfd);
  114    void ProcessDpkgStatusLine(char *line);
  115 
  116    // The Actual installation implementation
  117    virtual bool Install(PkgIterator Pkg,std::string File) APT_OVERRIDE;
  118    virtual bool Configure(PkgIterator Pkg) APT_OVERRIDE;
  119    virtual bool Remove(PkgIterator Pkg,bool Purge = false) APT_OVERRIDE;
  120 
  121    virtual bool Go(APT::Progress::PackageManager *progress) APT_OVERRIDE;
  122 
  123    virtual void Reset() APT_OVERRIDE;
  124    
  125    public:
  126 
  127    explicit pkgDPkgPM(pkgDepCache *Cache);
  128    virtual ~pkgDPkgPM();
  129 
  130    APT_HIDDEN static bool ExpandPendingCalls(std::vector<Item> &List, pkgDepCache &Cache);
  131 };
  132 
  133 void SigINT(int sig);
  134 
  135 #endif