Browse Source

split system install in two calls

drone
Claudio Luck 8 months ago
parent
commit
86c844880c
11 changed files with 115 additions and 48 deletions
  1. +0
    -1
      .Setup
  2. +1
    -0
      .Setup/pEp_import.sh
  3. +1
    -0
      .Setup/pEp_install.sh
  4. +1
    -0
      .Setup/tb_setup
  5. +2
    -2
      pEp_Thunderbird_Setup.desktop
  6. +6
    -6
      plat/all/pEp_import.sh
  7. +34
    -30
      plat/lnx/pEp_install.sh
  8. +0
    -0
      src/pEp_import.sh
  9. +0
    -0
      src/pEp_install.sh
  10. +64
    -9
      src/tb_setup.cc
  11. +6
    -0
      src/tb_setup.h

+ 0
- 1
.Setup View File

@ -1 +0,0 @@
Setup

+ 1
- 0
.Setup/pEp_import.sh View File

@ -0,0 +1 @@
../src/pEp_import.sh

+ 1
- 0
.Setup/pEp_install.sh View File

@ -0,0 +1 @@
../src/pEp_install.sh

+ 1
- 0
.Setup/tb_setup View File

@ -0,0 +1 @@
../src/tb_setup

+ 2
- 2
pEp_Thunderbird_Setup.desktop View File

@ -23,8 +23,8 @@ Comment=Start p≡p Linux Installer for Linux, requires Thunderbird to be instal
Categories=Network;Office;Security;Email;
Icon=mail-replied
Exec=sh -c '.Setup/tb_setup "%k"'
X-pEp-Exec=.Setup/pEp_install
X-pEp-Import-Exec=.Setup/pEp_import
X-pEp-Exec=.Setup/pEp_install.sh
X-pEp-Import-Exec=.Setup/pEp_import.sh
X-pEp-MDA-Version=2.0.7
X-pEp-MDA-Platform=x86_64
X-pEp-MDA-OSn=lnx


+ 6
- 6
plat/all/pEp_import.sh View File

@ -2,14 +2,14 @@
set -e
SETUP_DIR=./
[ ! -d .Setup ] || SETUP_DIR=.Setup/
if [ -e ${SETUP_DIR}pEp_import.py ] ; then
PYTHONPATH=$SETUP_DIR
if [ -e ${SETUP_DIR}Import/pEp_import.py ] ; then
PYTHONPATH=$SETUP_DIR/Import
export PYTHONPATH
python2 ${SETUP_DIR}pEp_import.py
python2 ${SETUP_DIR}Import/pEp_import.py "$@"
else
LD_LIBRARY_PATH=${PWD}/${SETUP_DIR}
LD_LIBRARY_PATH=${PWD}/${SETUP_DIR}/Import
export LD_LIBRARY_PATH
DYLD_LIBRARY_PATH=${PWD}/${SETUP_DIR}
DYLD_LIBRARY_PATH=${PWD}/${SETUP_DIR}/Import
export DYLD_LIBRARY_PATH
sh -c ${SETUP_DIR}pEp_import
sh -c ${SETUP_DIR}pEp_import "$@"
fi

+ 34
- 30
plat/lnx/pEp_install.sh View File

