@@ -297,13 +297,15 @@ static int doSetupMacro(rpmSpec spec, const char *line)
297297 }
298298
299299 if (dirName ) {
300- spec -> buildSubdir = xstrdup ( dirName );
300+ rpmPushMacro ( spec -> macros , "buildsubdir" , NULL , dirName , RMIL_SPEC );
301301 } else {
302- rasprintf (& spec -> buildSubdir , "%s-%s" ,
302+ char * buildSubdir = NULL ;
303+ rasprintf (& buildSubdir , "%s-%s" ,
303304 headerGetString (spec -> packages -> header , RPMTAG_NAME ),
304305 headerGetString (spec -> packages -> header , RPMTAG_VERSION ));
306+ rpmPushMacro (spec -> macros , "buildsubdir" , NULL , buildSubdir , RMIL_SPEC );
307+ free (buildSubdir );
305308 }
306- rpmPushMacroFlags (spec -> macros , "buildsubdir" , NULL , spec -> buildSubdir , RMIL_SPEC , RPMMACRO_LITERAL );
307309
308310 /* cd to the build dir */
309311 { char * buildDir = rpmGenPath (spec -> rootDir , "%{_builddir}" , "" );
@@ -316,7 +318,7 @@ static int doSetupMacro(rpmSpec spec, const char *line)
316318
317319 /* delete any old sources */
318320 if (!leaveDirs ) {
319- rasprintf ( & buf , "rm -rf '%s '" , spec -> buildSubdir );
321+ buf = rpmExpand ( "rm -rf '%{buildsubdir} '" , NULL );
320322 appendLineStringBuf (spec -> prep , buf );
321323 free (buf );
322324 }
@@ -325,8 +327,8 @@ static int doSetupMacro(rpmSpec spec, const char *line)
325327
326328 /* if necessary, create and cd into the proper dir */
327329 if (createDir ) {
328- buf = rpmExpand ("%{__mkdir_p} " , spec -> buildSubdir , " \n" ,
329- "cd '" , spec -> buildSubdir , " '" , NULL );
330+ buf = rpmExpand ("%{__mkdir_p} '%{buildsubdir}' \n" ,
331+ "cd '%{buildsubdir} '" , NULL );
330332 appendLineStringBuf (spec -> prep , buf );
331333 free (buf );
332334 }
@@ -341,7 +343,7 @@ static int doSetupMacro(rpmSpec spec, const char *line)
341343 }
342344
343345 if (!createDir ) {
344- rasprintf ( & buf , "cd '%s '" , spec -> buildSubdir );
346+ buf = rpmExpand ( "cd '%{buildsubdir} '" , NULL );
345347 appendLineStringBuf (spec -> prep , buf );
346348 free (buf );
347349 }
0 commit comments