Fedora Linux Support Community & Resources Center
  #1  
Old 16th May 2017, 08:31 AM
nobody Offline
Registered User
 
Join Date: Mar 2012
Location: München, Deutschland
Posts: 847
windows_98_nt_2000chrome
Arrow rpm -qa "C" parser

As promised from the problems I had encountered in The Past, described here:
Policy kit daemon fails to start due to Timeout
http://www.forums.fedoraforum.org/sh...d.php?t=313847

I have created the following C code, which can be pulled out of GitHub public repository:
https://github.com/nobbody/rpm_qa_C_parser

It is under GPL3 licence.

Quote:
Originally Posted by README.md
Author: nobodyless@gmail.com, GPL3 copyright!

To compile: gcc rpm_qa.c -o rpm_qa To execute: ./rpm_qa infile outfile [dnf] (dnf string optional)

Here, as example, the infile given is: rpm_F27_querry_all.txt

The command: ./rpm_qa rpm_F27_querry_all.txt script.sh dnf

script.sh is also presented, as output of the parser.

With 3rd argument: string "dnf" addition, it will add "dnf install " string to the outfile.

Copyright nobody, GPL3. rpm -qa parser, which makes from the command rpm -qa > input_file.txt simple bash shell script in the case somebody needs to reinstall from schratch Fedora distro, and import all the packages into new one.

Also could be used for other distros, after original C code re-edit (changing char dnf[] constant string to match particular Linux distro command, example Debian: dpkg (equivalent to RHL rpm))!
Since I did not test all corner cases, any/every suggestion is welcome!

_nobody_
__________________
I am nobody, and nobody is perfect, therefore I am perfect!
Reply With Quote
  #2  
Old 18th May 2017, 10:28 AM
HaydnH Offline
Registered User
 
Join Date: Feb 2005
Location: London, UK
Posts: 436
windows_7chrome
Re: rpm -qa "C" parser

Hi Nobody,

What does this parser do exactly? Take the output of "rpm -qa" as an input and output a list of "dnf install <package_without_version>" lines?

Haydn.
Reply With Quote
  #3  
Old 19th May 2017, 06:31 AM
nobody Offline
Registered User
 
Join Date: Mar 2012
Location: München, Deutschland
Posts: 847
windows_98_nt_2000chrome
Talking Re: rpm -qa "C" parser

Quote:
Originally Posted by HaydnH View Post
What does this parser do exactly? Take the output of "rpm -qa" as an input and output a list of "dnf install <package_without_version>" lines?
Exactly!

Steps TO DO for that:
[1] git clone https://github.com/nobbody/rpm_qa_C_parser.git (to pull the package into your local directory);
[2] To compile it: gcc rpm_qa.c -o rpm_qa
[3] To create input file: rpm -qa > list_packages.txt
[4] To execute: ./rpm_qa list_packages.txt packages_clean.txt (in this case you'll have just packages' names);
[5] To execute: ./rpm_qa list_packages.txt packages_clean1.txt dnf (in this case you'll have "dnf install " string in front of the each package's name).



_nobody_
__________________
I am nobody, and nobody is perfect, therefore I am perfect!
Reply With Quote
  #4  
Old 21st May 2017, 07:22 PM
srakitnican Offline
Registered User
 
Join Date: Oct 2011
Posts: 1,438
linuxchrome
Re: rpm -qa "C" parser

This is possible already with nothing more then plain rpm. With --queryformat it is possible to set arbitrary format of output data, the most suitable for passing later is by name and architecture, since there can be at least two different installed at the same time as it is the case for various libraries.

Code:
$ rpm -qa --qf "%{name}.%{arch}\n" > packages-list.txt
Reply With Quote
  #5  
Old 22nd May 2017, 09:41 AM
nobody Offline
Registered User
 
Join Date: Mar 2012
Location: München, Deutschland
Posts: 847
windows_98_nt_2000chrome
Talking Re: rpm -qa "C" parser

Quote:
Originally Posted by srakitnican View Post
This is possible already with nothing more then plain rpm. With --queryformat it is possible to set arbitrary format of output data, the most suitable for passing later is by name and architecture, since there can be at least two different installed at the same time as it is the case for various libraries.

Code:
$ rpm -qa --qf "%{name}.%{arch}\n" > packages-list.txt
Hello srakitnican,

Thank you for useful addition to this thread.

I have tried your one line of online script. It is not ideal (there are some differences, but they are seldom).

I guess, the more suitable script to execute is: rpm -qa --qf "%{name}\n" > packages-list.txt , since we would like to use generic names (not bound with CPU architecture used).

Even better one is: rpm -qa --qf "dnf install %{name}\n" > packages-list.txt , which is very close to the target file (adds to the target file string: "dnf install ").

I'll re-edit README.md file on GitHub project, also to add this rpm on(e)line command possibility for the people to use.

Thank you,
_nobody_
__________________
I am nobody, and nobody is perfect, therefore I am perfect!
Reply With Quote
Reply

Tags
parser, rpm

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't access "lost+found" or "root" in "Computer" directory jeb3121 Installation, Upgrades and Live Media 5 27th November 2013 04:36 PM
unpredictable "delete" "move to trash" or "cut" file menu option dorianrenato Using Fedora 1 21st November 2011 04:09 AM
"ls" and "cd" treat ".." differently inside symlinked directories bnorman Using Fedora 0 19th June 2008 04:49 PM
Metacity and "Xlib: extension "SHAPE" missing on display ":0.0". debu_sagii Using Fedora 0 29th August 2007 05:53 PM
Error:visibility arg must be one of "default", "hidden", "protected" or "internal" wangfeng Using Fedora 0 23rd May 2005 04:59 AM


Current GMT-time: 07:48 (Sunday, 20-08-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat