aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Oberritter <obi@opendreambox.org>2014-08-28 20:30:15 +0200
committerAndreas Oberritter <obi@opendreambox.org>2019-04-08 13:49:57 +0200
commitdcb88ac1fc5ed74141e7b035b4607f24ad3629d2 (patch)
treeccd4a016dd62f6317cbdaa54c3a96d6420b57d3c
parent06c9d36e83797be1b5db302c1390a67b3ee9090f (diff)
downloadopenembedded-core-contrib-dcb88ac1fc5ed74141e7b035b4607f24ad3629d2.tar.gz
apt: Introduce apt-opkg
'apt-opkg' provides a stripped-down opkg frontend with an apt backend. Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
-rw-r--r--meta/recipes-devtools/apt/apt/0001-apt-opkg-compatibility-shim-to-ease-migration-from-o.patch369
-rw-r--r--meta/recipes-devtools/apt/apt_1.2.12.bb13
2 files changed, 380 insertions, 2 deletions
diff --git a/meta/recipes-devtools/apt/apt/0001-apt-opkg-compatibility-shim-to-ease-migration-from-o.patch b/meta/recipes-devtools/apt/apt/0001-apt-opkg-compatibility-shim-to-ease-migration-from-o.patch
new file mode 100644
index 0000000000..a1139951c1
--- /dev/null
+++ b/meta/recipes-devtools/apt/apt/0001-apt-opkg-compatibility-shim-to-ease-migration-from-o.patch
@@ -0,0 +1,369 @@
+From f08346a2ab4b0da2099197d2f81131b6869fe8cb Mon Sep 17 00:00:00 2001
+From: Andreas Oberritter <obi@opendreambox.org>
+Date: Wed, 6 Apr 2016 00:46:49 +0200
+Subject: [PATCH] apt-opkg: compatibility shim to ease migration from opkg to
+ apt-get
+
+Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
+---
+ apt-private/private-cmndline.cc | 17 ++
+ apt-private/private-cmndline.h | 1 +
+ cmdline/apt-opkg.cc | 283 ++++++++++++++++++++++++++++++++
+ cmdline/makefile | 7 +
+ 4 files changed, 308 insertions(+)
+ create mode 100644 cmdline/apt-opkg.cc
+
+diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
+index 829085916..644c3db16 100644
+--- a/apt-private/private-cmndline.cc
++++ b/apt-private/private-cmndline.cc
+@@ -301,6 +301,22 @@ static bool addArgumentsAPTSortPkgs(std::vector<CommandLine::Args> &Args, char c
+ return true;
+ }
+ /*}}}*/
++static bool addArgumentsAPTOpkg(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
++{
++ if (CmdMatches("info", "list", "list_installed", "list-installed",
++ "list_upgradable", "list-upgradable", "status")) {
++ ;
++ } else if (CmdMatches("update", "upgrade", "install", "remove")) {
++ addArg(0, "autoremove", "APT::Get::AutomaticRemove", 0);
++ addArg(0, "force-maintainer", "APT::Opkg::ForceMaintainer", 0);
++ addArg(0, "noaction", "APT::Get::Simulate", 0);
++ } else {
++ return false;
++ }
++
++ return true;
++}
++ /*}}}*/
+ static bool addArgumentsAPT(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
+ {
+ if (CmdMatches("list"))
+@@ -351,6 +367,7 @@ std::vector<CommandLine::Args> getCommandArgs(APT_CMD const Program, char const
+ case APT_CMD::APT_HELPER: addArgumentsAPTHelper(Args, Cmd); break;
+ case APT_CMD::APT_INTERNAL_SOLVER: addArgumentsAPTInternalSolver(Args, Cmd); break;
+ case APT_CMD::APT_MARK: addArgumentsAPTMark(Args, Cmd); break;
++ case APT_CMD::APT_OPKG: addArgumentsAPTOpkg(Args, Cmd); break;
+ case APT_CMD::APT_SORTPKG: addArgumentsAPTSortPkgs(Args, Cmd); break;
+ }
+
+diff --git a/apt-private/private-cmndline.h b/apt-private/private-cmndline.h
+index 6235ef9f5..ac770475d 100644
+--- a/apt-private/private-cmndline.h
++++ b/apt-private/private-cmndline.h
+@@ -20,6 +20,7 @@ enum class APT_CMD {
+ APT_HELPER,
+ APT_INTERNAL_SOLVER,
+ APT_MARK,
++ APT_OPKG,
+ APT_SORTPKG,
+ };
+ struct aptDispatchWithHelp
+diff --git a/cmdline/apt-opkg.cc b/cmdline/apt-opkg.cc
+new file mode 100644
+index 000000000..82da9a2f2
+--- /dev/null
++++ b/cmdline/apt-opkg.cc
+@@ -0,0 +1,283 @@
++// vim: tabstop=8 softtabstop=0 expandtab shiftwidth=3 smarttab
++#include <config.h>
++
++#include <apt-pkg/acquire-item.h>
++#include <apt-pkg/cacheset.h>
++#include <apt-pkg/error.h>
++#include <apt-pkg/fileutl.h>
++#include <apt-pkg/init.h>
++#include <apt-pkg/pkgrecords.h>
++#include <apt-pkg/pkgsystem.h>
++#include <apt-pkg/policy.h>
++#include <apt-pkg/sourcelist.h>
++#include <apt-pkg/strutl.h>
++#include <apt-pkg/tagfile.h>
++#include <apt-pkg/update.h>
++
++#include <apt-private/private-cachefile.h>
++#include <apt-private/private-cacheset.h>
++#include <apt-private/private-cmndline.h>
++#include <apt-private/private-install.h>
++#include <apt-private/private-list.h>
++#include <apt-private/private-main.h>
++#include <apt-private/private-output.h>
++#include <apt-private/private-update.h>
++#include <apt-private/private-upgrade.h>
++
++static bool ShowHelp(CommandLine &) /*{{{*/
++{
++ std::cout <<
++ _("usage: apt-opkg [options...] sub-command [arguments...]\n"
++ "where sub-command is one of:\n"
++
++ "\nPackage Manipulation:\n"
++ "\tupdate Update list of available packages\n"
++ "\tupgrade Upgrade installed packages\n"
++ "\tinstall <pkgs> Install package(s)\n"
++ "\tremove <pkgs|glob> Remove package(s)\n"
++
++ "\nInformational Commands:\n"
++ "\tlist List available packages\n"
++ "\tlist-installed List installed packages\n"
++ "\tlist-upgradable List installed and upgradable packages\n"
++ "\tinfo [pkg|glob] Display all info for <pkg>\n"
++ "\tstatus [pkg|glob] Display all status for <pkg>\n"
++
++ "\nForce Options:\n"
++ "\t--force-maintainer Overwrite preexisting config files\n"
++ "\t--noaction No action -- test only\n"
++ "\t--autoremove Remove packages that were installed\n"
++ "\t automatically to satisfy dependencies\n"
++ "\n"
++ " glob could be something like 'pkgname*' '*file*' or similar\n"
++ " e.g. opkg remove 'libncur*'\n");
++
++ return true;
++}
++ /*}}}*/
++static const char *OpkgInfoOrder[] = {
++ "Package",
++ "Version",
++ "Depends",
++ "Recommends",
++ "Suggests",
++ "Provides",
++ "Replaces",
++ "Conflicts",
++ "Status",
++ "Section",
++ "Essential",
++ "Architecture",
++ "Maintainer",
++ "MD5sum",
++ "Size",
++ "Filename",
++ "Conffiles",
++ "Source",
++ "Description",
++ "Installed-Time",
++ "Tags",
++ 0
++};
++
++static bool OpkgDisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V)
++{
++ pkgCache *Cache = CacheFile.GetPkgCache();
++ if (unlikely(Cache == NULL))
++ return false;
++
++ pkgDepCache *depCache = CacheFile.GetDepCache();
++ if (unlikely(depCache == NULL))
++ return false;
++
++ // Find an appropriate file
++ pkgCache::VerFileIterator Vf = V.FileList();
++ for (; Vf.end() == false; ++Vf)
++ if ((Vf.File()->Flags & pkgCache::Flag::NotSource) == 0)
++ break;
++ if (Vf.end() == true)
++ Vf = V.FileList();
++
++ // Check and load the package list file
++ pkgCache::PkgFileIterator I = Vf.File();
++ if (I.IsOk() == false)
++ return _error->Error("Package file %s is out of sync.",
++ I.FileName());
++
++ // find matching sources.list metaindex
++ pkgSourceList *SrcList = CacheFile.GetSourceList();
++ pkgIndexFile *Index;
++ if (SrcList->FindIndex(I, Index) == false &&
++ _system->FindIndex(I, Index) == false)
++ return _error->Error("Can not find indexfile for Package %s (%s)",
++ V.ParentPkg().Name(), V.VerStr());
++
++ // Read the record
++ FileFd PkgF;
++ if (!PkgF.Open(I.FileName(), FileFd::ReadOnly, FileFd::Extension))
++ return false;
++
++ pkgTagSection Tags;
++ pkgTagFile TagF(&PkgF);
++ if (!TagF.Jump(Tags, V.FileList()->Offset))
++ return _error->Error("Internal Error, Unable to parse a package record");
++
++ std::vector<pkgTagSection::Tag> RW;
++ // we use the translated description
++ RW.push_back(pkgTagSection::Tag::Remove("Description"));
++ RW.push_back(pkgTagSection::Tag::Remove("Description-md5"));
++
++ FileFd stdoutfd;
++ if (stdoutfd.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly, false) == false ||
++ Tags.Write(stdoutfd, OpkgInfoOrder, RW) == false || stdoutfd.Close() == false)
++ return _error->Error("Internal Error, Unable to parse a package record");
++
++ // write the description
++ pkgRecords Recs(*Cache);
++ pkgCache::DescIterator Desc = V.TranslatedDescription();
++ if (Desc.end() == false) {
++ pkgRecords::Parser &P = Recs.Lookup(Desc.FileList());
++ std::cout << "Description: " << P.LongDesc() << std::endl;
++ }
++ // write a final newline (after the description)
++ std::cout << std::endl;
++
++ return true;
++}
++
++static bool OpkgInfoStatus(CommandLine &cmdline, APT::CacheSetHelper::VerSelector select)
++{
++ pkgCacheFile CacheFile;
++ APT::CacheSetHelper helper;
++
++ APT::VersionList const verset = APT::VersionList::FromCommandLine(CacheFile, &cmdline.FileList[1], select, helper);
++ for (APT::VersionList::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver)
++ if (!OpkgDisplayRecord(CacheFile, Ver))
++ return false;
++
++ if (verset.empty())
++ _error->Notice("No packages found");
++
++ return true;
++}
++
++static bool OpkgInfo(CommandLine &cmdline)
++{
++ return OpkgInfoStatus(cmdline, APT::CacheSetHelper::ALL);
++}
++
++static bool OpkgClean()
++{
++ std::string const archivedir = _config->FindDir("Dir::Cache::archives");
++
++ // Lock the archive directory
++ FileFd Lock;
++ if (_config->FindB("Debug::NoLocking",false) == false) {
++ int lock_fd = GetLock(archivedir + "lock");
++ if (lock_fd < 0)
++ return _error->Error(_("Unable to lock the download directory"));
++ Lock.Fd(lock_fd);
++ }
++
++ pkgAcquire Fetcher;
++ Fetcher.Clean(archivedir);
++ Fetcher.Clean(archivedir + "partial/");
++ return true;
++}
++
++static bool OpkgInstall(CommandLine &cmdline)
++{
++ return DoInstall(cmdline) && OpkgClean();
++}
++
++static bool OpkgList(CommandLine &cmdline)
++{
++ _config->Set("APT::Cmd::use-format", true);
++ _config->Set("APT::Cmd::format", "${Package} - ${candidate:Version} - ${Description}");
++ _config->Set("quiet", 2);
++
++ return DoList(cmdline);
++}
++
++static bool OpkgListInstalled(CommandLine &cmdline)
++{
++ _config->Set("APT::Cmd::Installed", true);
++ _config->Set("APT::Cmd::use-format", true);
++ _config->Set("APT::Cmd::format", "${Package} - ${installed:Version} - ${Description}");
++ _config->Set("quiet", 2);
++
++ cmdline.FileList[0] = "list";
++ return DoList(cmdline);
++}
++
++static bool OpkgListUpgradable(CommandLine &cmdline)
++{
++ _config->Set("APT::Cmd::Upgradable", true);
++ _config->Set("APT::Cmd::use-format", true);
++ _config->Set("APT::Cmd::format", "${Package} - ${installed:Version} - ${candidate:Version}");
++ _config->Set("quiet", 2);
++
++ cmdline.FileList[0] = "list";
++ return DoList(cmdline);
++}
++
++static bool OpkgStatus(CommandLine &cmdline)
++{
++ return OpkgInfoStatus(cmdline, APT::CacheSetHelper::INSTALLED);
++}
++
++static bool OpkgUpgrade(CommandLine &cmdline)
++{
++ _config->Set("APT::Get::Show-Upgraded", true);
++
++ cmdline.FileList[0] = "dist-upgrade";
++ return DoDistUpgrade(cmdline) && OpkgClean();
++}
++
++static std::vector<aptDispatchWithHelp> GetCommands()
++{
++ return {
++ {"update", &DoUpdate, nullptr},
++ {"upgrade", &OpkgUpgrade, nullptr},
++ {"install", &OpkgInstall, nullptr},
++ {"remove", &DoInstall, nullptr},
++ {"dist-upgrade", &OpkgUpgrade, nullptr}, // not available in opkg, but needed by CmdL.DispatchArg
++ {"list", &OpkgList, nullptr},
++ {"list_installed", &OpkgListInstalled, nullptr},
++ {"list-installed", &OpkgListInstalled, nullptr},
++ {"list_upgradable", &OpkgListUpgradable, nullptr},
++ {"list-upgradable", &OpkgListUpgradable, nullptr},
++ {"info", &OpkgInfo, nullptr},
++ {"status", &OpkgStatus, nullptr},
++ {nullptr, nullptr, nullptr},
++ };
++}
++
++int main(int argc,const char *argv[]) /*{{{*/
++{
++ // Parse the command line and initialize the package library
++ CommandLine CmdL;
++ auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_OPKG, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
++
++ if (CmdL.FileSize() == 0) {
++ ShowHelp(CmdL);
++ return 1;
++ }
++
++ if (Glob("/etc/apt/trusted.gpg.d/*.gpg").size() == 0)
++ _config->Set("APT::Get::AllowUnauthenticated", true);
++ _config->Set("APT::Get::Assume-Yes", true);
++ _config->Set("APT::Get::force-yes", true);
++ _config->Set("quiet", 1);
++
++ if (_config->FindB("APT::Opkg::ForceMaintainer"))
++ _config->Set("Dpkg::Options::", "--force-confnew");
++
++ InitSignals();
++ InitOutput();
++
++ CheckIfSimulateMode(CmdL);
++
++ return DispatchCommandLine(CmdL, Cmds);
++}
++ /*}}}*/
+diff --git a/cmdline/makefile b/cmdline/makefile
+index 6d21b0803..a9d2468c9 100644
+--- a/cmdline/makefile
++++ b/cmdline/makefile
+@@ -40,6 +40,13 @@ LIB_MAKES = apt-pkg/makefile apt-private/makefile
+ SOURCE = apt-cdrom.cc
+ include $(PROGRAM_H)
+
++# The apt-opkg program
++PROGRAM=apt-opkg
++SLIBS = -lapt-pkg -lapt-private
++LIB_MAKES = apt-pkg/makefile apt-private/makefile
++SOURCE = apt-opkg.cc
++include $(PROGRAM_H)
++
+ # The apt-mark program
+ PROGRAM=apt-mark
+ SLIBS = -lapt-pkg -lapt-private $(INTLLIBS)
diff --git a/meta/recipes-devtools/apt/apt_1.2.12.bb b/meta/recipes-devtools/apt/apt_1.2.12.bb
index 855f543752..90168582f0 100644
--- a/meta/recipes-devtools/apt/apt_1.2.12.bb
+++ b/meta/recipes-devtools/apt/apt_1.2.12.bb
@@ -17,6 +17,7 @@ SRC_URI = "http://snapshot.debian.org/archive/debian/20160526T162943Z/pool/main/
file://0001-apt-1.2.12-Fix-musl-build.patch \
file://0001-remove-Wsuggest-attribute-from-CFLAGS.patch \
file://0001-fix-the-gcc-version-check.patch \
+ file://0001-apt-opkg-compatibility-shim-to-ease-migration-from-o.patch \
file://apt.conf.in \
"
SRC_URI[md5sum] = "80f6f0ef110a45a7e5af8a9d233fb0e7"
@@ -26,7 +27,7 @@ SRC_URI[sha256sum] = "e820d27cba73476df4abcff27dadd1b5847474bfe85f7e9202a9a07526
# so we check the latest upstream from a directory that does get updated
UPSTREAM_CHECK_URI = "${DEBIAN_MIRROR}/main/a/apt/"
-inherit autotools gettext useradd
+inherit autotools gettext update-alternatives useradd
AUTOTOOLS_AUXDIR = "${S}/buildlib"
@@ -37,6 +38,7 @@ PACKAGECONFIG ??= "lzma"
PACKAGECONFIG[lzma] = "ac_cv_lib_lzma_lzma_easy_encoder=yes,ac_cv_lib_lzma_lzma_easy_encoder=no,xz"
PACKAGECONFIG[bz2] = "ac_cv_lib_bz2_BZ2_bzopen=yes,ac_cv_lib_bz2_BZ2_bzopen=no,bzip2"
PACKAGECONFIG[lz4] = "ac_cv_lib_lz4_LZ4F_createCompressionContext=yes,ac_cv_lib_lz4_LZ4F_createCompressionContext=no,lz4"
+PACKAGECONFIG[opkg] = ",,,"
USE_NLS_class-native = "yes"
@@ -51,6 +53,7 @@ USERADD_PARAM_${PN} = "--system --no-create-home --home-dir /nonexistent --shell
PROGRAMS = " \
apt apt-cache apt-cdrom apt-config apt-extracttemplates \
apt-ftparchive apt-get apt-key apt-mark apt-sortpkgs \
+ ${@bb.utils.contains('PACKAGECONFIG', 'opkg', 'apt-opkg', '', d)} \
"
inherit systemd
@@ -120,7 +123,7 @@ do_install_append_class-target() {
echo 'APT::Architecture "${DPKG_ARCH}";' > ${D}${sysconfdir}/apt/apt.conf
}
-PACKAGES =+ "${PN}-dselect ${PN}-transport-https ${PN}-utils lib${PN}-inst lib${PN}-pkg"
+PACKAGES =+ "${PN}-dselect ${PN}-opkg ${PN}-transport-https ${PN}-utils lib${PN}-inst lib${PN}-pkg"
RDEPENDS_${PN} = "dpkg debianutils"
RDEPENDS_${PN}-dselect = "bash perl"
@@ -128,8 +131,11 @@ RDEPENDS_${PN}-dselect = "bash perl"
RRECOMMENDS_${PN} = "gnupg"
RRECOMMENDS_${PN}_class-native = ""
+RPROVIDES_${PN}-opkg = "opkg"
+
FILES_${PN} += "${libdir}/dpkg ${systemd_system_unitdir}/apt-daily.service"
FILES_${PN}-dselect = "${libdir}/dpkg/methods/apt"
+FILES_${PN}-opkg = "${bindir}/apt-opkg"
FILES_${PN}-transport-https = "${libdir}/apt/methods/https"
FILES_${PN}-utils = "${bindir}/apt-extracttemplates \
${bindir}/apt-ftparchive \
@@ -137,4 +143,7 @@ FILES_${PN}-utils = "${bindir}/apt-extracttemplates \
FILES_lib${PN}-inst = "${libdir}/libapt-inst${SOLIBS}"
FILES_lib${PN}-pkg = "${libdir}/libapt-pkg${SOLIBS}"
+ALTERNATIVE_${PN}-opkg = "${@bb.utils.contains('PACKAGECONFIG', 'opkg', 'opkg', '', d)}"
+ALTERNATIVE_TARGET[opkg] = "${bindir}/apt-opkg"
+
BBCLASSEXTEND = "native"