This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathupdate-lvm.sh
executable file
·136 lines (113 loc) · 3.06 KB
/
update-lvm.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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/sh
# Script to checkout LVM2 from git and make attributes for all versions that
# don't have yet.
#
# Author: Elan Ruusamäe <[email protected]>
#
# Usage:
# - update all versions: ./update-lvm.sh -a
# - update specific version "2.0.102": ./update-lvm.sh v2_02_102
# ADDING ATTRIBUTES:
# To add attributes:
# * Download and extract LVM2 source version from: http://git.fedorahosted.org/cgit/lvm2.git/refs/tags
# * Fork this repository
# * `git clone your-forked-repo`
# * `cd your-forked-repo`
# * `git checkout -b mybranch`
# * `bin/generate_field_data path/to/lvm2-source`
# * See missing attribute type note below if there's issues, otherwise will just return "Done."
# * `mv LVM_VERSION_FULL lib/lvm/attributes/LVM_VERSION`
# * LVM_VERSION_FULL being something like 2.02.86(2)-cvs or 2.02.98(2)-git
# * LVM_VERSION being something like 2.02.86(2) or 2.02.98(2)
# * `git commit -am "Added LVM_VERSION attributes"`
# * `git push origin mybranch`
# * Submit PR to this repository. **Please make sure to point your pull at the
# `next` branch -- NOT MASTER!**
#
repo_url=git://git.fedorahosted.org/git/lvm2.git
refs=refs/heads/master:refs/remotes/origin/master
pattern=v2_02_*
git_dir=lvm2/.git
set -e
msg() {
echo >&2 "$*"
}
# do initial clone or update LVM2 repository
clone_lvm2() {
if [ ! -d $GIT_DIR ]; then
msg "Checkout $repo_url"
install -d $GIT_DIR
git init
git remote add origin $repo_url
git fetch --depth 1 origin $refs --tags
else
msg "Update $repo_url"
git fetch origin $refs --tags
fi
}
process_lvm2_version() {
local tag=$1
msg ""
msg "Process LVM2 $tag"
# already present in source tree
if [ -d lib/lvm/attributes/$tag ]; then
msg "lib/lvm/attributes/$tag already exists, skip"
return 1
fi
msg "Checkout LVM2 $tag"
cd lvm2
git checkout $tag
cd ..
version=$(awk '{print $1}' lvm2/VERSION)
msg "LVM2 Full Version: $version"
# skip old "cvs" releases
case "$version" in
*-cvs)
msg "$version is CVS tag, skip"
return 1
;;
esac
# already present locally
if [ -d $version ]; then
msg "dir '$version' exists, skip"
return 1
fi
# dir where attributes get saved
lvm_dir=$version
# remove -git suffix
version=${version%-git}
git_branch=LVM-${version}
# check that local branch isn't already created
if git show-ref --verify --quiet refs/heads/$git_branch; then
msg "Git branch '$git_branch' already exists; skip"
return 1
fi
./bin/generate_field_data lvm2
attr_dir=lib/lvm/attributes/${version}
if [ -d "$attr_dir" ]; then
msg "$attr_dir already exists, skip"
return 1
fi
mv $lvm_dir $attr_dir
git add -A $attr_dir
git checkout -b $git_branch next
git commit -am "Added $tag attributes"
return 0
}
GIT_DIR=$git_dir clone_lvm2
if [ "$1" = "-a" ]; then
# obtain all versions
set -- $(GIT_DIR=$git_dir git tag -l $pattern)
fi
# it shouldn't be exported, but somewhy is. unset
unset GIT_DIR
# process versions specified on commandline,
# otherwise iterate over all LVM2 tags
for tag in "$@"; do
process_lvm2_version $tag || continue
updated=1
done
if [ -z "$updated" ]; then
echo >&2 "Nothing updated"
exit 1
fi