@ -24,52 +24,56 @@ done
shift $(($OPTIND - 1))
xdg_script=$1
function _install () {
_install () {
mode=$1
owners=$2
src=$3
dst=$4
[ ! -e "$dst" ] || chmod 0600 "$dst"
cp -f "$src" "$dst"
[ -z "$owners" ] || chown "$owners" "$dst"
chmod "$mode" "$dst"
}
if [ $user_inst -ne 0 ] ; then
mkdir -p /usr/local/bin /usr/local/share/pEp
_install 0555 root:0 \
"${setup_base}/.Setup/pEp-mini-json-adapter" \
"/usr/local/bin/pEp-mini-json-adapter"
_install 0444 root:0 \
"${setup_base}/.Setup/system.db" \
"/usr/local/share/pEp/system.db"
if [ -d /etc/systemd/user ] ; then
if [ -r /etc/systemd/user/pEp-mini-json-adapter.service ] ; then
systemctl --user disable pEp-mini-json-adapter.service
systemctl --user stop pEp-mini-json-adapter.service
fi
_install 0444 root:0 \
"${setup_base}/.Setup/pEp-mini-json-adapter.service" \
"/etc/systemd/user/pEp-mini-json-adapter.service"
systemctl --user daemon-reload
systemctl --user enable pEp-mini-json-adapter.service
systemctl --user start pEp-mini-json-adapter.service
else
echo "Warning: /etc/systemd/user not present, can not install systemd unit" >&2
fi
if [ -d /etc/xdg ] ; then
mkdir -p /etc/xdg/autostart
if [ $user_inst -eq 0 ] ; then
_uid=$(id -u)
if [ $_uid -eq 0 ] ; then
mkdir -p /usr/local/bin /usr/local/share/pEp
_install 0555 root:0 \
"${setup_base}/.Setup/pEp-mini-json-adapter" \
"/usr/local/bin/pEp-mini-json-adapter"
_install 0444 root:0 \
"${setup_base}/.Setup/pEp-mini-json-adapter.desktop" \
"/etc/xdg/autostart/pEp-mini-json-adapter.desktop"
"${setup_base}/.Setup/system.db" \
"/usr/local/share/pEp/system.db"
if [ -d /etc/systemd/user ] ; then
_install 0444 root:0 \
"${setup_base}/.Setup/pEp-mini-json-adapter.service" \
"/etc/systemd/user/pEp-mini-json-adapter.service"
else
echo "Warning: /etc/systemd/user not present, can not install systemd unit" >&2
fi
if [ -d /etc/xdg ] ; then
mkdir -p /etc/xdg/autostart
_install 0444 root:0 \
"${setup_base}/.Setup/pEp-mini-json-adapter.desktop" \
"/etc/xdg/autostart/pEp-mini-json-adapter.desktop"
else
echo "Warning: /etc/xdg not present, can not install autostart entry" >&2
fi
else
echo "Warning: /etc/xdg not present, can not install autostart entry" >&2
if [ -f /etc/systemd/user/pEp-mini-json-adapter.service ] ; then
systemctl --user daemon-reload
systemctl --user enable pEp-mini-json-adapter.service
systemctl --user start pEp-mini-json-adapter.service
fi
fi
else
share_prefix=$HOME/.local/share
bin_prefix=$HOME/.local/bin
etc_xdg_prefix=$HOME/.config
umask 0750
umask 0027
mkdir -p "${share_prefix}/pEp" "${bin_prefix}"
chmod 0755 "${share_prefix}/pEp" "${bin_prefix}"
_install 0555 "" \
"${setup_base}/.Setup/pEp-mini-json-adapter.user" \
"${bin_prefix}/pEp-mini-json-adapter"
@ -78,7 +82,7 @@ else
"${share_prefix}/pEp/system.db"
if [ -d "${etc_xdg_prefix}" ] ; then
mkdir -p "${etc_xdg_prefix}/autostart"
_install 0444 root:0 \
_install 0444 "" \
"${setup_base}/.Setup/pEp-mini-json-adapter.desktop.user" \
"${etc_xdg_prefix}/autostart/pEp-mini-json-adapter.desktop"
else


src/pEp_import → src/pEp_import.sh View File


src/pEp_install → src/pEp_install.sh View File


+ 64
- 9
src/tb_setup.cc View File

@ -33,13 +33,16 @@ wxIMPLEMENT_APP(TbSetupApp);
#define PEP_TBSETUP_OPT_SCRIPT "script"
#define PEP_TBSETUP_OPT_SCRIPT_BASE "script-base"
#define PEP_TBSETUP_OPT_SKIP_IMPORT "no-migration"
#define PEP_TBSETUP_OPT_IMPORT_SCRIPT "import-script"
#define PEP_TBSETUP_OPT_WITH_UNINSTALL "with-uninstall"
#define PEP_TBSETUP_OPT_PROFILE "thunderbird-profile"
#define PEP_TBSETUP_OPT_ADAP_PKG_VER "adapter-package-version"
#define PEP_TBSETUP_OPT_ADAP_PKG_PLAT "adapter-package-platform"
#define PEP_TBSETUP_OPT_ADAP_PKG_OS "adapter-package-os"
#define PEP_TBSETUP_OPT_ADAP_PKG_VARIA "adapter-package-variant"
#define PEP_TBSETUP_OPT_USER_INSTALL "user-install"
#define PEP_TBSETUP_OPT_UNATTENDED "unattended"
static const wxCmdLineEntryDesc g_cmdLineDesc [] =
{
@ -49,6 +52,9 @@ static const wxCmdLineEntryDesc g_cmdLineDesc [] =
{ wxCMD_LINE_SWITCH, "U", PEP_TBSETUP_OPT_WITH_UNINSTALL,
"displays uninstall button",
wxCMD_LINE_VAL_NONE },
{ wxCMD_LINE_SWITCH, NULL, PEP_TBSETUP_OPT_SKIP_IMPORT,
"skip data migration step",
wxCMD_LINE_VAL_NONE },
{ wxCMD_LINE_SWITCH, "u", PEP_TBSETUP_OPT_USER_INSTALL,
"default to install to user profile instead of system location",
wxCMD_LINE_VAL_NONE },
@ -61,6 +67,9 @@ static const wxCmdLineEntryDesc g_cmdLineDesc [] =
{ wxCMD_LINE_OPTION, "I", PEP_TBSETUP_OPT_IMPORT_SCRIPT,
"internal data import script",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_OPTION, NULL, PEP_TBSETUP_OPT_PROFILE,
"profile directory to install to",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_OPTION, NULL, PEP_TBSETUP_OPT_ADAP_PKG_VER,
"adapter package version to install",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
@ -73,6 +82,9 @@ static const wxCmdLineEntryDesc g_cmdLineDesc [] =
{ wxCMD_LINE_OPTION, NULL, PEP_TBSETUP_OPT_ADAP_PKG_VARIA,
"adapter package variant",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_SWITCH, NULL, PEP_TBSETUP_OPT_UNATTENDED,
"unattended start and close",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_PARAM, NULL, NULL,
"*.desktop file",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
@ -92,6 +104,7 @@ bool TbSetupApp::OnCmdLineParsed(wxCmdLineParser& parser)
m_opt_with_uninstall = parser.Found(PEP_TBSETUP_OPT_WITH_UNINSTALL);
m_opt_prefer_user_install = parser.Found(PEP_TBSETUP_OPT_USER_INSTALL);
m_opt_unattended_start = parser.Found(PEP_TBSETUP_OPT_UNATTENDED);
if (parser.Found(PEP_TBSETUP_OPT_SCRIPT, &s))
m_opt_script = s.ToStdString();
if (parser.Found(PEP_TBSETUP_OPT_IMPORT_SCRIPT, &s))
@ -106,6 +119,8 @@ bool TbSetupApp::OnCmdLineParsed(wxCmdLineParser& parser)
m_opt_adapter_package_os = s.ToStdString();
if (parser.Found(PEP_TBSETUP_OPT_ADAP_PKG_VARIA, &s))
m_opt_adapter_package_variant = s.ToStdString();
if (parser.Found(PEP_TBSETUP_OPT_PROFILE, &s))
m_opt_tb_profile_dir = Abspath( s.ToStdString().c_str() );
if (parser.GetParamCount() > 0)
{
@ -164,6 +179,10 @@ bool TbSetupApp::OnCmdLineParsed(wxCmdLineParser& parser)
if (!m_opt_import_script.length())
m_opt_import_script = m_opt_script_base + "/pEp_import.sh";
chdir(m_opt_script_base.c_str());
if (m_opt_unattended_start && m_opt_with_uninstall)
wxPostEvent(this, wxCommandEvent(pEpWxEvt_TbSetup, PEP_TBSETUP_START_UNINSTALL));
else if (m_opt_unattended_start)
wxPostEvent(this, wxCommandEvent(pEpWxEvt_TbSetup, PEP_TBSETUP_START_SETUP));
return true;
}
@ -186,11 +205,9 @@ bool TbSetupApp::OnInit()
return true;
}
void TbSetupApp::OnStartSetup(wxCommandEvent& event)
vector<string>* TbSetupApp::GetScriptOptions()
{
bool user_inst = !m_windowFrame->IsSystemInstall();
m_windowFrame->ResetLogText();
m_import_script_pending = true;
auto *cmd = new vector<string>;
string script = Abspath(m_opt_script.c_str());
if (!script.length())
@ -225,6 +242,25 @@ void TbSetupApp::OnStartSetup(wxCommandEvent& event)
{
cmd->push_back(m_opt_xdg);
}
return cmd;
}
vector<string>* TbSetupApp::GetImportScriptOptions()
{
auto *cmd = new vector<string>;
cmd->push_back(m_opt_import_script);
if (m_opt_tb_profile_dir.length())
cmd->push_back(m_opt_tb_profile_dir);
return cmd;
}
void TbSetupApp::OnStartSetup(wxCommandEvent& event)
{
bool user_inst = !m_windowFrame->IsSystemInstall();
m_import_script_pending = true;
m_script_user_phase_pending = user_inst ? false : true;
m_windowFrame->ResetLogText();
vector<string> *cmd = GetScriptOptions();
if (!(this->th_interact))
{
m_windowFrame->EnableForward(0);
@ -238,7 +274,7 @@ void TbSetupApp::OnStartSetup(wxCommandEvent& event)
void TbSetupApp::OnStartUninstall(wxCommandEvent& event)
{
m_windowFrame->ResetLogText();
auto cmd = new vector<string>;
auto *cmd = new vector<string>;
cmd->push_back("/bin/sh");
cmd->push_back("-c");
cmd->push_back("{ echo 'Not implemented yet' ; exit 1 ; }");
@ -263,13 +299,22 @@ void TbSetupApp::OnInteractionCheckPending(wxCommandEvent& event)
}
if (!status)
{
auto cmd = new vector<string>;
cmd->push_back(m_opt_import_script);
if (m_import_script_pending)
if (m_script_user_phase_pending)
{
m_import_script_pending = false;
m_script_user_phase_pending = false;
if (m_opt_import_script.length())
{
auto *cmd = GetScriptOptions();
this->th_interact = new thread(&TbSetupApp::Interact, this, cmd);
deferred = true;
}
}
else if (m_import_script_pending)
{
m_import_script_pending = false;
if (!m_opt_do_not_import && m_opt_import_script.length())
{
auto *cmd = GetImportScriptOptions();
this->th_interact = new thread(&TbSetupApp::Interact, this, cmd);
deferred = true;
}
@ -299,7 +344,10 @@ void TbSetupApp::OnInteractionComplete(wxCommandEvent& event)
m_windowFrame->SetCloseDefault(true);
this->th_interact->join();
this->th_interact = NULL;
m_windowFrame->Ready(true);
if (m_opt_unattended_start)
wxPostEvent(this, wxCommandEvent(pEpWxEvt_TbSetup, PEP_TBSETUP_CLOSE));
else
m_windowFrame->Ready(true);
}
void TbSetupApp::OnClose(wxCommandEvent& event)
@ -421,6 +469,13 @@ int TbSetupApp::Interact(vector<string> *cmd)
m_script = script;
int status;
if ((status = script->rdbuf()->status()) >= 0)
{
wxPostEvent(this, wxCommandEvent(pEpWxEvt_TbSetup, PEP_TBSETUP_INTERACTION_CHECK_PENDING));
return status;
}
vector<char> ebuf(80, 0);
vector<char> obuf(80, 0);
buffer out_buf;


+ 6
- 0
src/tb_setup.h View File

@ -25,7 +25,11 @@ protected:
string m_opt_script = "";
string m_opt_import_script = "";
string m_opt_script_base = "";
string m_opt_tb_profile_dir = "";
bool m_opt_do_not_import = false;
bool m_import_script_pending = false;
bool m_script_user_phase_pending = false;
bool m_opt_unattended_start = false;
string m_opt_adapter_package_ver = "2.0.0";
string m_opt_adapter_package_archive = "";
string m_opt_adapter_package_plat = "x86_64";
@ -54,6 +58,8 @@ public:
void OnInteractionComplete(wxCommandEvent&);
void OnInteractionCheckPending(wxCommandEvent&);
void OnClose(wxCommandEvent&);
vector<string>* GetScriptOptions();
vector<string>* GetImportScriptOptions();
int InteractElevated(std::vector<std::string> *);
int Interact(std::vector<std::string> *);
string Abspath(const char *);


Loading…
Cancel
Save