[opensuse] Updated scripts for local repository management
Listmates, For anyone that maintains (or wants to try to maintain) a local repository of rpms to update your local boxes with, I have an updated set of scripts that do this. (anyone who is using the older scripts is encouraged to upgrade) The scripts do a whole lot work for you and the fdup... scripts are handy on their own for managing duplicate files (older/newer versions with same file name) regardless of whether they are rpms or not. [If you were brave enough to have tried the last set, the changes here just move some of the pieces from the client to the server to eliminate ssh calls and fix an annoying (but harmless) bug in the duplicate script where an extra bit of path info was appended to the path for the oss and update cache locations. There was also a fairly significant clean up of the output to make things look better when the scipts were running. Logging operations were unchanged.] Basically the scripts do everything from parsing the saved rpms in /var/cache/zypp/packages on the client to updating and signing your local repository on whatever host you use for your local rpm repository. (the server can be another host on your LAN -or- the same machine as the client) Basically this setup will take the spider-web of cached rpms under /var/cache/zypp/packages, remove any duplicates (moved to /home/backup not deleted) rsync the files to the local server, remove any duplicates from the repo (including new duplicates created by the rsync update), update the metadata, sign the repository and then offer to remove the cached rpms in /var/cache/zypp/.. The bzip file of scripts is at: http://www.3111skyline.com/download/openSUSE/pkgmanage/pkgmanage.tar.bz2 The individual scripts are also in the directory as well. The contents of the bzip file is: data/fduprpm - main parse and move duplicates script ** data/xmlparse-srv - main server repo management script data/fduprun - wrapper for fduprpm on the server client/zyppmerge.dev - main client repo management script client/fduplocal - wrapper for fduprpm on the client ** Note you also need to copy fduprpm to the client as well The files are in two directories [ data & client ]. The scripts in the data directory go on the server and the client scripts are for each client. I simply keep the data directory just above the top level of my local repository on my network server and use it to hold the server-side scripts to manage the repositories: 20:19 nirvana:/home/backup/rpms> ls -1 data dups openSUSE_11.0 openSUSE_11.1 openSUSE_11.2 My local repository has the normal structure: 20:19 nirvana:/home/backup/rpms> ls -1 openSUSE_11.0 delta i386 i586 i686 noarch repodata src x86_64 On the "client" side, I just put the client scripts in /usr/local/bin. Before you set up your local repository, you will need to set the zypper -- keeppackages=1 option on any of the openSuSE repositories you want to save rpms from, AND: 1) You need to set up passwordless ssh key access from your client to your local server (on client, use "ssh-keygen -t dsa" and copy the resulting ~/.ssh/id_dsa.pub from the client to the server ~/.ssh/authorized_keys file) 2) Unless you want to run the scripts as root, you need to set up "sudo" access for yourself on BOTH the client and the server. ("visudo" and then uncomment the "%wheel ALL=(ALL) NOPASSWD: SETENV: ALL" line to give members of the wheel group sudo privileges; then add yourself to the wheel group) 3) You will need to set a gpg key pair on the server to use for signing the repository. After you generate a key to sign the repository with, specify the path to the key on line 102 of xmlparse-srv: 102 REPOKEY="/home/david/.dcr/repokey" For a howto on creating the key, (see: http://en.opensuse.org/Creating_a_Kernel_Module_Update_Installation_Source and http://www.novell.com/communities/node/6335/creating-yum-repository-and- publishing-it-smt) 4) Edit the zyppmerge.dev script (lines 101 and 102) and set the default hostname and path you are using for your local repo: 101 REPOHOST=${1:-nirvana.3111skyline.com} 102 REPOPATH=/home/backup/rpms/${RPMDIR} Go ahead an look though the variable blocks in zyppmerge.dev and xmlparse- srv and adjust any of the other paths, etc. to fit with your setup. Generally, you only need to set one or two variables. Then if you are using the default setup here, the rest takes care of itself. 5) Not specifically required, but I would go ahead and create the directory structure and set the permissions that will allow rpms to be written to them before running the scripts. The scripts should create all required directories, but this will help avoid any permission problems. Example: "mkdir -p pathyouwant/openSUSE_11.0/{delta,i386,i586,i686,noarch,repodata,src,x86_64}" 6) There are probably several other things I haven't thought to mention here, but thankfully I put relatively meaningful error checks in that should point you to anything else that needs adjusting. If you already have rpms cached on any of your desktops boxes, all you really need to do is make sure you have the path information set and 1-6 checked above, then just run the "zyppmerge.dev" script on the client. It will offer to move duplicates (older versions) of rpms in /var/cache/zypp/packages to (default: /home/backup/rpms/dups). It doesn't hurt to answer "no" and skip running fduplocal. After handling duplicates, the script then parses all subdirectories under /var/cache/zypp/packages and separates all rpms found by architecture or delta and passes the list to rsync to transfer to your local server (it just copies the rpms if your repo is also localhost). After all rpms have been transferred to the server, zyppmerge.dev passes control to xmlparse-srv on the server via ssh. xmlparse-srv then moves all duplicates out of your repository before, downloading the latest deltainfo.xml.gz from openSuSE, parses the XML file and creates your local deltainfo.xml.gz file, updating the repository metadata (with YUM sqlite and XML data), signing the repository with the gpg key and passing control back to your desktop box. Once back at your desktop, the script offers to remove all of the rpms under /var/cache/zypp/packages. (your choice, you can keep a second set in /var/cache and it doesn't affect future operations). That should be about it. The biggest headache with the local repo is just managing the deltainfo.xml.gz file so your server know what delta are available there and managing the duplicates so you always have just the latest version in your local repo. These scripts handle that part for you on both ends (at the client and the server). I strongly suggest diabling the use of delta rpms in your zypp.conf file. While they are faster to download, they are computationally intensive for the clients. Plus with the full rpms, you always have the whole rpm in one file. To disable the use of deltas, just change the setting in /etc/zypp/zypp.conf and set: download.use_deltarpm = false The comment in the file says: ## There is no further processing needed, as it is for a .delta.rpm. ## Whether to consider using a .delta.rpm when downloading a package ## Using a delta rpm will decrease the download size for package updates ## not too slow, you benefit from disabling .delta.rpm. The scripts are fairly well commented so they are not that bad to go through. If you are someone who has thought about learning shell scripting, these scripts would be a fairly good set to tear apart and keep a few parts for later use. They are not all inclusive, but they cover a fair range of BASH capabilities. Let me know if something blows up on you and I'll see if I can fix it. Good luck. -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wednesday 23 September 2009 11:20:19 pm David C. Rankin wrote:
For anyone that maintains (or wants to try to maintain) a local repository of rpms to update your local boxes with, I have an updated set of scripts that do this. (anyone who is using the older scripts is encouraged to upgrade) The scripts do a whole lot work for you and the fdup... scripts are handy on their own for managing duplicate files (older/newer versions with same file name) regardless of whether they are rpms or not.
OK, I'm done tweaking for a while. The local repository setup is working good. Last updates to the scripts are in: http://www.3111skyline.com/download/openSUSE/pkgmanage/pkgmanage.tar.bz2 Usage notes are in the README.txt, and a more complete (but a bit dated) write-up at: http://www.3111skyline.com/linux/openSuSE-LocalUpdate.php One note that I haven't included, but will, is the fact that your client you first download a set of updates from the openSuSE servers to should NOT have the local update repository enabled at the time you do the updates. Why? Since the local update repository has a lower number priority (higher) than then default repos, your client will not download the newer package versions from openSuSE if the local repo is enabled. Just use yast to disable the local repo temporarily, get the updates from openSuSE, use the zyppmerge.dev script to move the new rpms to your local update server, then re-enable to repository. (in case you update from another workstation next time) Setting your the repository priority of your local repo on the clients to anything lower than the default for the openSuSE "Update" repo works great. (I use 18). If you disable the openSuSE Update repo on your clients (accept for the one you download the Updates to), then you can set the priority to anything less than the repo default of 99 and it works fine. -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (1)
-
David C. Rankin