1
0

really first commit

This commit is contained in:
Daniel Tartavel 2022-08-16 23:33:14 +02:00
parent f5c470695c
commit 77db6f5ef5
9 changed files with 968 additions and 0 deletions

2
Makefile Normal file
View File

@ -0,0 +1,2 @@
default:
g++ -lrpm -I/usr/include/rpm -lrpmio -o listrpm main.cpp

View File

@ -0,0 +1,525 @@
DTux /
config_lalis
8_auto_inst.cfg.pl 13 KB
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
#!/usr/bin/perl -cw
#
# You should check the syntax of this file before using it in an auto-install.
# You can do this with 'perl -cw auto_inst.cfg.pl' or by executing this file
# (note the '#!/usr/bin/perl -cw' on the first line).
$o = {
'X' => {
'monitors' => [
{
'VendorName' => 'Plug\'n Play',
'manually_chosen' => 1
}
],
'resolution_wanted' => 'x'
},
'authentication' => {
'sha512' => 1,
'shadow' => 1
},
'autoExitInstall' => '1',
'default_packages' => [
'acpi',
'acpid',
'akonadi',
'akonadi-import-wizard',
'akregator-handbook',
'aoss',
'aria2',
'ark',
'ark-handbook',
'autocorr-fr',
'baloo',
'baloo-widgets',
'basesystem',
'bash-completion',
'bc',
'bind-utils',
'bluedevil',
'bluez-firmware',
'bluez-qt',
'breeze',
'breeze-common',
'breeze-gtk',
'cdrkit-genisoimage',
'chrony',
'clementine',
'comgt',
'coreutils-doc',
'cpupower',
'cronie-anacron',
'dconf',
'dcraw',
'dhcp-client',
'dmraid',
'dnf',
'dnf-plugins-core',
'dnf-yum',
'dracut',
'dragon-handbook',
'drakconf',
'drakguard',
'drakx-net',
'drakx-net-applet',
'drakxtools',
'drakxtools-curses',
'dump',
'dvdauthor',
'enchant',
'enscript',
'eventviews',
'faad2',
'ffmpeg',
'ffmpeg2theora',
'ffmpegthumbs',
'file',
'filezilla',
'firefox',
'firefox-fr',
'flac',
'flash-player-plugin',
'fonts-ttf-decoratives',
'fonts-ttf-west_european',
'frei0r',
'ghostscript',
'ghostscript-common',
'ghostscript-module-X',
'giftrans',
'gimp',
'gimp-help-fr',
'glib2.0-common',
'gnupg',
'gnupg2',
'gphoto2',
'gpm',
'grub-doc',
'grub2',
'grub2-common',
'grub2-mageia-theme',
'gstreamer1.0-a52dec',
'gstreamer1.0-amrnb',
'gstreamer1.0-cdio',
'gstreamer1.0-dv',
'gstreamer1.0-faad',
'gstreamer1.0-farstream',
'gstreamer1.0-flac',
'gstreamer1.0-gme',
'gstreamer1.0-gsm',
'gstreamer1.0-lame',
'gstreamer1.0-mms',
'gstreamer1.0-mpeg',
'gstreamer1.0-neon',
'gstreamer1.0-ofa',
'gstreamer1.0-plugins-ugly',
'gstreamer1.0-pulse',
'gstreamer1.0-rtmp',
'gstreamer1.0-soup',
'gstreamer1.0-speex',
'gstreamer1.0-twolame',
'gstreamer1.0-wavpack',
'gstreamer1.0-x264',
'gstreamer1.0-x265',
'gvfs-archive',
'gvfs-fuse',
'gvfs-goa',
'gvfs-gphoto2',
'gvfs-iphone',
'gvfs-mtp',
'gvfs-smb',
'gwenview',
'gwenview-handbook',
'harddrake',
'hawkey-man',
'hdparm',
'hexedit',
'hplip-model-data',
'html2text',
'hunspell',
'hunspell-en',
'icedtea-web',
'icewm-i18n',
'icewm-light',
'icu58-data',
'imagemagick',
'incidenceeditor',
'info',
'iproute2',
'irqbalance',
'iwlwifi-firmware',
'java-1.8.0-openjdk',
'json-glib',
'kaccounts-integration',
'kactivities',
'kaddressbook',
'kalarm',
'kamera',
'kamera-handbook',
'kcalc',
'kcalc-handbook',
'kcharselect',
'kcharselect-handbook',
'kcmutils',
'kcolorchooser',
'kcron',
'kcron-handbook',
'kde-cli-tools',
'kde-l10n-fr',
'kded',
'kdegraphics-mobipocket',
'kdegraphics-thumbnailers',
'kdenlive',
'kdeplasma-addons',
'kdesu',
'kdnssd',
'kdoctools',
'kernel-desktop-latest',
'kernel-firmware-nonfree',
'kfilemetadata',
'kgamma5',
'kglobalaccel',
'kholidays',
'khtml',
'kidletime',
'kinfocenter',
'kio',
'kio5-sieve',
'kipi-common',
'kipi-plugins',
'kipi-plugins-facebook',
'kipi-plugins-flashexport',
'kipi-plugins-flickr',
'kipi-plugins-kmlexport',
'kipi-plugins-piwigo',
'kipi-plugins-printimages',
'kipi-plugins-rajceexport',
'kipi-plugins-sendimages',
'kipi-plugins-smug',
'kipi-plugins-vkontakte',
'kipi-plugins-yandexfotki',
'kjobwidgets',
'kjots',
'kldap',
'kldap-handbook',
'kleopatra-handbook',
'kmail',
'kmailtransport',
'kmailtransport-handbook',
'kmenuedit',
'kmozillahelper',
'knotes-handbook',
'knotifyconfig',
'kolourpaint',
'kolourpaint-handbook',
'konsole-doc',
'kontact',
'kontact-handbook',
'kontactinterface',
'konversation',
'korganizer',
'kpeople',
'kross',
'krunner',
'kscreen',
'kscreenlocker',
'kservice',
'ksysguard',
'ktexteditor',
'ktexteditor-plugins',
'ktextwidgets',
'ktimer',
'ktimer-handbook',
'ktorrent',
'kwallet',
'kwallet-pam',
'kwalletmanager',
'kwalletmanager-handbook',
'kwin',
'kwrite-handbook',
'ladspa',
'lame',
'ldetect',
'ldetect-lst',
'lftp',
'libreoffice',
'libreoffice-langpack-fr',
'locales',
'lsof',
'lvm2',
'lynx',
'mageia-gfxboot-theme',
'mageia-theme-screensavers',
'mageiawelcome',
'mailimporter',
'man-pages',
'man-pages-fr',
'mandi-ifw',
'marble',
'marble-handbook',
'mariadb-common',
'mariadb-common-core',
'mc',
'mencoder',
'meta-task',
'mgaonline',
'microcode',
'microcode_ctl',
'mjpegtools',
'mkxauth',
'mlocate',
'monitor-edid',
'mp3gain',
'mpeg2dec',
'mpgtx',
'mplayer',
'msec',
'msec-gui',
'mtools',
'nano',
'ncurses',
'net_monitor',
'netprofile-plugin-firewall',
'netprofile-plugin-network',
'netprofile-plugin-proxy',
'netprofile-plugin-services',
'netprofile-plugin-urpmi',
'nmap',
'notification-daemon-engine-nodoka',
'nss',
'nss-myhostname',
'ntfs-3g',
'numlock',
'okular-handbook',
'open',
'openssh',
'openssh-clients',
'openssl',
'os-prober',
'oxygen-icons5',
'p7zip',
'patch',
'perl-Time-HiRes',
'perl-XML-LibXML',
'perl-doc',
'phonon4qt5',
'phonon4qt5-vlc',
'pidgin-plugins',
'pinentry-gnome3',
'plasma-integration',
'plasma-pa',
'plasma-workspace',
'plymouth-system-theme',
'poppler-data',
'preload',
'procmail',
'psutils',
'pulseaudio-module-gconf',
'pulseaudio-module-zeroconf',
'python',
'python3-dnf-plugins-core',
'python3-rpm',
'python3-smbc',
'qttools5',
'qttools5-assistant',
'radeon-firmware',
'ralink-firmware',
'rdist',
'readahead',
'recode',
'recordmydesktop',
'rfkill',
'rootcerts',
'rootcerts-java',
'rpm',
'rsync',
's2u',
'sane-backends-iscan',
'screen',
'scribus',
'sddm',
'sddm-kcm',
'seahorse',
'sectool',
'shadow-utils',
'sharutils',
'shorewall-ipv6',
'skrooge',
'solid',
'sonnet',
'sound-scripts',
'soundwrapper',
'spectacle',
'speex',
'sqlite3-tools',
'strace',
'sudo',
'symlinks',
'system-config-printer',
'systemd',
'systemsettings',
'task-codec-audio',
'task-codec-video',
'task-lalis',
'task-plasma5-minimal',
'task-pulseaudio',
'telepathy-haze',
'telepathy-idle',
'telepathy-kde-common-internals-core',
'telepathy-kde-desktop-applets',
'telepathy-kde-send-file',
'telepathy-salut',
'tmpwatch',
'tree',
'twolame',
'ufraw-gimp',
'unar',
'usbutils',
'vim-enhanced',
'vim-minimal',
'vlc',
'vlc-plugin-common',
'vlc-plugin-flac',
'vlc-plugin-lua',
'vlc-plugin-pulse',
'vlc-plugin-speex',
'vlc-plugin-theora',
'vorbis-tools',
'vorbisgain',
'wget',
'wireless-tools',
'words',
'x11-driver-input',
'x11-driver-video',
'x11-driver-video-vboxvideo',
'x11-font-bh-type1',
'x11-server-xorg',
'x264',
'xdg-utils',
'xdm',
'xev',
'xorg-x11-75dpi-fonts',
'xorriso',
'yelp',
'zeroconf-ioslave',
'zip'
],
'enabled_media' => [
'Core Release',
'Core Updates',
'Nonfree Release',
'Nonfree Updates',
'Tainted Release',
'Tainted Updates'
],
'interactiveSteps' => [
'doPartitionDisks',
'formatPartitions',
'summary'
],
'keyboard' => {
'GRP_TOGGLE' => '',
'KEYBOARD' => 'fr'
},
'locale' => {
'IM' => undef,
'country' => 'FR',
'lang' => 'fr',
'langs' => {
'fr' => 1
},
'utf8' => 1
},
'miscellaneous' => {
'numlock' => 1,
'HDPARM' => 1
},
'mouse' => {
'EmulateWheel' => undef,
'MOUSETYPE' => 'ps/2',
'Protocol' => 'ExplorerPS/2',
'device' => 'input/mice',
'evdev_mice' => [
{
'HWheelRelativeAxisButtons' => '7 6',
'device' => '/dev/input/by-id/usb-noserial-event-mouse'
}
],
'evdev_mice_all' => [
{
'HWheelRelativeAxisButtons' => '7 6',
'device' => '/dev/input/by-id/usb-noserial-event-mouse'
}
],
'name' => 'Any PS/2 & USB mice',
'nbuttons' => 7,
'synaptics' => undef,
'type' => 'Universal',
'wacom' => []
},
'net' => {
'PROFILE' => 'default',
'ethernet' => {},
'ifcfg' => {
},
'net_interface' => '',
'network' => {
'CRDA_DOMAIN' => 'FR',
'FORWARD_IPV4' => 'false',
'GATEWAY' => '',
'NETWORKING' => 'yes'
},
'resolv' => {
'DOMAINNAME' => undef,
'DOMAINNAME2' => undef,
'DOMAINNAME3' => undef,
'dnsServer' => undef,
'dnsServer2' => undef,
'dnsServer3' => undef
},
'type' => 'ethernet',
'wireless' => {},
'zeroconf' => {}
},
'bootloader' => {
'method' => 'grub2-graphic',
'boot' => '/dev/sda',
'timeout' => 5,
'crushMbr' => 1,
},
'security' => 1,
'security_user' => undef,
'superuser' => {
'gid' => '0',
'home' => '/root',
'pw' => '$6$4olYuu4o35YoPivZ$jJVF1JHdP9g2rMRivkHywyPZfHe/b/d9RtD09/0p8NBRmCgTQy0x5rgHcBm18D66Dqf0HSZcd8QjSAgiAaV1/1',
'realname' => 'root',
'shell' => '/bin/bash',
'uid' => '0'
},
'timezone' => {
'UTC' => 0,
'ntp' => 'pool.ntp.org',
'timezone' => 'Europe/Paris'
},
'users' => [
{
'gid' => '500',
'groups' => [],
'icon' => 'default',
'name' => 'lalis',
'password' => 'lalis',
'realname' => undef,
'shell' => '/bin/bash',
'uid' => '500'
}
]
};
© 2022 Laboratoire Ouvert Lyonnais
Page: 131ms Modèle: 6ms français
Site web

