add pamac-cache-clean and save cache options
This commit is contained in:
89
src/pamac-clean-cache/CMakeLists.txt
Normal file
89
src/pamac-clean-cache/CMakeLists.txt
Normal file
@@ -0,0 +1,89 @@
|
||||
### 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.1")
|
||||
set (TESTSRCDIR "${CMAKE_SOURCE_DIR}")
|
||||
set (DOLLAR "$")
|
||||
|
||||
configure_file (${CMAKE_SOURCE_DIR}/src/pamac-clean-cache/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-clean-cache/Config.vala)
|
||||
add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\")
|
||||
set (VERSION "6.0.1")
|
||||
add_definitions (${DEPS_CFLAGS})
|
||||
include_directories ( ${CMAKE_BINARY_DIR}/src )
|
||||
link_libraries ( ${DEPS_LIBRARIES} -lPamac )
|
||||
link_directories ( ${DEPS_LIBRARY_DIRS} ${CMAKE_BINARY_DIR}/src )
|
||||
find_package (Vala REQUIRED)
|
||||
include (ValaVersion)
|
||||
ensure_vala_version ("0.38" MINIMUM)
|
||||
include (ValaPrecompile)
|
||||
|
||||
set (VALA_PACKAGES ${VALA_PACKAGES} posix)
|
||||
set (VALA_PACKAGES ${VALA_PACKAGES} gtk+-3.0)
|
||||
set (VALA_PACKAGES ${VALA_PACKAGES} gio-2.0)
|
||||
set (VALA_PACKAGES ${VALA_PACKAGES} glib-2.0)
|
||||
set (VALA_PACKAGES ${VALA_PACKAGES} gobject-2.0)
|
||||
|
||||
set (APP_SOURCES ${APP_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/Config.vala)
|
||||
set (APP_SOURCES ${APP_SOURCES} clean_cache.vala)
|
||||
set (APP_SOURCES ${APP_SOURCES} pamac_config.vala)
|
||||
|
||||
set (CUSTOM_VAPIS_LIST ${CUSTOM_VAPIS_LIST} ${CMAKE_BINARY_DIR}/src/Pamac.vapi)
|
||||
|
||||
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()
|
||||
|
||||
|
||||
vala_precompile(VALA_C pamac-clean-cache
|
||||
${APP_SOURCES}
|
||||
PACKAGES
|
||||
${VALA_PACKAGES}
|
||||
CUSTOM_VAPIS
|
||||
${CUSTOM_VAPIS_LIST}
|
||||
OPTIONS
|
||||
${COMPILE_OPTIONS}
|
||||
)
|
||||
|
||||
add_executable(pamac-clean-cache ${VALA_C})
|
||||
set ( pamac-clean-cache_DEPENDENCIES ${pamac-clean-cache_DEPENDENCIES} Pamac )
|
||||
add_dependencies( pamac-clean-cache ${pamac-clean-cache_DEPENDENCIES} )
|
||||
|
||||
|
||||
install(TARGETS
|
||||
pamac-clean-cache
|
||||
RUNTIME DESTINATION
|
||||
${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
if(HAVE_VALADOC)
|
||||
valadoc(pamac-clean-cache
|
||||
${CMAKE_BINARY_DIR}/valadoc/pamac-clean-cache
|
||||
${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/pamac-clean-cache/Config.vala.base
Normal file
10
src/pamac-clean-cache/Config.vala.base
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Constants {
|
||||
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
|
||||
}
|
33
src/pamac-clean-cache/clean_cache.vala
Normal file
33
src/pamac-clean-cache/clean_cache.vala
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
int main () {
|
||||
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
|
||||
string rm_only_uninstalled_str = "";
|
||||
if (pamac_config.rm_only_uninstalled) {
|
||||
rm_only_uninstalled_str = "-u";
|
||||
}
|
||||
try {
|
||||
Process.spawn_command_line_sync ("paccache -q --nocolor %s -r -k %llu".printf (rm_only_uninstalled_str, pamac_config.keep_num_pkgs));
|
||||
} catch (SpawnError e) {
|
||||
stderr.printf ("SpawnError: %s\n", e.message);
|
||||
}
|
||||
return 0;
|
||||
}
|
1
src/pamac-clean-cache/pamac_config.vala
Symbolic link
1
src/pamac-clean-cache/pamac_config.vala
Symbolic link
@@ -0,0 +1 @@
|
||||
../pamac_config.vala
|
Reference in New Issue
Block a user