@@ -85,21 +85,28 @@ def load_whence():
85
85
def load_config ():
86
86
with open ("config.txt" , encoding = "utf-8" ) as file :
87
87
pattern_empty = re .compile ("^#|^$" )
88
- pattern_data = re .compile ("Install: ([^ \t ]+)[ \t ]+([^ \t ]+)[ \t ]+([^ \t ]+)\n " )
88
+ pattern_install = re .compile ("Install: ([^ \t ]+)[ \t ]+([^ \t ]+)[ \t ]+([^ \t ]+)\n " )
89
+ pattern_link = re .compile ("Link: ([^ \t ]+)[ \t ]+([^ \t ]+)\n " )
89
90
90
91
for (lineno , line ) in enumerate (file , start = 1 ):
91
92
if pattern_empty .match (line ):
92
93
continue
93
- match = pattern_data .match (line )
94
+
95
+ match = pattern_install .match (line )
96
+ if match :
97
+ yield ("install" , lineno , * match .groups ())
98
+ continue
99
+
100
+ match = pattern_link .match (line )
94
101
if match :
95
- yield (lineno , match . group ( 1 ), match .group ( 2 ), match . group ( 3 ))
102
+ yield ("link" , lineno , * match .groups ( ))
96
103
continue
97
104
98
105
raise Exception ("config.txt: %d: failed to parse '%s'" % (lineno , line [:- 1 ]))
99
106
100
107
DSPS = [ "adsp" , "cdsp" , "sdsp" , "cdsp1" , "gdsp0" , "gdsp1" ]
101
108
102
- def check_config (data , dirs ):
109
+ def check_install_config (data , dirs ):
103
110
(lineno , path , dsp , subdir ) = data
104
111
ret = True
105
112
@@ -122,6 +129,40 @@ def check_config(data, dirs):
122
129
123
130
return ret
124
131
132
+ def check_link_config (data ):
133
+ (lineno , src_path , dst_path ) = data
134
+ ret = True
135
+
136
+ if src_path .endswith ("/" ):
137
+ sys .stderr .write ("config.txt: %d: trailing '/' in %s\n " % (lineno , src_path ))
138
+ ret = False
139
+
140
+ if dst_path .endswith ("/" ):
141
+ sys .stderr .write ("config.txt: %d: trailing '/' in %s\n " % (lineno , dst_path ))
142
+ ret = False
143
+
144
+ dsp_path = os .path .dirname (src_path )
145
+ sourcedir = os .path .dirname (dsp_path )
146
+ if not os .path .exists (sourcedir ):
147
+ sys .stderr .write ("config.txt: %d: dir %s doesn't exist\n " % (lineno , sourcedir ))
148
+ ret = False
149
+
150
+ if os .path .basename (dsp_path ) != "dsp" :
151
+ sys .stderr .write ("config.txt: %d: DSP type not under 'dsp' dir %s\n " % (lineno , src_path ))
152
+ ret = False
153
+
154
+ return ret
155
+
156
+ def check_config (data , dirs ):
157
+ ret = True
158
+
159
+ if data [0 ] == "install" :
160
+ ret = check_install_config (data [1 :], dirs )
161
+ elif data [0 ] == "link" :
162
+ ret = check_link_config (data [1 :])
163
+
164
+ return ret
165
+
125
166
def list_git ():
126
167
if not os .path .exists (".git" ):
127
168
sys .stderr .write ("Skipping git ls-files check, no .git dir" )
0 commit comments