View File

@ -0,0 +1,8 @@
'enabled_media' => [
'Core Release',
'Core Updates',
'Nonfree Release',
'Nonfree Updates',
'Tainted Release',
'Tainted Updates'
],

View File

@ -0,0 +1,85 @@
'keyboard' => {
'GRP_TOGGLE' => '',
'KEYBOARD' => 'fr'
},
'locale' => {
'IM' => undef,
'country' => 'FR',
'lang' => 'fr',
'langs' => {
'fr' => 1
},
'utf8' => 1
},
'miscellaneous' => {
'numlock' => 1,
'HDPARM' => 1
},
'mouse' => {
'EmulateWheel' => undef,
'MOUSETYPE' => 'ps/2',
'Protocol' => 'ExplorerPS/2',
'device' => 'input/mice',
'evdev_mice' => [
{
'HWheelRelativeAxisButtons' => '7 6',
'device' => '/dev/input/by-id/usb-noserial-event-mouse'
}
],
'evdev_mice_all' => [
{
'HWheelRelativeAxisButtons' => '7 6',
'device' => '/dev/input/by-id/usb-noserial-event-mouse'
}
],
'name' => 'Any PS/2 & USB mice',
'nbuttons' => 7,
'synaptics' => undef,
'type' => 'Universal',
'wacom' => []
},
'net' => {
'PROFILE' => 'default',
'ethernet' => {},
'ifcfg' => {
},
'net_interface' => '',
'network' => {
'CRDA_DOMAIN' => 'FR',
'FORWARD_IPV4' => 'false',
'GATEWAY' => '',
'NETWORKING' => 'yes'
},
'resolv' => {
'DOMAINNAME' => undef,
'DOMAINNAME2' => undef,
'DOMAINNAME3' => undef,
'dnsServer' => undef,
'dnsServer2' => undef,
'dnsServer3' => undef
},
'type' => 'ethernet',
'wireless' => {},
'zeroconf' => {}
},
'bootloader' => {
'method' => '',
'boot' => '',
'timeout' => 5,
'crushMbr' => 1,
},
'security' => 1,
'security_user' => undef,
'superuser' => {
'gid' => '0',
'home' => '/root',
'pw' => '',
'realname' => 'root',
'shell' => '/bin/bash',
'uid' => '0'
},
'timezone' => {
'UTC' => 0,
'ntp' => 'pool.ntp.org',
'timezone' => ''
},

