» Script to refresh YaST2 installation sources
Since SUSE Linux 10.0, YaST2 has the ability to automatically refresh installation sources (package repositories) when they're marked as "autorefresh".
Nevertheless, in some situations it might be interesting to periodically refresh the repository metadata, e.g. using a cron job.
I quickly hacked a very simple shell script that does so, using y2pmsh (just install the "y2pmsh" package, comes with SUSE Linux):
#!/bin/sh y2pmsh source -s | grep -E '^[0-9]+:' | cut -f 1 -d : | while read n; do y2pmsh source --update "$n" doneIt's pretty simple and straightforward, but might be interesting for someone who's not accustomed to shell scripting. If you want the sources to be refreshed every hour, just save the snippet above as /etc/cron.hourly/yast2-refresh Don't forget to make it executable: chmod +x /etc/cron.hourly/yast2-refresh) Obviously, you have to do both steps as root. Update: darix (Marcus Rueckert) came up with a nice script that uses python-expect. It's slightly different, as it just starts the y2pmsh shell and waits for the prompt, then quits:
#!/usr/bin/python import pexpect s = pexpect.spawn("y2pmsh") s.expect ('.*y2pm.*\>') s.sendline ('quit')This way, you only refresh the repositories that are marked as "auto-refresh". Thanks for the tip Marcus :) To use python-expect, first install my python-pexpect package (or use YaST2/smart/apt/yum if you have my repository configured in one of those).
1 Comments:
thanks for the tip, one question
every time I start yast software install, it takes 2-3 minutes in auto refreshing the installation sources.
I can turn auto refresh off, but that will prevent me from getting latest sources.
Can I use your script in cron job, and keep auto refresh off. that way I can get the best of both worlds right ?
Post a Comment
<< Home