Skip to content

Commit

Permalink
general: add pacman license to source files who contains functions ta…
Browse files Browse the repository at this point in the history
…ken from pacman source code
  • Loading branch information
Toni500github committed Jun 5, 2024
1 parent 2c71b64 commit 327f199
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 8 deletions.
19 changes: 19 additions & 0 deletions include/args.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
*
* Copyright (c) 2006-2022 Pacman Development Team <[email protected]>
* Copyright (c) 2002-2006 by Judd Vinet <[email protected]>
*
* 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. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef ARGS_HPP
#define ARGS_HPP

Expand Down
19 changes: 19 additions & 0 deletions include/pacman.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
*
* Copyright (c) 2006-2022 Pacman Development Team <[email protected]>
* Copyright (c) 2002-2006 by Judd Vinet <[email protected]>
*
* 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. If not, see <http://www.gnu.org/licenses/>.
*/

// code taken from pacman utils
// putted it on a separeted file for keeping the codebase a bit more clean
// args.cpp and args.hpp has part of pacman code too
Expand Down
20 changes: 20 additions & 0 deletions src/args.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
/*
*
* Copyright (c) 2006-2022 Pacman Development Team <[email protected]>
* Copyright (c) 2002-2006 by Judd Vinet <[email protected]>
*
* 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. If not, see <http://www.gnu.org/licenses/>.
*/

// Why re-invent the wheel when there is already one working well?
// All credits goes to the pacman devs

#include "args.hpp"
#include "util.hpp"
#include "config.hpp"
Expand Down
20 changes: 20 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
*
* Copyright (c) 2006-2022 Pacman Development Team <[email protected]>
* Copyright (c) 2002-2006 by Judd Vinet <[email protected]>
*
* 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. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma GCC diagnostic ignored "-Wvla"

#include "args.hpp"
Expand Down Expand Up @@ -502,6 +521,7 @@ bool queryPkgs(alpm_list_t *pkgNames) {
/** Sets up gettext localization. Safe to call multiple times.
*/
/* Inspired by the monotone function localize_monotone. */
// taken from pacman
#if defined(ENABLE_NLS)
static void localize(void) {
static int init = 0;
Expand Down
24 changes: 22 additions & 2 deletions src/pacman.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
// code taken from pacman utils
// putted it on a separeted file for keeping the codebase a bit more clean
/*
*
* Copyright (c) 2006-2022 Pacman Development Team <[email protected]>
* Copyright (c) 2002-2006 by Judd Vinet <[email protected]>
*
* 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. If not, see <http://www.gnu.org/licenses/>.
*/


// general functions taken from pacman source code
// putted it on a separeted file for keeping the codebase a bit more clean

#include "pacman.hpp"
#include "util.hpp"
Expand Down
20 changes: 20 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
*
* Copyright (c) 2006-2022 Pacman Development Team <[email protected]>
* Copyright (c) 2002-2006 by Judd Vinet <[email protected]>
*
* 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. If not, see <http://www.gnu.org/licenses/>.
*/

#include <alpm.h>
#pragma GCC diagnostic ignored "-Wignored-attributes"

Expand Down Expand Up @@ -71,6 +90,7 @@ static void make_aligned_titles(void) {
/** Turn a optdepends list into a text list.
* @param optdeps a list with items of type alpm_depend_t
*/
// taken from pacman
static void optdeplist_display(alpm_pkg_t *pkg, unsigned short cols = getcols()) {
alpm_list_t *i, *text = NULL;
alpm_db_t *localdb = alpm_get_localdb(config->handle);
Expand Down
7 changes: 1 addition & 6 deletions tests/test_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@ TEST_CASE( "util.cpp test suitcase", "[Util]" ) {
string env = std::getenv("HOME");
string path = "~/.config/rule34";
REQUIRE(hasEnding("I want the end", "end"));
REQUIRE(hasStart("And now the begin, then I want the end", "A"));
REQUIRE(hasStart("And now the begin, then I want the end", "And"));
REQUIRE(expandVar(path) == env + "/.config/rule34");
REQUIRE(shell_exec("echo hello") == "hello");
}

SECTION("ALPM asserts") {
alpm_list_t *syncdbs = alpm_get_syncdbs(config->handle);
REQUIRE(is_package_from_syncdb("linux", syncdbs));
}
}

0 comments on commit 327f199

Please sign in to comment.