Skip to content

Commit 1caa6dd

Browse files
authored
Merge pull request #2601 from flatcar/krnowak/pkg-auto-fixes
pkg-auto: Some fixes made during weekly updates
2 parents 36b79e2 + 020f9fe commit 1caa6dd

File tree

4 files changed

+196
-6
lines changed

4 files changed

+196
-6
lines changed

pkg_auto/diff_pkg.sh

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
source "$(dirname "${BASH_SOURCE[0]}")/impl/util.sh"
6+
7+
##
8+
## Prints a diff of a package in old and new scripts
9+
## directories. Operates in one of two modes. First mode is an
10+
## "ebuild" mode where it shows a diff of two ebuilds. The other mode
11+
## is an "other" mode where it shows diffs of all non-ebuild files
12+
## (ignoring Manifest files too).
13+
##
14+
## Parameters:
15+
## -h: this help
16+
## -r <name>: New package name (useful when package got renamed)
17+
##
18+
## Positional:
19+
## 1: mode, "ebuild" (or "e") or "other" (or "o")
20+
## 2: path to old scripts repository
21+
## 3: path to new scripts repository
22+
## 4: package name (but see -r flag too)
23+
## 5: old version (for "ebuild" mode only)
24+
## 6: new version (for "ebuild" mode only)
25+
##
26+
27+
renamed=
28+
29+
while [[ ${#} -gt 0 ]]; do
30+
case ${1} in
31+
-h)
32+
print_help
33+
exit 0
34+
;;
35+
-r)
36+
renamed=${2}
37+
shift 2
38+
;;
39+
--)
40+
shift
41+
break
42+
;;
43+
-*)
44+
fail "unknown flag ${1@Q}"
45+
;;
46+
*)
47+
break
48+
;;
49+
esac
50+
done
51+
52+
if [[ ${#} -lt 1 ]]; then
53+
fail 'Use -h to get help'
54+
fi
55+
56+
mode=${1}; shift
57+
58+
case ${mode} in
59+
ebuild|ebuil|ebui|ebu|eb|e)
60+
mode=e
61+
if [[ ${#} -ne 5 ]]; then
62+
fail 'Expected five positional parameters: a path to old and new scripts repositories, a package name, and old a new version of package'
63+
fi
64+
;;
65+
other|othe|oth|ot|o)
66+
mode=o
67+
# expect at least three parameters, if more are given, they
68+
# will be ignored, to allow changing mode from ebuild to other
69+
# without the need for removing versions from the command
70+
# invocation
71+
if [[ ${#} -lt 3 ]]; then
72+
fail 'Expected three positional parameters: a path to old and new scripts repositories, and a package name'
73+
fi
74+
;;
75+
esac
76+
77+
old_scripts=${1}
78+
new_scripts=${2}
79+
# old and new package name
80+
old_package=${3}
81+
new_package=${renamed:-${3}}
82+
83+
gentoo_path=sdk_container/src/third_party/portage-stable
84+
overlay_path=sdk_container/src/third_party/coreos-overlay
85+
old_gentoo_path=${old_scripts}/${gentoo_path}/${old_package}
86+
old_overlay_path=${old_scripts}/${overlay_path}/${old_package}
87+
new_gentoo_path=${new_scripts}/${gentoo_path}/${new_package}
88+
new_overlay_path=${new_scripts}/${overlay_path}/${new_package}
89+
90+
if [[ -e ${old_gentoo_path} ]] && [[ -e ${old_overlay_path} ]]; then
91+
fail "Package ${old_package@Q} exists in both gentoo and overlay in old scripts"
92+
fi
93+
94+
if [[ -e ${new_gentoo_path} ]] && [[ -e ${new_overlay_path} ]]; then
95+
fail "Package ${new_package@Q} exists in both gentoo and overlay in new scripts"
96+
fi
97+
98+
if [[ ${mode} = e ]]; then
99+
old_version=${4}
100+
new_version=${5}
101+
old_gentoo_ebuild=${old_gentoo_path}/${old_package#*/}-${old_version}.ebuild
102+
old_overlay_ebuild=${old_overlay_path}/${old_package#*/}-${old_version}.ebuild
103+
new_gentoo_ebuild=${new_gentoo_path}/${new_package#*/}-${new_version}.ebuild
104+
new_overlay_ebuild=${new_overlay_path}/${new_package#*/}-${new_version}.ebuild
105+
106+
old_path=''
107+
new_path=''
108+
109+
if [[ -e ${old_gentoo_ebuild} ]]; then
110+
old_path=${old_gentoo_ebuild}
111+
fi
112+
if [[ -e ${old_overlay_ebuild} ]]; then
113+
old_path=${old_overlay_ebuild}
114+
fi
115+
116+
if [[ -e ${new_gentoo_ebuild} ]]; then
117+
new_path=${new_gentoo_ebuild}
118+
fi
119+
if [[ -e ${new_overlay_ebuild} ]]; then
120+
new_path=${new_overlay_ebuild}
121+
fi
122+
123+
if [[ -z ${old_path} ]]; then
124+
fail "Old version ${old_version@Q} does not exist neither in overlay nor in gentoo"
125+
fi
126+
127+
if [[ -z ${new_path} ]]; then
128+
fail "New version ${new_version@Q} does not exist neither in overlay nor in gentoo"
129+
fi
130+
131+
diff --color --unified=3 "${old_path}" "${new_path}" || :
132+
else
133+
old_path=${old_gentoo_path}
134+
new_path=${new_gentoo_path}
135+
136+
if [[ -e ${old_overlay_path} ]]; then
137+
old_path=${old_overlay_path}
138+
fi
139+
140+
if [[ -e ${new_overlay_path} ]]; then
141+
new_path=${new_overlay_path}
142+
fi
143+
144+
diff --color --recursive --unified=3 --new-file --exclude='*.ebuild' --exclude='Manifest' "${old_path}" "${new_path}" || :
145+
fi

pkg_auto/impl/inside_sdk_container_lib.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ source "$(dirname "${BASH_SOURCE[0]}")/util.sh"
1111
# Params:
1212
#
1313
# 1 - root filesystem with the portage config
14-
# 2 - metapackage to get the deps from
14+
# @ - packages and metapackages to get the deps from
1515
function emerge_pretend() {
16-
local root package
16+
local root
1717
root=${1}; shift
18-
package=${1}; shift
1918

2019
# Probably a bunch of those flags are not necessary, but I'm not
2120
# touching it - they seem to be working. :)
@@ -50,7 +49,7 @@ function emerge_pretend() {
5049
)
5150
local rv
5251
rv=0
53-
emerge "${emerge_opts[@]}" "${package}" || rv=${?}
52+
emerge "${emerge_opts[@]}" "${@}" || rv=${?}
5453
if [[ ${rv} -ne 0 ]]; then
5554
echo "WARNING: emerge exited with status ${rv}" >&2
5655
fi
@@ -62,7 +61,10 @@ function package_info_for_sdk() {
6261
root='/'
6362

6463
ignore_crossdev_stuff "${root}"
65-
emerge_pretend "${root}" coreos-devel/sdk-depends
64+
# stage4 build of SDK builds coreos-devel/sdk-depends, fsscript
65+
# pulls in cross toolchains with crossdev (which we have just
66+
# ignored) and dev-lang/rust
67+
emerge_pretend "${root}" coreos-devel/sdk-depends dev-lang/rust
6668
revert_crossdev_stuff "${root}"
6769
}
6870

pkg_auto/impl/sync_with_gentoo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function commit_with_gentoo_sha() {
169169
if [[ -z ${SKIP_GIT_INFO} ]]; then
170170
local commit
171171

172-
commit=$(git -C "${GENTOO}/${path}" log --pretty=oneline -1 -- . | cut -f1 -d' ')
172+
commit=$(git -C "${GENTOO}" log --pretty=oneline -1 -- "${path}" | cut -f1 -d' ')
173173
commit_extra+=( --message "It's from Gentoo commit ${commit}." )
174174
unset commit
175175
fi

pkg_auto/occurences.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
##
4+
## Print all the places in the scripts repository where the given
5+
## package is mentioned. It's sort of like grep, but a bit smarter and
6+
## with a slightly better output.
7+
##
8+
## Parameters:
9+
## -h: this help
10+
##
11+
## Positional:
12+
## 1: scripts repo
13+
## 2: package name
14+
##
15+
16+
set -euo pipefail
17+
18+
source "$(dirname "${BASH_SOURCE[0]}")/impl/pkg_auto_lib.sh"
19+
20+
while [[ ${#} -gt 0 ]]; do
21+
case ${1} in
22+
-h)
23+
print_help
24+
exit 0
25+
;;
26+
--)
27+
shift
28+
break
29+
;;
30+
-*)
31+
fail "unknown flag '${1}'"
32+
;;
33+
*)
34+
break
35+
;;
36+
esac
37+
done
38+
39+
if [[ ${#} -ne 2 ]]; then
40+
fail 'Expected two positional parameters: a path to scripts repository and a package name'
41+
fi
42+
43+
generate_mention_report_for_package "${1}" "${2}"

0 commit comments

Comments
 (0)