<---- template headericclude ----->
rpm -qa "C" parser
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2012
    Location
    München, Deutschland
    Posts
    897
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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_

  2. #2
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    1,345
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    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.

  3. #3
    Join Date
    Mar 2012
    Location
    München, Deutschland
    Posts
    897
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Re: rpm -qa "C" parser

    Quote Originally Posted by HaydnH
    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_

  4. #4
    Join Date
    Oct 2011
    Posts
    1,917
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  5. #5
    Join Date
    Mar 2012
    Location
    München, Deutschland
    Posts
    897
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Re: rpm -qa "C" parser

    Quote Originally Posted by srakitnican
    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_

Similar Threads

  1. Can't access "lost+found" or "root" in "Computer" directory
    By jeb3121 in forum Installation, Upgrades and Live Media
    Replies: 5
    Last Post: 27th November 2013, 04:36 PM
  2. Replies: 1
    Last Post: 21st November 2011, 04:09 AM
  3. Replies: 0
    Last Post: 19th June 2008, 04:49 PM
  4. Replies: 0
    Last Post: 29th August 2007, 05:53 PM
  5. Replies: 0
    Last Post: 23rd May 2005, 04:59 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
[[template footer(Guest)]]