[libcalamares] automount-manipulation test-program

This commit is contained in:
Adriaan de Groot 2020-12-22 21:25:00 +01:00
parent f0a33a235c
commit 1c4bf58fb4
2 changed files with 53 additions and 0 deletions

View File

@ -260,3 +260,8 @@ calamares_add_test(
add_executable( test_geoip geoip/test_geoip.cpp ${geoip_src} )
target_link_libraries( test_geoip calamares Qt5::Network yamlcpp )
calamares_automoc( test_geoip )
if ( Qt5DBus_FOUND )
add_executable( calautomount partition/calautomount.cpp )
target_link_libraries( calautomount calamares Qt5::DBus )
endif()

View File

@ -0,0 +1,48 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*
*/
/** @brief Command-line tool to enable or disable automounting
*
* This application uses Calamares methods to enable or disable
* automount settings in the running system. This can be used to
* test the automount-manipulating code without running
* a full Calamares or doing an installation.
*
*/
static const char usage[] = "Usage: calautomount <-e|-d>\n"
"\n"
"Enables (if `-e` is passed as command-line option) or\n"
"Disables (if `-d` is passed as command-line option)\n"
"\n"
"automounting of disks in the host system as best it can.\n"
"Exits with code 0 on success or 1 if an unknown option is\n"
"passed on the command-line.\n\n";
#include "AutoMount.h"
#include "Sync.h"
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
if ((argc != 2) || (argv[1][0] != '-') || (argv[1][1] !='e' && argv[1][1] !='d'))
{
qWarning() << usage;
return 1;
}
CalamaresUtils::Partition::automountDisable( argv[1][1] == 'd');
return 0;
}