@@ -57,6 +57,7 @@ def _parse_release_info(release_info):
57
57
58
58
return os_name , os_version
59
59
60
+ DEBUGINFO_TYPE_DEFAULT = "default"
60
61
DEBUGINFO_TYPE_NONE = "none"
61
62
DEBUGINFO_TYPE_CENTOS = "centos"
62
63
DEBUGINFO_TYPE_FEDORA = "fedora"
@@ -67,11 +68,25 @@ DEBUGINFO_TYPE_BY_OS_RELEASE = {
67
68
"fedora" : DEBUGINFO_TYPE_FEDORA ,
68
69
}
69
70
71
+ DEBUGINFO_VALID_VALUES = [
72
+ DEBUGINFO_TYPE_FEDORA ,
73
+ DEBUGINFO_TYPE_CENTOS ,
74
+ DEBUGINFO_TYPE_NONE ,
75
+ DEBUGINFO_TYPE_DEFAULT ,
76
+ ]
77
+
70
78
def _build_repo_for_rpmbuild_toolchain_impl (rctx ):
71
- debuginfo_type = DEBUGINFO_TYPE_NONE
72
- if rctx .path (RELEASE_PATH ).exists :
73
- os_name , _ = _parse_release_info (rctx .read (RELEASE_PATH ))
74
- debuginfo_type = DEBUGINFO_TYPE_BY_OS_RELEASE .get (os_name , debuginfo_type )
79
+ if rctx .attr .debuginfo_type not in DEBUGINFO_VALID_VALUES :
80
+ fail ("debuginfo_type must be one of" , DEBUGINFO_VALID_VALUES )
81
+
82
+ debuginfo_type = rctx .attr .debuginfo_type
83
+ if debuginfo_type == DEBUGINFO_TYPE_DEFAULT :
84
+ rctx .watch (RELEASE_PATH )
85
+ if rctx .path (RELEASE_PATH ).exists :
86
+ os_name , _ = _parse_release_info (rctx .read (RELEASE_PATH ))
87
+ debuginfo_type = DEBUGINFO_TYPE_BY_OS_RELEASE .get (os_name , debuginfo_type )
88
+ else :
89
+ debuginfo_type = DEBUGINFO_TYPE_NONE
75
90
76
91
rpmbuild_path = rctx .which ("rpmbuild" )
77
92
if rctx .attr .verbose :
@@ -80,9 +95,6 @@ def _build_repo_for_rpmbuild_toolchain_impl(rctx):
80
95
else :
81
96
print ("No system rpmbuild found." ) # buildifier: disable=print
82
97
83
- if rctx .attr .debuginfo_type not in ["centos7" , "fedora40" , "none" ]:
84
- fail ("debuginfo_type must be one of centos7, fedora40, or none" )
85
-
86
98
version = "unknown"
87
99
if rpmbuild_path :
88
100
res = rctx .execute ([rpmbuild_path , "--version" ])
@@ -112,9 +124,9 @@ build_repo_for_rpmbuild_toolchain = repository_rule(
112
124
doc = """
113
125
The underlying debuginfo configuration for the system rpmbuild.
114
126
115
- One of `centos`, `fedora`, and `none`
127
+ One of `centos`, `fedora`, `none`, and `default` (which looks up `/etc/os-release`)
116
128
""" ,
117
- default = "none" ,
129
+ default = DEBUGINFO_TYPE_DEFAULT ,
118
130
),
119
131
},
120
132
)
0 commit comments