next up previous contents
Next: PKGFSCache Up: Definizioni delle classi Previous: PkgMgr   Indice

PkgDebian

/*
 * pkgmgr_debian.h
 * Copyright (C) 2004 Luca Ferroni <fferroni@cs.unibo.it>
 *
 * This class is the one that deals directly with the Debian APT
 * package manager
 *
 * This file is released under the GPL v2.
 * This file may be redistributed under the terms of the GNU Public
 * License.
 */
#ifndef _PKGMGR_DEBIAN_H_
#define _PKGMGR_DEBIAN_H_

#include <apt-pkg/pkgcache.h>
#include <apt-pkg/cachefile.h>

#define INFODIR "/var/lib/dpkg/info"
#define OR_DEPPREFIX "or" 
#define DEF_PKGMGR_OPTS " -qq " /* leave the starting and the ending space */

using namespace std;

class PkgDebian : public PkgManager {
   
   public:

        PkgDebian();
        virtual ~PkgDebian();

        virtual bool readCache();
        virtual void closeCache();
        virtual int findPkg(string, void**);
        virtual string CachePath() const;
        virtual int getInitCache(string &);
		
        //!Check status (and availability) of a package
        //!Return pkgstatus.$status
        virtual string checkstatus(void *);
        virtual int install(string);
        virtual int remove(string);
	
        //!Return the sections and priorities of the package manager.
        //!The int parameter passed is the value that will assume 
        //!sectVal and priorVal private members
        virtual string Sections(int);
        virtual string Priorities(int);
	
        //!Return the real path of a pkg in pkgfs.
        //!Following the config options, the real path can be:
        //!Section, Priority, Section/Priority, Priority/Section
        virtual string getRealPath(void *);

        //!Return the buffer full of the requested info
        virtual int getOwnedFiles(string,string &);

        //!In Debian, the first parameter is a pointer 
        //!to an instance of pkgCache::PkgIterator
        virtual int getInfo(void *, string &);
        virtual int getDepends(void *,string &);
        virtual int getRDepends(void *,string &);
        virtual bool isRDepToRemove(string);

        //!Get the amount of the available packages
        virtual int getNumAvail() {
                return nAvailable;
        }
	
        //!Update and Upgrade the system
        virtual int update();
        virtual int upgrade();

   private:

        //! Debian specific attributes
        pkgCacheFile CacheFile;
        pkgCache::PkgIterator foundPkg;

        //! Amount of available packages
        int nAvailable;
	
        //! Values of Section and Priority configuration options
        int sectionValue,priorityValue;
	
    protected:
	
        //! Fill a buffer with straight or reverse dependencies info 
        //! Debian APT uses the same object for both types
        void fillDepBuf(bool, pkgCache::DepIterator, 
			pkgCache::PkgIterator, string &);
	
};

#endif


2004-11-19