dmnks left a comment (rpm-software-management/rpm#3682)

Digging a bit deeper and discussing with @pmatilai, turns out the root cause is 
that the `rmbuild` scriptlet is running despite there not being a `%_builddir` 
(since it's a source RPM build which does not require one, that was also what 
the aforementioned commit fixes).

And indeed, in `tools/rpmbuild.c`:
```c
  713     switch (bigMode) {                                                    
                                                                                
                                                                                
                
  714     case MODE_REBUILD:    // <----- HERE                                  
                                                                                
                                                              
  715     case MODE_RECOMPILE:                                                  
                                                                                
                                                                                
                
  716         if (bigMode == MODE_REBUILD &&                                    
                                                                                
                                                                                
                
  717             buildChar != 'p' &&                                           
                                                                                
                                                                                
                
  718             buildChar != 'f' &&                                           
                                                                                
                                                                                
                
  719             buildChar != 'c' &&                                           
                                                                                
                                                                                
                
  720             buildChar != 'i' &&                                           
                                                                                
                                                                                
                
  721             buildChar != 'l') {                                           
                                                                                
                                                                                
                
  722             ba->buildAmount |= RPMBUILD_RMSOURCE;                         
                                                                                
                                                                                
                
  723             ba->buildAmount |= RPMBUILD_RMSPEC;                           
                                                                                
                                                                                
                
  724             ba->buildAmount |= RPMBUILD_RMBUILD;    // <----- HERE        
                                                                                
                                                                                
                        
  725         }                                           
```

So when running `rpmbuild -rs` (as in "rebuild source"), the above code path 
gets executed and the `RPMBUILD_RMBUILD` is flag is set, causing the `rmbuild` 
stage to run:

```c
  216     if (what == RPMBUILD_RMBUILD) {                                       
                                                                                
                                                                                
                
  217         char *fix = rpmExpand("%{_fixperms}", NULL);                      
                                                                                
                                                                                
                
  218         fprintf(fp, "test -d '%s' && %s '%s'\n",                          
                                                                                
                                                                                
                
  219                         spec->buildDir, fix, spec->buildDir);             
                                                                                
                                                                                
                
  220         fprintf(fp, "rm -rf '%s'\n", spec->buildDir);                     
                                                                                
                                                                                
                
  221         free(fix);                                                        
                                                                                
                                                                                
                
  222     } else if (sb != NULL)                                                
                                                                                
                                                                                
                
```

Reassigning to @pmatilai now as he's more familiar with the surrounding code & 
recent patches 😄 

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/3682#issuecomment-2754100283
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/issues/3682/2754100...@github.com>
_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
https://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to