OpenSUSE Linux Rants

OpenSUSE Linux Tips, tricks, how-tos, opinions, and news

My Resume  -  My LinkedIn Profile - twitter: @scottmmorris

December 7, 2009

zypper + bash script = simple repo management

by @ 12:16 am. Filed under bash, sweet tools

I had a smooth, easy experience with a fresh install of openSUSE 11.2 on my desktop this weekend. Man, that was nice.

With the excellent openSUSE Build Service available, I find myself there often. Many times I am looking for more recent versions of packages than what are available from the repositories I have loaded into my machine. Once the packages are found, I usually just grab the repository that they are in and load that into YAST.

For example, let’s say we’re looking for pidgin. Using YaST or zypper, we do a search, and find that we have version 2.6.2 available to us. However, with the openSUSE Build Service, we see that 2.6.3 is available. We’ll just grab the repo for it, which is located directly above the 1-click install button. Right-click on it, select “Copy Link Location.” You have the repo in your clipboard.

Then, we can use zypper to load our repository into YaST, set it to autorefresh, and then refresh it. Then, when we search for pidgin again, 2.6.3 shows up rather than 2.6.2. It’s a quick, easy way to collect and save reliable repositories that have newer packages in them.

To add a repo, then set it to autorefresh, then refresh it takes three, semi-lengthy commands, for example:

[1049][root@laptop:~]$ zypper addrepo "http://download.opensuse.org/repositories/GNOME:/Apps/openSUSE_11.2" "Gnome Apps"

 

Then:

[1049][root@laptop:~]$ zypper modifyrepo -r "Gnome Apps"

 

Then:

[1049][root@laptop:~]$ zypper refresh "Gnome Apps"

 

Rather than type all that out every time, I threw a quick script together that I call ‘repoadd’ (don’t forget to run chmod +x on it to make it executable) to save me all the agony:

#!/bin/sh
# $1 is the repo, i.e. http://download.opensuse.org/repositories/GNOME:/Apps/openSUSE_11.2
# $2 is the name you wish to give it, i.e. "Gnome Apps"
zypper addrepo "$1" "$2"
zypper modifyrepo -r "$2"
zypper refresh "$2"

 

Now, instead of having to type that all out every time, you can just run:

[1049][root@laptop:~]$ repoadd "http://download.opensuse.org/repositories/GNOME:/Apps/openSUSE_11.2" "Gnome Apps"

 

Of course, 1-Click Install does essentially the same thing. I just thought I’d explore and share this different way of going through that process. You never know when those alternative ways of doing things can save your hide.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Diigo
  • email
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Mixx
  • MySpace
  • Twitter
  • Yahoo! Buzz
If you enjoyed this post, make sure you subscribe to my RSS feed!

4 Responses to “zypper + bash script = simple repo management”

  1. Pavol Rusnak Says:

    “zypper addrepo -f” sets autorefresh while adding repository. Also I’m not sure why you need to call refresh after adding an autorefreshed repo (it still will be refreshed before any zypper command).

  2. Michal Hrusecky Says:

    Just one minor note, you can also use
    ‘zypper ar -f http://download.opensuse.org/repositories/GNOME:/Apps/openSUSE_11.2/GNOME:Apps.repo
    It will add repository with some default name and enable autorefresh by default (-f option) and this repo will be refreshed automatically once you will try to do anything with it. But it’s always nice to see people scripting to make their life easier. Keep up good work.

  3. Scott Morris Says:

    That’s the kind of feedback that I *TOTALLY LOVE*! Ways to make stuff way simpler. If I lived around you guys, I’d buy you a drink for your suggestions. I’m humbly honored for your insights. Thank you for stopping by and sharing your thoughts.

  4. Scott Morris Says:

    @Pavol: It’s really kind of a dorky personal preference. When I go to use it with the next command, I don’t like waiting, so I want it already refreshed when I search for packages. Yeah, I’m somewhat impatient. But I mean, it’s totally just my own personal quirk.

Leave a Reply

OpenSUSE Linux Rants
Official OpenSUSE Linux Site

internal links:

categories:

SUSE Resources

search blog:

rss feeds

news & syndication

archives:

March 2010
S M T W T F S
« Feb    
 123456
78910111213
14151617181920
21222324252627
28293031  

latest tweets:

  • Anyone have a 350Z/370Z that I can drive around for a few hours? 2 days ago
  • The skunk thunk the sunk sump pump in the stump stunk. 2 days ago
  • Five Tools for Measuring and Improving Linux System Performance | Linux.com http://tinyurl.com/yd8wglz 1 week ago
  • Beginner's Guide to Nmap | Linux.com http://ow.ly/1pEKDr 1 week ago
  • The Church History Symposium on Fri was spectacular. Vaughn J. Featherstone and Pres. Kimball's son were highlights for me. Fully loved it! 1 week ago
  • A magician was driving down the road... then he turned into a drive way. 2 weeks ago
  • No cavities for me. Yay! :) 2 weeks ago
  • Just finishing getting our proprietary Windows software humming along on wine. At 1:00 AM. 2 weeks ago
  • More updates...

51 queries. 0.684 seconds