JiaLiangC opened a new pull request, #1254:
URL: https://github.com/apache/bigtop/pull/1254

   <!--
     Thanks for sending a pull request!
       1. If this is your first time, please read our contributor guidelines: 
https://cwiki.apache.org/confluence/display/BIGTOP/How+to+Contribute
       2. Make sure your PR title starts with JIRA issue id, e.g., 
'BIGTOP-3638: Your PR title ...'.
   -->
   
   ### Description of PR
   While working on adding pkgSuffix and parent directory to BigTop DEBs, it 
became necessary to pass these two variables to the DEB rules file. Upon 
inspection, I found that the code logic for pkgSuffix and parent directory in 
RPMs shared similarities in several places and was repetitive. The DEB logic 
appeared similar too. Instead of following the previous practice that resulted 
in significant code duplication, I have refactored this part and conducted 
tests.
   
   Below are some comments regarding the modifications added.
   
   ```
   getPkgNameSuffix(component, type) {
       def originalSuffix = type.equalsIgnoreCase("deb") ? 
component.deb_pkg_suffix : component.rpm_pkg_suffix
       
   #In RPMs, the Suffix is in the form of a macro and cannot be an empty 
string, as it would result in a "macro empty body" 
   error. However, in DEB packaging, an empty string can be used.
   
       def defaultSuffix = type.equalsIgnoreCase("deb") ?  "" : "%{nil}"
       def pkgNameSuffix = project.hasProperty("pkgSuffix")? originalSuffix : 
defaultSuffix
       #The gradlePkgNameSuffix is solely used for concatenating package names, 
thus it must be empty if the originalSuffix does not exist.
       def gradlePkgNameSuffix = pkgNameSuffix == defaultSuffix ? "" : 
pkgNameSuffix
   
       return [pkgNameSuffix: pkgNameSuffix, gradlePkgNameSuffix: 
gradlePkgNameSuffix]
   }
   def getParentDir(bigtopBaseVersion, type) {
       #In RPMs, the Suffix is in the form of a macro and cannot be an empty 
string, as it would result in a "macro empty body" error. However, in DEB 
packaging, an empty string can be used.
       def defaultParentDirValue = type.equalsIgnoreCase("deb") ? "" : "%{nil}"
       def parentDir = project.hasProperty("parentDir") ? 
project.property('parentDir') : defaultParentDirValue
       if (parentDir && parentDir != "%{nil}") {
           parentDir = "${parentDir}/${bigtopBaseVersion}"
       }
       return parentDir
   
   ```
   
   ### How was this patch tested?
   manual test and smoke test
   test without suffix
   . /etc/profile.d/bigtop.sh;./gradlew zookeeper-clean zookeeper-pkg  
-PbuildThreads=2C repo 
   
![image](https://github.com/apache/bigtop/assets/18082602/d58db023-ac9c-44b8-bce4-9565b7fd8eda)
   
   smoke test
   ./docker-hadoop.sh -d -dcp -C config_rockylinux-8.yaml -F 
docker-compose-cgroupv2.yml -G -L -k zookeeper -s zookeeper -c 1
   
![image](https://github.com/apache/bigtop/assets/18082602/1795cf62-a825-4472-a29b-2f99594a7bf5)
   
   
   
   test with suffix 
   . /etc/profile.d/bigtop.sh;./gradlew zookeeper-clean zookeeper-pkg 
-PparentDir=/usr/bigtop -PpkgSuffix -PbuildThreads=2C repo 
   
![image](https://github.com/apache/bigtop/assets/18082602/34dc6750-2457-4288-9314-888715059bc6)
   
![image](https://github.com/apache/bigtop/assets/18082602/307e126c-04d2-4c17-8544-64fe0b39c64c)
   
   ### For code changes:
   
   - [ ] Does the title or this PR starts with the corresponding JIRA issue id 
(e.g. 'BIGTOP-3638. Your PR title ...')?
   - [ ] Make sure that newly added files do not have any licensing issues. 
When in doubt refer to https://www.apache.org/licenses/


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@bigtop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to