Browse Source

add variant option to select between user and system install

argv
Claudio Luck 9 months ago
parent
commit
8df5c160da
3 changed files with 61 additions and 16 deletions
  1. +44
    -15
      README.md
  2. +16
    -1
      src/tb_setup.cc
  3. +1
    -0
      src/tb_setup.h

+ 44
- 15
README.md View File

@ -3,17 +3,15 @@
# About
This is a component of the pEp Installer for Linux (it does not consistute a
useable installer on it's own). This is the program to launch to start the
guided installation. It is designed to offer a choice between *system
installation* and *user installation*, and to locate the best available
privilege escalation utility for the platform.
useable installer on it's own). This is the program to launch from a *.desktop
file, which in turn will offer user choices, and then run backend scripts
with proper privileges.
It then launches a secondary binary, which could be a shell script or an
executable, with the `--user` or `--system` command line option.
It also has the facility to prompt the user for an administrative password
shall the backend script prompt accordingly on its stdout (pseudo-terminal) or
stderr.
The binary can optionally be launched with the `-U` command line option, which
exposes the *Uninstall* button. This will result in also passing `--remove` to
the secondary binary.
The uninstall button is only exposed if launched with the option `-U`.
# Build
@ -29,7 +27,7 @@ make wx_config=/path/to/custom/wx-config
```
./tb_setup -h
./tb_setup -U
./tb_setup -U /path/to/pEp_Thunderbird_Setup.desktop
```
![Running installer binary](./docs/screenshots/screen1.png)
@ -37,11 +35,14 @@ make wx_config=/path/to/custom/wx-config
# Features
The ./tb_binary accepts a shell-script parameter, which is expanded to an
absolute path and passed to the internal install script. This is targeting
usage as she-bang in an executable *.desktop file.
A pseudo *.desktop file.
The ./tb_binary execution is meant to be wrapped by a *.desktop file carrying
specific parameters for the installation. Two ways of launching tb_setup exist,
(a) by means of the Exec= setting, and (b) by means of a shell "shebang" while
the .desktop files executable bit is also set. In the latter case, tb_setup
relies on the shell passing the .desktop file as the script to be executed as
an argument to the running interpreter, which in this case is tb_setup. To
achieve symmetry between the two modes of launching, the .desktop file shall be
structured as follows:
```
#!/usr/bin/env ./tb_setup
@ -54,6 +55,34 @@ A pseudo *.desktop file.
Exec=sh -c './tb_setup "%k"'
```
Whenever tb_setup is launched this way, it will parse the .desktop file and extract
installation parameters. It will then set defaults and launch install scripts
according to the parameters.
```
[Desktop Entry]
X-pEp-Exec=
X-pEp-Import-Exec=
X-pEp-MDA-Version=
X-pEp-MDA-Platform=
X-pEp-MDA-OS=
X-pEp-MDA-Variant=
X-pEp-Prefer-User-Install=yes|1|no|0
```
The options and values are case sensitive.
The *X-pEp-Exec* is a file path to the script performing the adapter
installation. It is called with the command line arguments and with appropriate
privileges (root or user) as described below. The *X-pEp-Import-Exec* is
called after the adapter installation, and called with the command line
argumentsas described below, while it is always called as the current user. The
values of *X-pEp-MDA-Version*, *X-pEp-MDA-Platform*, *X-pEp-MDA-OS* and
*X-pEp-MDA-Variant* are passed through to the install scripts.
If not set explicitely, *X-pEp-MDA-Variant* defaults to `tb` for system installs,
and `tbmini` for user installs.
# Testing


+ 16
- 1
src/tb_setup.cc View File

@ -35,6 +35,7 @@ wxIMPLEMENT_APP(TbSetupApp);
#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"
static const wxCmdLineEntryDesc g_cmdLineDesc [] =
@ -66,6 +67,9 @@ static const wxCmdLineEntryDesc g_cmdLineDesc [] =
{ wxCMD_LINE_OPTION, NULL, PEP_TBSETUP_OPT_ADAP_PKG_OS,
"adapter package operating system to install",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_OPTION, NULL, PEP_TBSETUP_OPT_ADAP_PKG_VARIA,
"adapter package variant",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_PARAM, NULL, NULL,
"*.desktop file",
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
@ -97,6 +101,8 @@ bool TbSetupApp::OnCmdLineParsed(wxCmdLineParser& parser)
m_opt_adapter_package_plat = s.ToStdString();
if (parser.Found(PEP_TBSETUP_OPT_ADAP_PKG_OS, &s))
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.GetParamCount() > 0)
{
@ -126,6 +132,7 @@ bool TbSetupApp::OnCmdLineParsed(wxCmdLineParser& parser)
string xdg_mda_ver = reader.Get("Desktop Entry", "X-pEp-MDA-Version", "");
string xdg_mda_plat = reader.Get("Desktop Entry", "X-pEp-MDA-Platform", "");
string xdg_mda_os = reader.Get("Desktop Entry", "X-pEp-MDA-OS", "");
string xdg_mda_varia = reader.Get("Desktop Entry", "X-pEp-MDA-Variant", "");
m_opt_prefer_user_install = xdg_pref_user;
if (xdg_script.length())
@ -138,6 +145,8 @@ bool TbSetupApp::OnCmdLineParsed(wxCmdLineParser& parser)
m_opt_adapter_package_plat = xdg_mda_plat;
if (xdg_mda_os.length())
m_opt_adapter_package_os = xdg_mda_os;
if (xdg_mda_varia.length())
m_opt_adapter_package_variant = xdg_mda_varia;
}
if (!script_base_explicit)
{
@ -187,7 +196,13 @@ void TbSetupApp::OnStartSetup(wxCommandEvent& event)
string cmd = Abspath(m_opt_script.c_str());
if (user_inst)
cmd += " -u";
cmd += " -X tb -P " + ShellQuote(m_opt_adapter_package_plat);
if (m_opt_adapter_package_variant.length())
cmd += " -X " + ShellQuote(m_opt_adapter_package_variant.c_str());
else if (user_inst)
cmd += " -X tbmini";
else
cmd += " -X tb";
cmd += " -P " + ShellQuote(m_opt_adapter_package_plat);
cmd += " -O " + ShellQuote(m_opt_adapter_package_os);
cmd += " -V " + ShellQuote(m_opt_adapter_package_ver);
cmd += " -b " + ShellQuote(m_opt_script_base);


+ 1
- 0
src/tb_setup.h View File

@ -29,6 +29,7 @@ protected:
string m_opt_adapter_package_ver = "2.0.0";
string m_opt_adapter_package_archive = "";
string m_opt_adapter_package_plat = "x86_64";
string m_opt_adapter_package_variant = "";
#if __linux__
string m_opt_adapter_package_os = "lnx";
#elif __APPLE__


Loading…
Cancel
Save