-
Notifications
You must be signed in to change notification settings - Fork 8
/
versionlock.sh
executable file
·32 lines (23 loc) · 1.04 KB
/
versionlock.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
# A simple script to help manage yum versionlock lists.
#
# versionlock.sh list-installed /tmp/basePackages
# Write a package-per-line list of installed packages to the supplied path
#
# versionlock.sh lock-new /tmp/basePackages
# Add a yum versionlock for any packages installed now, that aren't listed
# in the supplied package list (generated by list-installed earlier).
#
function dumpInstalled {
# The 'tr' fun is to get around the fact that yum list always wraps lines. This puts them back.
yum -q list installed | tr "\n" "#" | sed -e 's/# / /g' | tr "#" "\n" | cut -d ' ' -f 1 | sort > $1
}
if [ "$1" == "list-installed" ]; then
dumpInstalled $2
elif [ "$1" == "lock-new" ]; then
dumpInstalled "$2-delta"
# This may have line too long issues at some point, but doing a lock-per
# package is not only horrendously slow, but adds a timestamp for each
# package which makes diffs harder to understand.
yum versionlock $(diff --new-line-format="%L" --old-line-format="" --unchanged-line-format="" $2 "$2-delta" )
fi