Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11th April 2012, 07:56 AM
kkshethin Offline
Registered User
 
Join Date: Dec 2009
Location: India
Posts: 254
linuxfirefox
command line support

I am using Fedora16 (64 bit). I have installed yum-plugin-local, which collects all rpm packages in directory /var/lib/yum/plugins/local. This directory contains more then one version of rpm packages.

1st question

I want to copy latest packages to another directory. I tried different options of grep but failed. I am not very familiar with command line. so my question is

How can I copy latest versions of rpm packages from /var/lib/yum/plugins/local to another directory?

2nd question

I copied all rpms from dvd to /var/lib/yum/plugins/local and run createrepo. Now I think I can copy latest packages which will be "yum list installed" to another directory. Again i failed with grep. So my question is

How can I copy all latest packages with the help of "yum list installed" from /var/lib/yum/plugins/local to another directory?

I have asked very few questions in last two year and I take these opportunity to express my greatfulness to Fedora, such a nice linux distribution and to all forummembers.

Thanks once again.

Last edited by kkshethin; 11th April 2012 at 08:00 AM.
Reply With Quote
  #2  
Old 11th April 2012, 11:02 AM
marriedto51 Offline
Registered User
 
Join Date: Jul 2009
Location: England, UK
Posts: 821
linuxfirefox
Re: command line support

If you want to do something for each filename that matches an installed package, one way to do that is to use a shell for ... done loop like the following. Save this as a file, make it executable, then run it.
Code:
#!/bin/bash

cd /var/lib/yum/plugins/local

for file in *.rpm ; do
    pkg="${f%.rpm}"
    if rpm -q "$pkg"; then
        echo "I have found an installed packaged %pkg (filename $file)"
        # enter suitable commands here to do the move command that you want
    else
        echo "The filename $file does not match an installed package"
    fi
done
Reply With Quote
  #3  
Old 11th April 2012, 12:10 PM
kkshethin Offline
Registered User
 
Join Date: Dec 2009
Location: India
Posts: 254
linuxfirefox
Re: command line support

i have tried. It gives error for all packages as below

The filename a52dec-0.7.4-15.fc11.x86_64.rpm does not match an installed package
Reply With Quote
  #4  
Old 11th April 2012, 03:14 PM
marriedto51 Offline
Registered User
 
Join Date: Jul 2009
Location: England, UK
Posts: 821
linuxfirefox
Re: command line support

Looking at the script I gave you, I made a typing error: change the line starting "pkg=" to
Code:
pkg="${file%.rpm}"
(otherwise the variable pkg is always empty).
Reply With Quote
  #5  
Old 12th April 2012, 08:54 AM
kkshethin Offline
Registered User
 
Join Date: Dec 2009
Location: India
Posts: 254
linuxfirefox
Re: command line support

thanks for the script. I have added following copy command but it is not working preperly. It copies one package and while copying another package, it deletes earlier. i do not know what is wrong.

Quote:
cd /var/lib/yum/plugins/local

for file in *.rpm ; do
pkg="${file%.rpm}"
if rpm -q "$pkg"; then
echo "I have found an installed packaged %pkg (filename $file)"
# enter suitable commands here to do the move command that you want
cp "$file" /media/kks/local
else
echo "The filename $file does not match an installed package"
fi
done
please help
Reply With Quote
  #6  
Old 12th April 2012, 09:00 AM
marriedto51 Offline
Registered User
 
Join Date: Jul 2009
Location: England, UK
Posts: 821
linuxfirefox
Re: command line support

Quote:
Originally Posted by kkshethin View Post
thanks for the script. I have added following copy command but it is not working preperly. It copies one package and while copying another package, it deletes earlier.
The only thing I can think is that /media/kks/local is not a directory (then the cp command will repeatedly overwrite it).

Make sure you have done
Code:
mkdir -p /media/kks/local/
as root, and perhaps change that "cp" line to
Code:
cp "$file" /media/kks/local/
to stop cp regarding the target as a file to overwrite.
Reply With Quote
  #7  
Old 12th April 2012, 09:24 AM
glennzo's Avatar
glennzo Offline
Un-Retired Administrator
 
Join Date: Mar 2004
Location: Salem, Mass USA
Posts: 13,929
linuxfirefox
Re: command line support

Remove the quotes from around $file in your cp command.
PHP Code:
cp $file /media/kks/local 
__________________
Glenn
The Bassinator © ®


Laptop: Toshiba Satellite / Intel Core 2 Duo 1.73 GHz / 2GB / 160GB / Intel Mobile 945GM/GMS/GME/943/940GML Integrated Graphics
Desktop: BioStar MCP6PB M2+ / AMD Phenom 9750 Quad Core / 4GB / 1TB SATA / 500GB SATA / EVGA GeForce 8400 GS 1GB
Reply With Quote
  #8  
Old 12th April 2012, 12:48 PM
kkshethin Offline
Registered User
 
Join Date: Dec 2009
Location: India
Posts: 254
linuxubuntufirefox
Re: command line support

i corrected it to (I took some from both )

cp $file /media/kks/local/

now it works.

Thanks for script/tips. thank you both.
Reply With Quote
  #9  
Old 26th April 2012, 03:25 PM
kkshethin Offline
Registered User
 
Join Date: Dec 2009
Location: India
Posts: 254
linuxfirefox
Re: command line support

today from another thread "http://www.redhat.com/archives/rhl-list/2007-July/msg03527.html"

i found this

Quote:
Check out repomanage from yum-utils. You could use it something like
this to move old packages to an archive dir (or remove them):

repo=/path/to/cache
archive=/path/to/archive
repomanage --old $repo | while read package; do
mv "$package" $archive
done.
I will try this also & report.

I also found out from "http://blog.kagesenshi.org/2007/01/howto-mirroring-yum-repositories-using.html"

Quote:
Repomanage
Repomanage is a utility for repository managers to manage old and new packages in a repository. It will read the RPM packages in the directory and list out old/new packages from the directory to stdout.

Example of using repomanage for removing old packages in the current directory and its subdirectories.

repomanage --old . |xargs rm -rf

Last edited by kkshethin; 26th April 2012 at 04:09 PM.
Reply With Quote
Reply

Tags
command, grep, line, support, yum-plugin-local

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


Current GMT-time: 05:28 (Wednesday, 22-05-2013)

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