Sponsored Content
Full Discussion: RPM Repo Cleanup
Top Forums UNIX for Advanced & Expert Users RPM Repo Cleanup Post 303009527 by drysdalk on Friday 15th of December 2017 10:57:32 AM
Old 12-15-2017
Hi,

As a general approach, you could try something like this:

1. Identify the first part of each filename before the version number and architecture (e.g. for foo-1.3.2-1024.1.rhel6.x86_64.rpm, you'd want to just capture the foo- part).

2. For each base filename determined in Step 1, do an ls on all of them in chronological or alphabetical order (or whatever order you desire).

3. From the output of Step 2, keep the last X lines of the output.

4. Keep only those files you listed in Step 3, and remove/archive every other foo-*rpm file that was not on the list.

That's the first idea that springs to mind, anyway.

The second method I can think of (and the one I'd probably use myself in this type of situation) is to use find. If you could clearly identify a cut-off point in time beyond which you wanted to discard all RPMs, then something like this might work:

Code:
find /path/to/rpms -type f -name "*.rpm" -mtime +31 -exec rm -fv \{\} \;

This particular example would remove all files with names matching the pattern *.rpm older than 31 days. Note again that this will only be safe if you are sure that every part of this is safe to do: i.e. that there's nothing else you could accidentally match with *.rpm beneath /path/to/rpms/ other than the RPMs you want to remove; and that 31 days is an acceptable and safe cut-off point beyond which it is definitely safe to delete things.

Anyway, there's a couple of possibilities for you to consider.
 

10 More Discussions You Might Find Interesting

1. Linux

Failed dependencies of rpm / how does RPM check for ?

Hey, I've a problem installing a package. rpm -ivh brings the errors: libjvm.so is needed by libverify.so is needed by But I have installed the Java SDK like requested and the files are on the disk. But I have no idea how to find out, why rpm cann't find them. I have also... (2 Replies)
Discussion started by: mod
2 Replies

2. Linux

Converting source rpm to binary rpm

Hi, I need to install an rpm file,but I only have '.src.rpm' version of it. I want to convert it to a binary rpm. so I tried this rpm --rebuild somethin.src.rpm But I am gettin '--rebuild:Invalid option' as output Is there another way to rebuild source rpm.? Thanks in... (2 Replies)
Discussion started by: eamani_sun
2 Replies

3. SuSE

How to install .src.rpm ? ( source rpm )

Hi, I have got few RPM's from rpmfind.net ( mainly gcc ). But it seems to be src files instead of the image. so I think we have to build the src files according to target machine using rpmbuild. Can any one help me with 1) Various options of rpm build that have to be taken care 2)... (3 Replies)
Discussion started by: Sivaswami
3 Replies

4. Shell Programming and Scripting

Extract RPM name from path to .rpm file

It's the end of the day and I just can't get my head around this. I'm trying to extract just the name of the RPM from the path to a .rpm file. So from: /home/me/rpm/RPMS/i386/nagios-our-plugins-1.2-6.i386.rpmI need to extract 'nagios-our-plugins'. I can't get the awk syntax right: awk '{... (5 Replies)
Discussion started by: aussieos
5 Replies

5. Shell Programming and Scripting

How to make RPM not write to RPM database if RPM fails to deploy?

How to make RPM not write to RPM database if RPM fails to deploy? IE I create an rpm spec file that contains the following if then exit 1 fi My rpm will fail at deployment, but if I do rpm -qa , I can see the rpm in the rpm db (3 Replies)
Discussion started by: 3junior
3 Replies

6. UNIX and Linux Applications

SVN repo issues

We have about 5 different SVN repositories running on SVN 1.6.11 on top of CentOS Linux 6.3. I was asked to migrate our SVN server to a new server last week. We have a cron job that does a Full backup of each repo once a week, and every other night we do an incremental backup via svnadmin dump... (1 Reply)
Discussion started by: glev2005
1 Replies

7. AIX

Rpm issue with autoconf-2.63-1.AIX6.1.noarch.rpm

dears i am trying to install the autoconf-2.63-1.aix6.1.noarch.rpm but its shows the below error message . P700_dev/svn/dependencies>rpm -i autoconf-2.63-1.aix6.1.noarch.rpm error: failed dependencies: m4 is needed by autoconf-2.63-1 P700_dev/svn/dependencies> (6 Replies)
Discussion started by: thecobra151
6 Replies

8. UNIX for Dummies Questions & Answers

Configuring EPEL repo and setting it as default repo.

I am using RHEL 6, but with no RHN subscription. I tried installing the EPEL repo, it is enabled under yum repolist but when I try a sample search such as yum search nginx , there's a string of errno 14 PYCURL error 6 . When I tried yum list installed, it didn't work because it defaults to the... (0 Replies)
Discussion started by: Hijanoqu
0 Replies

9. Solaris

Solaris Repo Update

Hi Folks, Just a quick question on this, I've tried to run this a couple of times now - first time it failed I increased the swap. I'm not sure that increasing the physical memory will do any good, but will try later today - has anyone seen this or anything similar? SunOS fvssphsun01 5.11... (8 Replies)
Discussion started by: gull04
8 Replies

10. UNIX for Beginners Questions & Answers

Find which RPM Azure repo is used in "yum repolist" for EUS or non EUS repos

Hello, I'm looking for help with a script or ideally just a one line command perhaps that will check the results of yum repolist and look for a specific repo on a sever. We have some VM's using EUS repos from Red Hat and others that do not use EUS repos. The way we would see which repos are... (2 Replies)
Discussion started by: greavette
2 Replies
build(1)                                                      General Commands Manual                                                     build(1)

NAME
build - build SuSE Linux RPMs in a chroot environment SYNOPSIS
build [--clean|--no-init] [--rpms path1:path2:...] [--arch arch1:arch2:...] [--root buildroot] [specfile|srcrpm] build --help build --verify DESCRIPTION
build is a tool to build SuSE Linux RPMs in a safe and clean way. build will install a minimal SuSE Linux as build system into some direc- tory and will chroot to this system to compile the package. This way you don't risk to corrupt your working system (due to a broken spec file for example), even if the package does not use BuildRoot. build searches the spec file for a BuildRequires: line; if such a line is found, all the specified rpms are installed. Otherwise a selec- tion of default packages are used. Note that build doesn't automatically resolve missing dependencies, so the specified rpms have to be sufficient for the build. If a spec file is specified on the command line, build will use this file and all other files in the directory for building the package. If a srcrpm is specified, build automatically unpacks it for the build. If neither is given, build will use all the specfiles in the current directory. OPTIONS
--clean remove the build system and reinitialize it from scratch. --no-init skip the build system initialization and start with build immediately. --list-state list rpms that would be used to create a fresh build root. Does not create the build root or perform a build. --rpms path1:path2:path3... Where build can find the SuSE Linux RPMs needed to create the build system. This option overrides the BUILD_RPMS environment vari- able. --arch arch1:arch2:arch3... What architectures to select from the RPMs. build automatically sets this to a sensible value for your host if you don't specify this option. --root buildroot Specifies where the build system is set up. Overrides the BUILD_ROOT enviroment variable. --useusedforbuild Tell build not to do dependency expansion, but to extract the list of packages to install from "# usedforbuild" lines or, if none are found, from all "BuildRequires" lines. This option is useful if you want to re-build a package from a srcrpm with exactly the same packages used for the srcrpm build. --norootforbuild --help Print a short help text. --verify verify the files in an existing build system. .spec FILE OPTIONS The build command interprets some special control comments in the specfile: # norootforbuild # needsrootforbuild build uses either user root or user abuild in the build system to do the build. For non-SUSE distros as well as since SUSE 10.2, the default build user is abuild. For 10.2 and before, the default build user is root. These two flags in the spec file allow to deviate from the defaults and force-set the build user to abuild and root (for # norootforbuild and # needsrootforbuild respec- tively. # needsbinariesforbuild provide the binary rpms that have been used to set up the build root in /.build.binaries within the build root. ENVIRONMENT
BUILD_ROOT The directory where build should install the chrooted build system. "/var/tmp/build-root" is used by default. BUILD_RPMS Where build can find the SuSE Linux RPMs. build needs them to create the build system. "/media/dvd/suse" is the default value which will do the trick if you have the SuSE Linux DVD mounted. BUILD_RPM_BUILD_STAGE The rpm build stage (-ba, -bb, ...). This is just passed through to rpm, check the rpm manpage for a complete list and descrip- tions. "-ba" is the default. You can use this to add more options to RPM. SEE ALSO
rpm(1), Maximum RPM: http://www.rpm.org/max-rpm/ cross distribution packaging: http://en.opensuse.org/Build_Service/cross_distribution_package_how_to SUSE packaging standards and guidelines: http://en.opensuse.org/Packaging (c) 1997-2008 SuSE Linux AG Nuernberg, Germany build(1)
All times are GMT -4. The time now is 11:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy