customized builds

This commit is contained in:
2017-10-10 16:29:22 -03:00
parent 3d5d662152
commit 235c95aa2b
246 changed files with 8857 additions and 1535 deletions

3
src/aur/AUR.deps Normal file
View File

@@ -0,0 +1,3 @@
json-glib-1.0
libsoup-2.4
glib-2.0

12
src/aur/AUR.pc Normal file
View File

@@ -0,0 +1,12 @@
prefix=@CMAKE_INSTALL_PREFIX@
real_prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@DOLLAR@{prefix}
libdir=@DOLLAR@{exec_prefix}/${CMAKE_INSTALL_LIBDIR}
includedir=@DOLLAR@{exec_prefix}/${CMAKE_INSTALL_INCLUDEDIR}
Name: AUR
Description: AUR
Version: 6.0.0
Libs: -L@DOLLAR@{libdir} -lAUR
Cflags: -I@DOLLAR@{includedir}
Requires: json-glib-1.0 libsoup-2.4 glib-2.0

117
src/aur/CMakeLists.txt Normal file
View File

@@ -0,0 +1,117 @@
### CMakeLists automatically created with AutoVala
### Do not edit
set (DATADIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}")
set (PKGDATADIR "${DATADIR}/pamac")
set (GETTEXT_PACKAGE "pamac")
set (RELEASE_NAME "pamac")
set (CMAKE_C_FLAGS "")
set (PREFIX ${CMAKE_INSTALL_PREFIX})
set (VERSION "6.0.0")
set (TESTSRCDIR "${CMAKE_SOURCE_DIR}")
set (DOLLAR "$")
configure_file (${CMAKE_SOURCE_DIR}/src/aur/Config.vala.base ${CMAKE_BINARY_DIR}/src/aur/Config.vala)
add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\")
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/AUR.pc ${CMAKE_CURRENT_BINARY_DIR}/AUR.pc)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/AUR.deps ${CMAKE_CURRENT_BINARY_DIR}/AUR.deps)
set (VERSION "6.0.0")
add_definitions (${DEPS_CFLAGS})
link_libraries ( ${DEPS_LIBRARIES} )
link_directories ( ${DEPS_LIBRARY_DIRS} )
find_package (Vala REQUIRED)
include (ValaVersion)
ensure_vala_version ("0.38" MINIMUM)
include (ValaPrecompile)
set (VALA_PACKAGES ${VALA_PACKAGES} json-glib-1.0)
set (VALA_PACKAGES ${VALA_PACKAGES} libsoup-2.4)
set (VALA_PACKAGES ${VALA_PACKAGES} glib-2.0)
set (APP_SOURCES ${APP_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/Config.vala)
set (APP_SOURCES ${APP_SOURCES} aur.vala)
if (DISABLE_AUR)
set (COMPILE_OPTIONS ${COMPILE_OPTIONS} -D DISABLE_AUR)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDISABLE_AUR " )
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDISABLE_AUR " )
endif ()
if (KDE_TRAY)
set (COMPILE_OPTIONS ${COMPILE_OPTIONS} -D KDE_TRAY)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DKDE_TRAY " )
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DKDE_TRAY " )
endif ()
set (COMPILE_OPTIONS ${COMPILE_OPTIONS} --vapidir=${CMAKE_SOURCE_DIR}/src/vapis )
if ((${CMAKE_BUILD_TYPE} STREQUAL "Debug") OR (${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo"))
set(COMPILE_OPTIONS ${COMPILE_OPTIONS} "-g")
endif()
set (COMPILE_OPTIONS ${COMPILE_OPTIONS} --library=AUR --gir AUR-6.0.gir )
vala_precompile(VALA_C AUR
${APP_SOURCES}
PACKAGES
${VALA_PACKAGES}
OPTIONS
${COMPILE_OPTIONS}
GENERATE_VAPI
AUR
GENERATE_HEADER
AUR
)
add_library(AUR SHARED ${VALA_C})
set_target_properties( AUR PROPERTIES
VERSION
6.0.0
SOVERSION
6 )
install(TARGETS
AUR
LIBRARY DESTINATION
${CMAKE_INSTALL_LIBDIR}/
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/AUR.h
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/AUR.vapi
DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/vala/vapi/
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/AUR.deps
DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/vala/vapi/
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/AUR-6.0.gir
DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/gir-1.0/
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/AUR.pc
DESTINATION
${CMAKE_INSTALL_LIBDIR}/pkgconfig/
)
if(HAVE_VALADOC)
valadoc(AUR
${CMAKE_BINARY_DIR}/valadoc/AUR
${APP_SOURCES}
PACKAGES
${VALA_PACKAGES}
CUSTOM_VAPIS
${CUSTOM_VAPIS_LIST}
)
install(DIRECTORY
${CMAKE_BINARY_DIR}/valadoc
DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/doc/pamac
)
endif()

10
src/aur/Config.vala.base Normal file
View File

@@ -0,0 +1,10 @@
namespace AURConstants {
public const string DATADIR = "@DATADIR@";
public const string PKGDATADIR = "@PKGDATADIR@";
public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";
public const string RELEASE_NAME = "@RELEASE_NAME@";
public const string VERSION = "@VERSION@";
#if UNITEST
public const string TESTSRCDIR = "@TESTSRCDIR@";
#endif
}

90
src/aur/aur.vala Normal file
View File

@@ -0,0 +1,90 @@
/*
* pamac-vala
*
* Copyright (C) 2017 Chris Cromer <cromer@cromnix.org>
* Copyright (C) 2014-2017 Guillaume Benoit <guillaume@manjaro.org>
*
* 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 3 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 get of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace AUR {
// AUR urls
const string aur_url = "http://aur.archlinux.org";
const string rpc_url = aur_url + "/rpc/?v=5";
const string rpc_search = "&type=search&arg=";
const string rpc_multiinfo = "&type=info";
const string rpc_multiinfo_arg = "&arg[]=";
Json.Array rpc_query (string uri) {
var results = new Json.Array ();
var session = new Soup.Session ();
// set a 15 seconds timeout because it is also the dbus daemon timeout
session.timeout = 15;
var message = new Soup.Message ("GET", uri);
var parser = new Json.Parser ();
session.send_message (message);
try {
parser.load_from_data ((string) message.response_body.flatten ().data, -1);
} catch (Error e) {
critical (e.message);
}
unowned Json.Node? root = parser.get_root ();
if (root != null) {
if (root.get_object ().get_string_member ("type") == "error") {
critical ("Failed to query %s from AUR", uri);
} else {
results = root.get_object ().get_array_member ("results");
}
}
return results;
}
public async Json.Array search (string[] needles) {
if (needles.length == 0) {
return new Json.Array ();
} else {
var result = rpc_query (rpc_url + rpc_search + Uri.escape_string (needles[0]));
int i = 1;
while (i < needles.length) {
var inter = new Json.Array ();
var found = rpc_query (rpc_url + rpc_search + Uri.escape_string (needles[i]));
result.foreach_element ((result_array, result_index, result_node) => {
found.foreach_element ((found_array, found_index, found_node) => {
if (strcmp (result_node.get_object ().get_string_member ("Name"),
found_node.get_object ().get_string_member ("Name")) == 0) {
inter.add_element (result_node);
}
});
});
result = (owned) inter;
i++;
}
return result;
}
}
public async Json.Array multiinfo (string[] pkgnames) {
if (pkgnames.length == 0) {
return new Json.Array ();
}
var builder = new StringBuilder ();
builder.append (rpc_url);
builder.append (rpc_multiinfo);
foreach (unowned string pkgname in pkgnames) {
builder.append (rpc_multiinfo_arg);
builder.append (Uri.escape_string (pkgname));
}
return rpc_query (builder.str);
}
}