-
Notifications
You must be signed in to change notification settings - Fork 36
/
yum-upload
81 lines (69 loc) · 2.13 KB
/
yum-upload
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#! /bin/bash
# Uploads a binary distribution to a yum(1) repository. The distribution is
# read from the standard input stream.
#
# Usage: $0 distro
#
# where:
# distro Relative path to the distribution from the directory containing
# this script. The name component of the file must have the form
#
# <name>-<version>[-<release>].<cpu>.rpm
#
# where:
# <name> Package name (e.g., "udunits")
# <version> Package version (e.g., "2.2.3")
# <release> Optional package release number (e.g., "4").
# Ignored.
# <cpu> Package CPU (e.g., "x86_64")
set -e # Exit on error
distro=${1:?Distribution not specified}
# Assume that this script is in the root-directory of the complete binary
# repository and go to it.
#
cd `dirname $0`
# Vet and parse the distribution's filename.
#
repoDir=`dirname "$distro"`
distroName=`basename "$distro"`
if ! echo $distroName | egrep -q '[^-]+-[0-9.]+(-[0-9]+)?\.[^.]+\.rpm';
then
echo 1>&2 "Invalid distribution name: \"$distroName\""
exit 1
fi
set `echo "$distroName" |
sed -r 's/([^-]+-[0-9.]+)(-[0-9]+)?\.([^.]+)\.rpm/\1 \3/'`
pkgId=$1
pkgCpu=$2
# Ensure that the repository directory exists and go to it.
#
test -d $repoDir || mkdir -p $repoDir
pushd $repoDir
# Glob pattern for all releases of the same version of the same package in the
# repository directory:
#
releaseGlob=$pkgId-*.$pkgCpu.rpm
# Determine what the next release number should be.
#
if prevRelease=`ls $releaseGlob 2>/dev/null |
sed -r "s/$pkgId-([0-9]*)\.$pkgCpu\.rpm/\1/"`; then
pkgRelease=$(($prevRelease+1))
else
pkgRelease=1
fi
# Copy the distribution to the repository file.
#
distroPath=$pkgId-$pkgRelease.$pkgCpu.rpm
cat >$distroPath
# Delete all previous releases of the same version of the same package.
#
rm -f `ls $releaseGlob | fgrep -v $distroPath`
# Go to the root-directory of the complete binary repository.
#
popd
# Create a yum(1) repository in the repository directory.
#
createrepo $repoDir
# Copy the yum(1) repository to the publicly-accessible repository computer.
#
rsync --archive --relative --delete $repoDir www:/web/content/repos/yum