Skip to content

Commit 7fc1fe5

Browse files
Merge pull request #525 from draios/probe-refactor
Probe refactor
2 parents d6e1ca6 + 9812e84 commit 7fc1fe5

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

scripts/build-probe-binaries

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function build_sysdigcloud {
118118

119119
function coreos_build_old {
120120
VERSION_URL=$1
121-
VERSION_NUMBER=$(echo $VERSION_URL | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
121+
VERSION_NUMBER=$2
122122
COREOS_DIR="coreos-"$VERSION_NUMBER
123123

124124
if [ ! -d $COREOS_DIR ]; then
@@ -175,7 +175,7 @@ function coreos_build_old {
175175

176176
function coreos_build_new {
177177
VERSION_URL=$1
178-
VERSION_NUMBER=$(echo $VERSION_URL | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
178+
VERSION_NUMBER=$2
179179
COREOS_DIR="coreos-"$VERSION_NUMBER
180180

181181
if [ ! -d $COREOS_DIR ]; then
@@ -409,12 +409,11 @@ URLS="$($DIR/kernel-crawler.py CoreOS)"
409409

410410
for URL in $URLS
411411
do
412-
FULL_VERSION=$(echo $URL|cut -d/ -f5)
413-
MAJOR_VERSION=$(echo $FULL_VERSION|cut -d. -f1)
414-
if [ $MAJOR_VERSION -gt 890 ]; then
415-
coreos_build_new $URL
412+
eval $(curl -s ${URL}version.txt)
413+
if [ $COREOS_BUILD -gt 890 ]; then
414+
coreos_build_new $URL $COREOS_VERSION
416415
else
417-
coreos_build_old $URL
416+
coreos_build_old $URL $COREOS_VERSION
418417
fi
419418
done
420419

scripts/kernel-crawler.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
"subdirs" : [
129129
""
130130
],
131-
"page_pattern" : "/html/body//a[regex:test(@href, '^[5-9][0-9][0-9]')]/@href"
131+
"page_pattern" : "/html/body//a[regex:test(@href, '^[5-9][0-9][0-9]|current')]/@href"
132132
},
133133

134134
{
@@ -137,7 +137,7 @@
137137
"subdirs" : [
138138
""
139139
],
140-
"page_pattern" : "/html/body//a[regex:test(@href, '^[5-9][0-9][0-9]')]/@href"
140+
"page_pattern" : "/html/body//a[regex:test(@href, '^[5-9][0-9][0-9]|current')]/@href"
141141
},
142142

143143
{
@@ -146,7 +146,7 @@
146146
"subdirs" : [
147147
""
148148
],
149-
"page_pattern" : "/html/body//a[regex:test(@href, '^[4-9][0-9][0-9]')]/@href"
149+
"page_pattern" : "/html/body//a[regex:test(@href, '^[4-9][0-9][0-9]|current')]/@href"
150150
}
151151
]
152152
}
@@ -157,7 +157,7 @@
157157
# links will be found automagically without needing to write any single line of
158158
# code.
159159
#
160-
packages = {}
160+
urls = set()
161161

162162
if len(sys.argv) < 2 or not sys.argv[1] in repos:
163163
sys.stderr.write("Usage: " + sys.argv[0] + " <distro>\n")
@@ -184,13 +184,12 @@
184184
rpms = html.fromstring(page).xpath(repo["page_pattern"], namespaces = {"regex": "http://exslt.org/regular-expressions"})
185185

186186
for rpm in rpms:
187-
if not rpm in packages:
188-
packages[rpm] = source + rpm
187+
urls.add(source + rpm)
189188
except:
190189
continue
191190

192191
#
193192
# Print URLs to stdout
194193
#
195-
for rpm, url in packages.iteritems():
194+
for url in urls:
196195
print(url)

0 commit comments

Comments
 (0)