customized builds
This commit is contained in:
1
src/pamac-install/CMakeDepends.txt
Normal file
1
src/pamac-install/CMakeDepends.txt
Normal file
@@ -0,0 +1 @@
|
||||
add_dependencies(pamac-install Pamac)
|
||||
90
src/pamac-install/CMakeLists.txt
Normal file
90
src/pamac-install/CMakeLists.txt
Normal file
@@ -0,0 +1,90 @@
|
||||
### 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/pamac-install/Config.vala.base ${CMAKE_BINARY_DIR}/src/pamac-install/Config.vala)
|
||||
add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\")
|
||||
set (VERSION "6.0.0")
|
||||
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} 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} installer.vala)
|
||||
set (APP_SOURCES ${APP_SOURCES} progress_dialog.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()
|
||||
|
||||
set (COMPILE_OPTIONS ${COMPILE_OPTIONS} --gresources=${CMAKE_SOURCE_DIR}/data/pamac.installer.gresource.xml )
|
||||
|
||||
vala_precompile(VALA_C pamac-install
|
||||
${APP_SOURCES}
|
||||
PACKAGES
|
||||
${VALA_PACKAGES}
|
||||
CUSTOM_VAPIS
|
||||
${CUSTOM_VAPIS_LIST}
|
||||
OPTIONS
|
||||
${COMPILE_OPTIONS}
|
||||
)
|
||||
|
||||
SET (VALA_C ${VALA_C} ${pamac_installer_gresource_xml_C_FILE})
|
||||
add_executable(pamac-install ${VALA_C})
|
||||
add_dependencies (pamac-install pamac_installer_gresource_xml)
|
||||
|
||||
|
||||
install(TARGETS
|
||||
pamac-install
|
||||
RUNTIME DESTINATION
|
||||
${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
if(HAVE_VALADOC)
|
||||
valadoc(pamac-install
|
||||
${CMAKE_BINARY_DIR}/valadoc/pamac-install
|
||||
${APP_SOURCES}
|
||||
PACKAGES
|
||||
${VALA_PACKAGES}
|
||||
CUSTOM_VAPIS
|
||||
${CUSTOM_VAPIS_LIST}
|
||||
)
|
||||
install(DIRECTORY
|
||||
${CMAKE_BINARY_DIR}/valadoc
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_DATAROOTDIR}/doc/pamac
|
||||
)
|
||||
endif()
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/CMakeDepends.txt)
|
||||
10
src/pamac-install/Config.vala.base
Normal file
10
src/pamac-install/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
|
||||
}
|
||||
135
src/pamac-install/installer.vala
Normal file
135
src/pamac-install/installer.vala
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* 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 Pamac {
|
||||
|
||||
public class Installer: Gtk.Application {
|
||||
Transaction transaction;
|
||||
ProgressDialog progress_dialog;
|
||||
bool pamac_run;
|
||||
bool important_details;
|
||||
|
||||
public Installer () {
|
||||
application_id = "org.pamac.installer";
|
||||
flags |= ApplicationFlags.HANDLES_OPEN;
|
||||
}
|
||||
|
||||
public override void startup () {
|
||||
// i18n
|
||||
Intl.textdomain ("pamac");
|
||||
Intl.setlocale (LocaleCategory.ALL, "");
|
||||
|
||||
base.startup ();
|
||||
|
||||
pamac_run = check_pamac_running ();
|
||||
if (pamac_run) {
|
||||
var msg = new Gtk.MessageDialog (null,
|
||||
Gtk.DialogFlags.MODAL,
|
||||
Gtk.MessageType.ERROR,
|
||||
Gtk.ButtonsType.OK,
|
||||
dgettext (null, "Pamac is already running"));
|
||||
msg.run ();
|
||||
msg.destroy ();
|
||||
} else {
|
||||
important_details = false;
|
||||
// integrate progress box and term widget
|
||||
progress_dialog = new ProgressDialog ();
|
||||
transaction = new Transaction (progress_dialog as Gtk.ApplicationWindow);
|
||||
transaction.mode = Transaction.Mode.INSTALLER;
|
||||
transaction.finished.connect (on_transaction_finished);
|
||||
transaction.important_details_outpout.connect (on_important_details_outpout);
|
||||
progress_dialog.box.pack_start (transaction.progress_box);
|
||||
progress_dialog.box.reorder_child (transaction.progress_box, 0);
|
||||
transaction.term_window.height_request = 200;
|
||||
progress_dialog.expander.add (transaction.term_window);
|
||||
progress_dialog.close_button.clicked.connect (on_close_button_clicked);
|
||||
progress_dialog.close_button.visible = false;
|
||||
this.hold ();
|
||||
}
|
||||
}
|
||||
|
||||
public override void activate () {
|
||||
if (!pamac_run) {
|
||||
print ("\nError: Path(s) of tarball(s) to install is needed\n");
|
||||
transaction.stop_daemon ();
|
||||
this.release ();
|
||||
}
|
||||
}
|
||||
|
||||
public override void open (File[] files, string hint) {
|
||||
if (!pamac_run) {
|
||||
foreach (unowned File file in files) {
|
||||
transaction.to_load.add (file.get_path ());
|
||||
}
|
||||
progress_dialog.show ();
|
||||
if (transaction.get_lock ()) {
|
||||
transaction.run ();
|
||||
} else {
|
||||
transaction.progress_box.action_label.label = dgettext (null, "Waiting for another package manager to quit") + "...";
|
||||
transaction.start_progressbar_pulse ();
|
||||
Timeout.add (5000, () => {
|
||||
bool locked = transaction.get_lock ();
|
||||
if (locked) {
|
||||
transaction.stop_progressbar_pulse ();
|
||||
transaction.run ();
|
||||
}
|
||||
return !locked;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool check_pamac_running () {
|
||||
Application app;
|
||||
bool run = false;
|
||||
app = new Application ("org.pamac.manager", 0);
|
||||
try {
|
||||
app.register ();
|
||||
} catch (GLib.Error e) {
|
||||
stderr.printf ("%s\n", e.message);
|
||||
}
|
||||
run = app.get_is_remote ();
|
||||
return run;
|
||||
}
|
||||
|
||||
void on_important_details_outpout (bool must_show) {
|
||||
important_details = true;
|
||||
progress_dialog.expander.expanded = true;
|
||||
}
|
||||
|
||||
void on_close_button_clicked () {
|
||||
this.release ();
|
||||
}
|
||||
|
||||
void on_transaction_finished () {
|
||||
transaction.stop_daemon ();
|
||||
if (important_details) {
|
||||
progress_dialog.close_button.visible = true;
|
||||
} else {
|
||||
this.release ();
|
||||
}
|
||||
}
|
||||
|
||||
public static int main (string[] args) {
|
||||
var installer = new Installer();
|
||||
return installer.run (args);
|
||||
}
|
||||
}
|
||||
}
|
||||
40
src/pamac-install/progress_dialog.vala
Normal file
40
src/pamac-install/progress_dialog.vala
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
//using GIO
|
||||
|
||||
namespace Pamac {
|
||||
|
||||
[GtkTemplate (ui = "/org/pamac/installer/interface/progress_dialog.ui")]
|
||||
class ProgressDialog : Gtk.ApplicationWindow {
|
||||
|
||||
[GtkChild]
|
||||
public Gtk.Box box;
|
||||
[GtkChild]
|
||||
public Gtk.Button close_button;
|
||||
[GtkChild]
|
||||
public Gtk.Expander expander;
|
||||
|
||||
public ProgressDialog () {
|
||||
Object ();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user