Permalink
Browse files

aptcc: Compile with APT 1.1

The latest APT is currently in Debian experimental, but will soon enter
unstable.
We do not preserve backwards compatibility here - there is already too
much cruft in the code, and every bit of that which we can get rid off
is worth it.
  • Loading branch information...
1 parent 213b555 commit 30bfee4d41944bbfbd7a40c7f3fa1004fc6effa9 @ximion ximion committed Nov 18, 2015
@@ -5,7 +5,6 @@ AM_CPPFLAGS = \
plugindir = $(PK_PLUGIN_DIR)
plugin_LTLIBRARIES = libpk_backend_aptcc.la
libpk_backend_aptcc_la_SOURCES = PkgList.cpp \
- pkg_acqfile.cpp \
acqpkitstatus.cpp \
deb-file.cpp \
matcher.cpp \
@@ -14,7 +13,7 @@ libpk_backend_aptcc_la_SOURCES = PkgList.cpp \
apt-utils.cpp \
apt-sourceslist.cpp \
OpPackageKitProgress.cpp \
- AptCacheFile.cpp \
+ AptCacheFile.cpp \
apt-intf.cpp \
pk-backend-aptcc.cpp
libpk_backend_aptcc_la_LIBADD = -lcrypt -lapt-pkg -lapt-inst -lutil $(PK_PLUGIN_LIBS)
@@ -37,8 +36,7 @@ EXTRA_DIST = 20packagekit \
apt-messages.h \
acqpkitstatus.h \
OpPackageKitProgress.h \
- AptCacheFile.h \
- pkg_acqfile.h
+ AptCacheFile.h
helperdir = $(datadir)/PackageKit/helpers/aptcc
dist_helper_DATA = \
@@ -21,9 +21,7 @@
#include "acqpkitstatus.h"
#include "apt-intf.h"
-#include "pkg_acqfile.h"
-#include <apt-pkg/acquire-item.h>
#include <apt-pkg/acquire-worker.h>
// AcqPackageKitStatus::AcqPackageKitStatus - Constructor
@@ -21,7 +21,7 @@
#ifndef ACQ_PKIT_STATUS_H
#define ACQ_PKIT_STATUS_H
-#include <apt-pkg/acquire.h>
+#include <apt-pkg/acquire-item.h>
#include <pk-backend.h>
#include "PkgList.h"
@@ -56,4 +56,11 @@ class AcqPackageKitStatus : public pkgAcquireStatus
AptIntf *m_apt;
};
+class pkgAcqArchiveSane : public pkgAcqArchive
+{
+public:
+ // This is insane the version is protected
+ pkgCache::VerIterator version() { return Version; }
+};
+
#endif
@@ -45,7 +45,6 @@
#include "gstMatcher.h"
#include "apt-messages.h"
#include "acqpkitstatus.h"
-#include "pkg_acqfile.h"
#include "deb-file.h"
#define RAMFS_MAGIC 0x858458f6
@@ -20,8 +20,7 @@
#include "apt-utils.h"
-#include "pkg_acqfile.h"
-
+#include <apt-pkg/acquire-item.h>
#include <glib/gstdio.h>
#include <fstream>
@@ -261,7 +260,7 @@ void getChangelogFile(const string &filename,
string descr("Changelog for ");
descr += name;
- new pkgAcqFileSane(fetcher, uri, descr, name, filename);
+ new pkgAcqFile(fetcher, uri, HashStringList(), 0, descr, name, "", filename);
ofstream out(filename.c_str());
if (fetcher->Run() == pkgAcquire::Failed) {
@@ -22,11 +22,9 @@
#ifndef APT_UTILS_H
#define APT_UTILS_H
-#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/acquire.h>
-
+#include <apt-pkg/pkgrecords.h>
#include <glib.h>
-
#include <pk-backend.h>
#include "AptCacheFile.h"
@@ -22,6 +22,7 @@
#include "deb-file.h"
+#include <glib.h>
#include <apt-pkg/init.h>
DebFile::DebFile(const string &filename) :
@@ -39,7 +40,11 @@ DebFile::DebFile(const string &filename) :
m_isValid = true;
}
- m_controlData = m_extractor->Section;
+ if(!m_controlData.Scan(m_extractor->Control,m_extractor->Length+2)) {
+ g_warning("DebFile: Scan failed.");
+ m_isValid = false;
+ return;
+ }
}
bool DebFile::isValid() const
@@ -1,67 +0,0 @@
-/* pkg_acqfile.cpp
- *
- * Copyright (c) 2002, 2005 Daniel Burrows
- * Copyright (c) 2009 Daniel Nicoletti <dantti12@gmail.com>
- * 2012 Matthias Klumpp <matthias@tenstral.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-// (based on pkg_changelog)
-
-#include "pkg_acqfile.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <apt-pkg/configuration.h>
-
-// Let's all sing a song about apt-pkg's brokenness..
-
-pkgAcqFileSane::pkgAcqFileSane(pkgAcquire *Owner, string URI,
- string Description, string ShortDesc,
- string filename) :
- Item(Owner)
-{
- Retries=_config->FindI("Acquire::Retries",0);
- DestFile=filename;
-
- Desc.URI=URI;
- Desc.Description=Description;
- Desc.Owner=this;
- Desc.ShortDesc=ShortDesc;
-
- QueueURI(Desc);
-}
-
-// Straight from acquire-item.cc
-/* Here we try other sources */
-void pkgAcqFileSane::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
-{
- ErrorText = LookupTag(Message,"Message");
-
- // This is the retry counter
- if (Retries != 0 &&
- Cnf->LocalOnly == false &&
- StringToBool(LookupTag(Message,"Transient-Failure"),false) == true) {
- Retries--;
- QueueURI(Desc);
- return;
- }
-
- Item::Failed(Message,Cnf);
-}
@@ -1,58 +0,0 @@
-/* pkg_acqfile.h
- *
- * Copyright (c) 2002, 2005 Daniel Burrows
- * Copyright (c) 2009 Daniel Nicoletti <dantti@gmail.com>
- * 2012 Matthias Klumpp <matthias@tenstral.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef PKG_ACQFILE_H
-#define PKG_ACQFILE_H
-
-#include <apt-pkg/acquire-item.h>
-
-/** \file pkg_acqfile.h
- */
-
-class pkgAcqFileSane : public pkgAcquire::Item
- // This is frustrating: pkgAcqFile is **almost** good enough, but has some
- // hardcoded stuff that makes it not quite work.
- //
- // Based heavily on that class, though.
-{
- pkgAcquire::ItemDesc Desc;
- string Md5Hash;
- unsigned int Retries;
-
-public:
- pkgAcqFileSane(pkgAcquire *Owner, string URI,
- string Description, string ShortDesc, string filename);
-
- void Failed(string Message, pkgAcquire::MethodConfig *Cnf);
- string MD5Sum() {return Md5Hash;}
- string DescURI() {return Desc.URI;}
- virtual ~pkgAcqFileSane() {}
-};
-
-class pkgAcqArchiveSane : public pkgAcqArchive
-{
-public:
- // This is insane the version is protected
- pkgCache::VerIterator version() { return Version; }
-};
-
-#endif
View
@@ -480,24 +480,22 @@ if test x$enable_aptcc = xyes; then
AC_SUBST(APTCC_CFLAGS)
AC_SUBST(APTCC_LIBS)
- AC_CHECK_LIB(apt-inst, main, , [AC_MSG_ERROR([Can't find the APT libraries -- please install libapt-pkg-dev])])
- AC_SUBST(APTCC_CFLAGS)
- AC_SUBST(APTCC_LIBS)
+ AC_CHECK_LIB(apt-inst, main, , [AC_MSG_ERROR([Can't find the APT libraries -- please install libapt-pkg-dev])])
+ AC_SUBST(APTCC_CFLAGS)
+ AC_SUBST(APTCC_LIBS)
PKG_CHECK_MODULES(GSTREAMER, gstreamer-1.0 gstreamer-base-1.0 gstreamer-plugins-base-1.0,,
[AC_MSG_ERROR([Can't find the gstreamer libraries -- please install libgstreamer-plugins-base1.0-dev])])
AC_SUBST(GSTREAMER_CFLAGS)
AC_SUBST(GSTREAMER_LIBS)
- AC_MSG_CHECKING([whether apt includes the automatic dependency removal patch (required)])
-
- AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[#include <apt-pkg/depcache.h>]],
- [[extern pkgDepCache::ActionGroup d;]]),
+ AC_MSG_CHECKING([whether apt is at least at version 1.1])
+ AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[#include <apt-pkg/pkgsystem.h>]],
+ [[_system->ArchitecturesSupported();]]),
AC_MSG_RESULT([yes]),
- AC_MSG_FAILURE([need libapt-pkg 0.7 or later]))
+ AC_MSG_FAILURE([need libapt-pkg 1.1 or later]))
AC_MSG_CHECKING([whether apt supports ddtp])
-
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[#include <apt-pkg/pkgcache.h>]],
[[pkgCache::DescIterator d;]]),
AC_MSG_RESULT([yes])

0 comments on commit 30bfee4

Please sign in to comment.