View File

@ -0,0 +1,16 @@
$o = {
'X' => {
'monitors' => [
{
'VendorName' => 'Plug\'n Play',
'manually_chosen' => 1
}
],
'resolution_wanted' => 'x'
},
'authentication' => {
'sha512' => 1,
'shadow' => 1
},
'autoExitInstall' => '1',
'default_packages' => [

View File

@ -0,0 +1,5 @@
'interactiveSteps' => [
'doPartitionDisks',
'formatPartitions',
'summary'
],

View File

@ -0,0 +1,13 @@
'users' => [
{
'gid' => '1000',
'groups' => [],
'icon' => 'default',
'name' => '',
'password' => '',
'realname' => undef,
'shell' => '/bin/bash',
'uid' => '1000'
}
]
};

3
listrpm.kdev4 Normal file
View File

@ -0,0 +1,3 @@
[Project]
Manager=KDevCustomMakeManager
Name=listrpm

311
main.cpp Normal file
View File

@ -0,0 +1,311 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/utsname.h>
#include <errno.h>
#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <array>
#include <memory>
#include <stdexcept>
#include <getopt.h>
#include <filesystem>
#include <cstdlib>
//#include <pstreams/pstream.h>
#include <rpm/rpmlib.h>
#include <rpm/header.h>
#include <rpm/rpmdb.h>
#include <rpm/rpmtypes.h>
#include <rpm/rpmts.h>
#include <rpm/rpmtd.h>
#include <rpm/rpmds.h>
#include <rpm/rpmtag.h>
#include <rpm/rpmfi.h>
#include <rpm/header.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmps.h>
#include <rpm/rpmcli.h>
#include <rpm/rpmio.h>
namespace fs = std::filesystem;
using namespace std;
// Global variables
int verbose = false;
void help(char * cmd)
{
printf("Usage: %s [-lavVf]\n", cmd);
printf("-l List of the first level packages installed\n");
printf("-f Verify the modified files and save them\n");
printf("-a Execute all commands\n" );
printf("-V Display the version of this software\n");
printf("-h Display this help\n");
printf("-v verbose\n");
exit(EXIT_FAILURE);
}
void whatprovides(string cmd, vector<string>& pkgs)
{
string pkg;
string command;
string line;
bool erased = false;
array<char, 128> buffer;
vector <string>::iterator iter;
for ( iter = pkgs.begin(); iter < pkgs.end();)
{
pkg = string(*iter);
command = cmd + pkg;
printf("Searching whatprovides for %s\n", pkg.c_str());
unique_ptr<FILE, decltype(&pclose)> pipe(popen(command.c_str(), "r"), pclose);
if (!pipe) {
throw std::runtime_error("popen() failed!");
}
while (fgets(buffer.data(), buffer.size(), pipe.get()) != NULL)
{
printf("=> %s\n", buffer.data());
line = string(buffer.cbegin(), buffer.cend());
if(line.find(pkg) == std::string::npos)
{
printf("erasing %s\n", pkg.c_str() );
pkgs.erase(iter);
erased = true;
break;
}
}
if (!erased)
{
iter++;
}else
{
erased = false;
buffer.fill(0);
}
}
}
void verification()
{
int result;
int i = 0;
int rsyncErrors = 0;
array<char, 128> buffer;
string cmd = "rpm -a --verify";
string line;
string filepath;
string rsyncdestination = "files/";
string rsynccmd = "rsync -aqP";
printf("Verifying packages installed\n");
flush(cout);
unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd.c_str(), "r"), pclose);
if (!pipe) {
throw std::runtime_error("popen() failed!");
}
while(fgets(buffer.data(), buffer.size(), pipe.get()) != NULL)
{
i = 0;
while(buffer[i] != '\n' )
{
line.push_back(buffer[i]);
i++;
}
printf("line: %s<=====\n", line.c_str());
if (line.at(2) == '5')
{
line.erase(0, 13);
if (verbose) cout << "===>>>>" << line.c_str() << "\n";
rsynccmd = "rsync -aqP --relative " + line + " " + rsyncdestination;
/*rsynccmd.append("rsync -aqP");
rsynccmd.append(line);
rsynccmd.append(" ");
rsynccmd.append(rsyncdestination);*/
if (verbose) printf("%s<====\n", rsynccmd.c_str());
if ((result = system(rsynccmd.c_str())) != 0)
{
rsyncErrors ++;
}
}
buffer.fill(0);
line.clear();
rsynccmd.clear();
}
if (rsyncErrors != 0) printf("rsync returned %i errors", rsyncErrors);
}
int mkauto_inst()
{
bool returnCode = 0;
string dirpath = "auto_inst.files";
return returnCode;
}
int main(int argc, char** argv)
{
/*rpmdbMatchIterator mi;
//int type, count;
//char *name;
rpmdb db;
Header h;
rpmtd td;
rpmTagVal result;
rpmts ts = NULL;
rpmds ds = NULL;
const char *DNEVR;
*/
struct utsname buffer;
int i = 0;
errno = 0;
bool x64 = 0;
string line;
string tmpfile = "/tmp/installedrpmlist.txt";
string pkgsfile = "pkgsfile.txt";
string rpmcmd = "/usr/bin/rpm -q";
string rpmfullcmd;
string whatrequirescmd;
size_t found;
string pkg;
vector <string> pkgs;
vector <string>::iterator iter;
set <string> requires;
set <string>::iterator reqiter;
ofstream fh;
int verif = false;
int opt = 0;
int list = false;
rpmfullcmd = rpmcmd + "a >" + tmpfile;
whatrequirescmd = "urpmq --whatrequires ";
// listing arguments
if(argc>1)
{
while((opt = getopt(argc, argv, "valVf")) != -1)
{
switch (opt)
{
case 'f':
verif = true;
break;
case 'l':
list = true;
break;
case 'a':
list = true;
verif = true;
break;
case 'v':
verbose = true;
break;
default:
help(argv[0]);
}
}
}else
{
cout << "no args\n";
help(argv[0]);
}
if (verbose == true)
{
printf("%s\n", rpmfullcmd.c_str());
printf("%s\n", whatrequirescmd.c_str());
}
// getting processeur architecture
if (uname(&buffer) < 0)
{
perror("uname");
exit(EXIT_FAILURE);
}
if ( strcmp(buffer.machine, "x86_64") == 0)
{
x64 = true;
}
if (verbose) printf("architecture is %s\n", buffer.machine);
if (list == true)
{
// launching rpm -qa ...
if (system(rpmfullcmd.c_str()) != 0)
{
cout << "system return an error\n";
exit(EXIT_FAILURE);
}
// opening file generated by rpm -qa
cout << "Opening file generated by rpm -qa\n";
ifstream myfile (tmpfile);
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
found = line.find_last_of("-"); // searching first "." delimiting version string
found = line.find_last_of("-", found - 1);
if (found != std::string::npos)
{
line.erase(found, string::npos); // erasing version string
}
/*found = line.find_last_of("-");
if (found != std::string::npos)
{
line.erase(found, string::npos); // erasing version string
}*/
pkgs.push_back(line); // inserting line in array (set)
}
myfile.close();
}else
{
cout << "Unable to open file\n";
exit(EXIT_FAILURE);
}
/*
for ( iter = pkgs.begin(); iter < pkgs.end();)
{
found = string(*iter).find("lib");
if (found != string::npos and found == 0)
{
printf("erasing %s\n", string(*iter).c_str() );printf("\n");
pkgs.erase(iter);
}else
{
iter++;
}
}
*/
// searching whatrequires for every pkg
whatprovides(whatrequirescmd, pkgs);
// saving to file
if (verbose) cout << "Saving result to file" << pkgsfile << "\n";
fh.open(pkgsfile);
for( iter = pkgs.begin(); iter < pkgs.end(); ++iter)
{
fh << *iter << " ";
}
fh.close();
}
if( verif == true)
{
verification();
}
cout << "finished\n";
exit(EXIT_SUCCESS);
}