@@ -2274,15 +2274,16 @@ def get_distro_version(self):
2274
2274
res = self .get_distro_details ()
2275
2275
return res .get ('VERSION_ID' )[0 ].strip ("\" " )
2276
2276
2277
- def get_distro_src (self , package , dest_path , build_option = None ):
2277
+ def get_distro_src (self , package , dest_path , build_option = None , pack_dir = None ):
2278
2278
2279
2279
'''
2280
2280
Downloads the source package and prepares it in the given dest_path
2281
2281
to be ready to build.
2282
2282
2283
2283
:param package: name of the package
2284
2284
:param dest_path: destination_path
2285
- :param build_option : rpmbuild option
2285
+ :param build_option : rpmbuild option
2286
+ :param pack_dir: final pakage dir in case of sles
2286
2287
:return path: build directory
2287
2288
'''
2288
2289
if dest_path is None :
@@ -2314,21 +2315,22 @@ def get_distro_src(self, package, dest_path, build_option=None):
2314
2315
return ""
2315
2316
2316
2317
elif self .distro_name () == 'sles' :
2317
- host .host_run_command ("zypper install rpm-build -y " )
2318
- s_cmd = f"zypper -n source-install { package } "
2318
+ host .host_run_command ("zypper install -y rpm-build " )
2319
+ s_cmd = f"zypper -n source-install { package } ;cd /usr/src/packages/SOURCES/;./mkspec;cp { package } .spec ../SPECS/ "
2319
2320
if host .host_run_command (s_cmd ):
2321
+
2320
2322
spec_path = f"/usr/src/packages/SPECS/{ package } .spec"
2321
2323
else :
2322
2324
spec_path = None
2323
2325
if spec_path :
2324
- return self .prepare_source (spec_path ,host , dest_path , package , build_option )
2326
+ return self .prepare_source (spec_path ,host , dest_path , package , build_option , 'sles' , pack_dir )
2325
2327
else :
2326
2328
log .error ("Failed to install distro package" )
2327
2329
else :
2328
2330
return ""
2329
2331
2330
2332
2331
- def prepare_source (self ,spec_file , host , dest_path , package , build_option = None ):
2333
+ def prepare_source (self ,spec_file , host , dest_path , package , build_option = None , distro = None , pack_dir = None ):
2332
2334
"""
2333
2335
Rpmbuild the spec path and return build dir
2334
2336
@@ -2344,7 +2346,10 @@ def prepare_source(self,spec_file, host, dest_path, package, build_option=None):
2344
2346
build_option += f" --define '_builddir { dest_path } '"
2345
2347
try :
2346
2348
host .host_run_command (f"rpmbuild { build_option } { spec_file } " )
2347
- return host .host_run_command (f"ls -d -- { dest_path } /* | grep { package } " )[0 ]
2349
+ dir_name = host .host_run_command (f"ls -d -- { dest_path } /* | grep { package } " )[0 ]
2350
+ if distro is not None :
2351
+ dir_name = host .host_run_command (f"ls -d -- { dir_name } /* | grep linux" )[0 ]
2352
+ return dir_name
2348
2353
except OpTestError :
2349
2354
return ""
2350
2355
0 commit comments