diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..604e11363 --- /dev/null +++ b/.clang-format @@ -0,0 +1,195 @@ +--- +Language: Cpp +BasedOnStyle: Google +Standard: Cpp11 + + +# Characters per line +ColumnLimit: 120 + + +# Do not wrap comments according to ColumnLimit +ReflowComments: false + + +# Indentation +IndentWidth: 4 +AccessModifierOffset: -4 +UseTab: false + +# Keep up to 2 empty lines +MaxEmptyLinesToKeep: 2 + + +# sort and group includes: c++, system, project +SortIncludes: true +IncludeBlocks: Regroup +IncludeCategories: + # C++ Standard Library headers + - Regex: '<[[:alnum:]_-]+>' + Priority: 5 + # system libraries + - Regex: '<.+>' + Priority: 4 + # project includes - libdnf absolute paths + - Regex: '"libdnf/.+"' + Priority: 3 + # project includes - libdnf-cli absolute paths + - Regex: '"libdnf-cli/.+"' + Priority: 2 + # project includes + - Regex: '".+"' + Priority: 1 + + +# Always break after an open bracket, if the parameters don't fit on a single line, e.g.: +# +# someLongFunction( +# argument1, argument2); +# +AlignAfterOpenBracket: AlwaysBreak + + +# Forbid simple braced statements on a single line. +# +# Allowed: +# if (a) { +# return; +# } +# +# Forbidden: +# if (a) { return; } +# +AllowShortBlocksOnASingleLine: false + + +# Forbid short case labels on a single line. +# +# Allowed: +# switch (a) { +# case 1: +# x = 1; +# break; +# } +# +# Forbidden: +# switch (a) { +# case 1: x = 1; break; +# case 2: return; +# } +# +AllowShortCaseLabelsOnASingleLine: false + + +# Allow only single line methods defined inside a class. +# +# Allowed: +# class Foo { +# void f() { foo(); } +# }; +# void f() { +# foo(); +# } +# +# Forbidden: +# void f() { foo(); } +AllowShortFunctionsOnASingleLine: Inline + + +# Forbid if statements on a single line. +# +# Allowed: +# if (a) +# return ; +# else { +# return; +# } +# +# Forbidden: +# if (a) return; +# else +# return; +# +AllowShortIfStatementsOnASingleLine: Never + + +# Forbid loops on a single line. +# +# Allowed: +# while (i < 1) { +# i--; +# } +# +# Forbidden: +# while (i < 1) i--; +# +AllowShortLoopsOnASingleLine: false + + +# Force middle pointer alignment. +# +# Examples: +# char * str; +# const std::string & str; +# +DerivePointerAlignment: false +PointerAlignment: Middle + + +# Allow only one argument/parameter per line. +# +# Allowed: +# void f(int aaaaaaaaaaaaaaaaaaaa, +# int aaaaaaaaaaaaaaaaaaaa, +# int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {} +# +# Forbidden: +# void f(int aaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaa, +# int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {} +# +BinPackArguments: false +BinPackParameters: false + + +# If the function declaration doesn't fit on a line, put all parameters on the next line. +# +# Allowed: +# void myFunction( +# int a, int b, int c, int d, int e); +# +# Forbidden: +# void myFunction(int a, +# int b, +# int c, +# int d, +# int e); +# +AllowAllParametersOfDeclarationOnNextLine: true + + +# Allow only per line constructor intitializers. +# +# Allowed: +# MyClass::MyClass() +# : member0(0) +# , member1(2) +# +# Forbidden: +# MyClass::MyClass() : +# member0(0), member1(2) +# +AllowAllConstructorInitializersOnNextLine: false +BreakConstructorInitializers: BeforeComma + + +# Align consecutive C/C++ preprocessor macros. +# +# Example: +# #define SHORT_NAME 42 +# #define LONGER_NAME 0x007f +# #define EVEN_LONGER_NAME (2) +# #define foo(x) (x * x) +# #define bar(y, z) (y + z) +# +AlignConsecutiveMacros: true +... diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..6f50d123a --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,31 @@ +--- +Checks: '*,readability-*,-google-runtime-references,-modernize-use-trailing-return-type,-hicpp-signed-bitwise,-fuchsia*,-modernize-use-nodiscard' +WarningsAsErrors: '' +HeaderFilterRegex: '' +AnalyzeTemporaryDtors: false +FormatStyle: none +CheckOptions: + - key: readability-identifier-naming.ClassCase + value: CamelCase + - key: readability-identifier-naming.FunctionCase + value: lower_case + - key: readability-identifier-naming.GlobalConstantCase + value: UPPER_CASE + - key: readability-identifier-naming.NamespaceCase + value: lower_case + - key: readability-identifier-naming.ParameterCase + value: lower_case + - key: readability-identifier-naming.StructCase + value: CamelCase + - key: readability-identifier-naming.VariableCase + value: lower_case + + - key: readability-implicit-bool-conversion.AllowIntegerConditions + value: '0' + - key: readability-implicit-bool-conversion.AllowPointerConditions + value: '1' + - key: readability-inconsistent-declaration-parameter-name.IgnoreMacros + value: '1' + - key: readability-inconsistent-declaration-parameter-name.Strict + value: '1' +... diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..453465913 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +build/* +__pycache__ +*.log +*.src.rpm +*.tar.gz diff --git a/AUTHORS.md b/AUTHORS.md new file mode 100644 index 000000000..c570c248d --- /dev/null +++ b/AUTHORS.md @@ -0,0 +1,84 @@ +The current Red Hat's Software Management / DNF team +==================================================== +Aleš Matěj +Daniel Mach +Jaroslav Mracek +Jaroslav Rohel +Lukáš Hrázký +Marek Blaha +Nicola Sella +Pavla Kratochvilova + + +All contributors to libdnf (incl. hawkey and libhif) +==================================================== +Adam Williamson +Ales Kozumplik +Aleš Matěj +Benjamin Kircher +Bernhard Rosenkränzer +Colin Walters +Corentin Noël +Dan Callaghan +Dan Horák +Daniel Mach +Eduard Čuba +Elan Ruusamäe +Giuseppe Scrivano +Christian Brunner +Courtney Pacheco +Igor Gnatenko +iliana weller +James Cassell +Jan Pazdziora +Jan Silhan +Jaroslav Mracek +Jaroslav Rohel +Jeff Law +Jens Petersen +Jonathan Dieter +Jonathan Lebon +Jonathan Wakely +Jo Shields +Kalev Lember +Kevin Howell +Kevin Kofler +Khem Raj +Lukáš Hrázký +Lumir Balhar +Marek Blaha +Marius Vollmer +Martin Hatina +Martin Sehnoutka +Matthew Barnes +Mihai Moldovan +Michael Mraka +Michael Schroeder +Michal Domonkos +Michal Luscon +Michal Minar +Michal Ruprich +Michal Toman +Neal Gompa +Nils Philippsen +Panu Matilainen +Pat Riehecky +Pavla Kratochvilova +Peter Hjalmarsson +Peter Robinson +Petr Viktorin +Radek Holy +Rafael Fonseca +Richard Hughes +Ruixin +Scott Tsai +Tomas Mlcoch +Tomasz Kłoczko +Tyrone Abdy +Valentina Mukhamedzhanova +Ville Skyttä +Vít Ondruch +Yavor Atanasov +Yuri Chornoivan +Zdeněk Pavlas +Zhang Xianwei diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..0e77360b0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,106 @@ +message("Running CMake on libdnf...") +cmake_minimum_required(VERSION 3.5) + + +include(VERSION.cmake) +project(libdnf LANGUAGES CXX VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) +cmake_policy(VERSION ${CMAKE_VERSION}) + + +message("Building ${PROJECT_NAME} version ${PROJECT_VERSION}") + + +if(DEFINED PACKAGE_VERSION) + if(NOT ${PACKAGE_VERSION} STREQUAL ${PROJECT_VERSION}) + message(FATAL_ERROR "Variables PROJECT_VERSION and PACKAGE_VERSION differ. Make sure the versions in VERSION.cmake and the value provided via -DPACKAGE_VERSION are in sync.") + endif() +endif() + + +# build options - components (sub-packages) +option(WITH_DNFDAEMON_CLIENT "Build command-line interface for dnfdaemon" ON) +option(WITH_DNFDAEMON_SERVER "Build package management service with a DBus interface" ON) +option(WITH_LIBDNF_CLI "Build library for working with a terminal in a command-line package manager" ON) +option(WITH_MICRODNF "Build microdnf command-line package manager" ON) + +# build options - features +option(WITH_COMPS "Build with comps groups and environments support" ON) +option(WITH_MODULEMD "Build with modulemd modules support" ON) +option(WITH_ZCHUNK "Build with zchunk delta compression support" ON) + +# build options - documentation +option(WITH_HTML "Build HTML documentation" ON) +option(WITH_MAN "Build man pages" ON) + +# build options - tests +option(WITH_TESTS "Build tests" ON) + +# build options - debugging +option(WITH_SANITIZERS "Build with address, leak and undefined sanitizers (DEBUG ONLY)" OFF) + +# build options - bindings +option(WITH_GO "Build Go bindings" ON) +option(WITH_PERL5 "Build Perl 5 bindings" ON) +option(WITH_PYTHON3 "Build Python 3 bindings" ON) +option(WITH_RUBY "Build Ruby bindings" ON) + + +# includes +include(GNUInstallDirs) + + +# common dependencies +find_package(PkgConfig REQUIRED) + + +# C++ standard +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# warnings +add_compile_options(-Wall -Wextra -Werror) +add_compile_options(-Wcast-align -Wformat-nonliteral -Wmissing-format-attribute -Wredundant-decls -Wsign-compare -Wtype-limits -Wuninitialized -Wwrite-strings) +# not sure about the conversion warnings being errors; review later +add_compile_options(-Wconversion) + +# linker options +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # clang doesn't support this option + add_compile_options(-Wl,--as-needed) +endif() + + +if(WITH_SANITIZERS) + message(WARNING "Building with sanitizers enabled!") + set(SANITIZER_FLAGS "-fsanitize=address -fsanitize=leak -fsanitize=undefined") + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # requires: compiler-rt package on Fedora + set(SANITIZER_FLAGS "${SANITIZER_FLAGS} -static-libsan") + else() + set(SANITIZER_FLAGS "${SANITIZER_FLAGS} -static-libasan -static-liblsan -static-libubsan") + endif() + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_FLAGS}") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SANITIZER_FLAGS}") +endif() + + +include_directories("${PROJECT_SOURCE_DIR}/include") + + +# libdnf +add_subdirectory("include") +add_subdirectory("libdnf") +add_subdirectory("libdnf-cli") +add_subdirectory("doc") +add_subdirectory("bindings") + +# dnfdaemon +add_subdirectory("dnfdaemon-server") +add_subdirectory("dnfdaemon-client") + +# microdnf +add_subdirectory("microdnf") + +# tests +enable_testing() +add_subdirectory("test") diff --git a/CODING_STYLE.md b/CODING_STYLE.md new file mode 100644 index 000000000..dc69ef916 --- /dev/null +++ b/CODING_STYLE.md @@ -0,0 +1,70 @@ +Coding style +============ + +Character case: + +* Types: CamelCase +* Classes: CamelCase +* Functions: snake_case +* Variables: snake_case +* Arguments: snake_case +* Constants: UPPER_CASE + + +File system hierarchy: + +* Directories: lower_case, avoid separators if possible +* Files: snake_case.{cpp,hpp} + + +C++ coding style: + +* Use clang-format and clang-tidy to check your coding style before you submit a pull request +* -std=c++17 +* Indent by 4 spaces +* 120 characters per line +* Includes grouped and alphabetically ordered within each group + + * project + * project - "libdnf-cli/" absolute paths + * project - "libdnf/" absolute paths + * 3rd party + * standard library + +* Project includes must use full path in the project or plain file name (includes in the same directory) +* Use C++ style comments: ``//`` +* Use three forward slashes for docstrings: ``///`` +* Use templates and lambdas only if really necessary +* Use ``// clang-format off|on`` if auto-formatted code is not readable +* See .clang-format for more details and examples + + +Python coding style: + +* 120 characters per line +* Follow pep8 + + +Project layout +============== +``` + + +-- bindings # everything related to SWIG bindings goes here + | +-- # go, perl5, python3, ruby + | | +-- libdnf # language specific bindings for libdnf + | | +-- libdnf_cli # language specific bindings for libdnf-cli + | +-- libdnf # SWIG *.i files for libdnf + | +-- libdnf_cli # SWIG *.i files for libdnf-cli + +-- doc # documentation + +-- include # public headers + | +-- libdnf # libdnf public C++ headers + | +-- libdnf-cli # libdnf-cli public C++ headers + +-- libdnf # libdnf code and private headers (core libdnf functionality) + | +-- # + +-- libdnf-cli # libdnf-cli code and private headers (argument parser, progressbars, tables, ...) + | +-- # + +-- dnfdaemon-client # command line client for dnfdaemon-server + +-- dnfdaemon-server # DBus package manager service + +-- microdnf # microdnf command line package manager + +-- test # tests; similar layout to the bindings +``` diff --git a/COPYING.md b/COPYING.md new file mode 100644 index 000000000..75eb1d6fa --- /dev/null +++ b/COPYING.md @@ -0,0 +1,24 @@ +Copying +======= +Libdnf is covered under two separate licenses: GPLv2+ and LGPLv2.1+. + + +GPLv2+ +------ +The entire code base may be distributed under the terms of the +GNU General Public License version 2 and any later version (GPLv2+). +The complete text of the license is available in the gpl-2.0.txt file. + + +LGPLv2.1+ +--------- +Alternatively, all of the source code in 'libdnf', 'libdnf-cli', 'include' +and 'bindings' subdirectories of the libdnf source code distribution as well +as any code derived from that code may instead be distributed under the +GNU Lesser General Public License version 2.1 and any later version (LGPLv2.1+), +at the choice of the distributor. +The complete text of the license is available in the lgpl-2.1.txt file. + +This alternative is provided to enable applications to be linked against +the libdnf and libdnf-cli libraries and their bindings to other programming +languages without forcing such applications to be distributed under the GPL. diff --git a/DCO b/DCO new file mode 100644 index 000000000..8201f9921 --- /dev/null +++ b/DCO @@ -0,0 +1,37 @@ +Developer Certificate of Origin +Version 1.1 + +Copyright (C) 2004, 2006 The Linux Foundation and its contributors. +1 Letterman Drive +Suite D4700 +San Francisco, CA, 94129 + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + + +Developer's Certificate of Origin 1.1 + +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +(b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +(c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +(d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. diff --git a/README.md b/README.md new file mode 100644 index 000000000..e160b559a --- /dev/null +++ b/README.md @@ -0,0 +1,92 @@ +libdnf +====== + +* Libdnf is a package management library. +* It's a backed of [DNF](https://github.com/rpm-software-management/dnf) package manager. +* Supported content types are: + + * RPM packages + * repomd repositories + * modulemd modules + * comps - categories, environments and groups + * updateinfo + + +:warning: **The current (dnf-5-devel) branch is subject of a major rewrite. The API/ABI is currently unstable** :warning: + + +Documentation +============= + +* For HTML documentation see https://libdnf.readthedocs.io/ +* The header files are documented because documentation is mainly generated from them + + +Reporting issues +================ + +* [Red Hat Bugzilla](https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=libdnf) is the preferred way of filing issues. [[backlog](https://bugzilla.redhat.com/buglist.cgi?bug_status=__open__&product=Fedora&component=libdnf)] +* [GitHub issues](https://github.com/rpm-software-management/libdnf/issues/new) are also accepted. [[backlog](https://github.com/rpm-software-management/libdnf/issues)] + + +Contributing +============ + +* By contributing to this project you agree to the Developer Certificate of Origin (DCO). + This document is a simple statement that you, as a contributor, + have the legal right to submit the contribution. See the [DCO](DCO) file for details. +* All contributions to this project are licensed under [LGPLv2.1+](lgpl-2.1.txt) or [GPLv2+](gpl-2.0.txt). + See the [License](#license) section for details. + + +Writing patches +--------------- + +* Please follow the [coding style](CODING_STYLE.md) +* When a patch is ready, submit a pull request +* It is a good practice to write documentation and unit tests as part of the patches + + +Building +-------- +To install build requirements, run:: + + $ dnf builddep libdnf.spec --define '_with_sanitizers 1' [--define '_without_