yum --downloadonly ignores packages in local repo

Viewed 379

I have two repos configured, one accessed via baseurl=http://... and one via baseurl=file://... (a local repo). When I run this command:

sudo yum -y update --downloadonly --downloaddir=foo

The command runs and lists many packages. However foo only contains packages from the remote repo not the local one. How do I 'download' the local files too?

What I am trying to do is pair down a local repo containing far more RPMs than I need down to just the ones I need to run an update. The idea being to create a new local repo containing only what I need.

1 Answers

I have confirmed by reading the yum source code that this is intended, but annoying, behaviour.

The solution I found was:

In the repo file:

[local]
name=local
baseurl=http://localhost:9999

In Python:

import http.server
import socketserver
import threading
os.chdir('/path to repo')
# We need the web server to run in its own thread
class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
  pass
httpd = ThreadedTCPServer(("127.0.0.1", 9999), http.server.SimpleHTTPRequestHandler)
httpd_thread = threading.Thread(target=httpd.serve_forever)
httpd_thread.daemon = True
httpd_thread.start()

...
yum stuff
...

httpd.shutdown()
httpd.server_close()
Related