[libcalamares] automount-manipulation test-program
This commit is contained in:
parent
f0a33a235c
commit
1c4bf58fb4
@ -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()
|
||||
|
48
src/libcalamares/partition/calautomount.cpp
Normal file
48
src/libcalamares/partition/calautomount.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user