zrhoffman commented on a change in pull request #5004:
URL: https://github.com/apache/trafficcontrol/pull/5004#discussion_r536333574



##########
File path: pkg
##########
@@ -156,12 +175,28 @@ while (( "$#" )); do
                if (( "$verbose" == 0 )); then
                        exec >/dev/null 2>&1
                fi
+
+               # Build the project
                if [[ $build_images -eq 1 ]]; then
                        "${COMPOSECMD[@]}" -f $COMPOSE_FILE build $1 || exit 1
                else
                        "${COMPOSECMD[@]}" -f $COMPOSE_FILE pull $1 || exit 1
                fi
                "${COMPOSECMD[@]}" -f $COMPOSE_FILE run "${RUN_OPTIONS[@]}" 
--rm $1 || exit 1
+
+               # Check for a chained compose file for this particular project.
+               # A chained compose file will be named exactly the same as main 
docker-compose, with .service added,
+               # where <service> is the name of the specific service to be 
chained. The file may be a symlink to another
+               # compose file, in which case the symlink will be followed 
before it is processed.
+               # A "dist" symlink will be temporarily created in that 
directory to facilitate the collation of artefacts.
+               if [ -e "$COMPOSE_FILE.$1" ] ; then
+                       ln -sf "$(dirname -- "$(realpath -e -- "$SELF")")/dist" 
"$(dirname -- "$(realpath -e -- "$COMPOSE_FILE.$1")")/dist" || exit 1
+                       $SELF -f $(realpath -e "$COMPOSE_FILE.$1") $([ 
"$verbose" == 0 ] || echo "-v") $([ "$quiet" == 0 ] || echo "-q") $([ "$debug" 
== 0 ] || echo "-d") $([ "$build" == 0 ] || echo "-b") $("${COMPOSECMD[@]}" -f 
$(realpath -e "$COMPOSE_FILE.$1") config --services) || exit 1
+                       rm "$(dirname -- "$(realpath -e -- 
"$COMPOSE_FILE.$1")")/dist"
+               fi
+
+               # Update the ownership of the artefacts to match the main repo.
+               chown -R "$(stat -c '%u:%g' .)" dist

Review comment:
       This line causes the build to "fail" (even though the RPMs are 
successfully built) when `pkg` is not run using `sudo`:
   
   ```
   Requires(rpmlib): rpmlib(FileDigests) <= 4.6.0-1 
rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
   Checking for unpackaged file(s): /usr/lib/rpm/check-files 
/rpmbuilddir/BUILDROOT/trafficserver-8.0.8-11.3a53261.el7.x86_64
   Wrote: /rpmbuilddir/RPMS/x86_64/trafficserver-8.0.8-11.3a53261.el7.x86_64.rpm
   Wrote: 
/rpmbuilddir/RPMS/x86_64/trafficserver-debuginfo-8.0.8-11.3a53261.el7.x86_64.rpm
   Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.lnPh60
   + umask 022
   + cd /rpmbuilddir/BUILD
   + cd trafficserver-8.0.8
   + rm -rf /rpmbuilddir/BUILDROOT/trafficserver-8.0.8-11.3a53261.el7.x86_64
   + exit 0
   chown: changing ownership of 
'dist/trafficserver-debuginfo-8.0.8-11.3a53261.el7.x86_64.rpm': Operation not 
permitted
   chown: changing ownership of 'dist/build.log': Operation not permitted
   chown: changing ownership of 
'dist/trafficserver-8.0.8-11.3a53261.el7.x86_64.rpm': Operation not permitted
   Failed to build ats_build.
   Results in 'dist':
   total 58376
   -rw-r--r-- 1 root      root        849202 Dec  4 12:22 build.log
   -rw-r--r-- 1 root      root      51845204 Dec  4 12:22 
trafficserver-debuginfo-8.0.8-11.3a53261.el7.x86_64.rpm
   -rw-r--r-- 1 root      root       7066360 Dec  4 12:22 
trafficserver-8.0.8-11.3a53261.el7.x86_64.rpm
   lrwxrwxrwx 1 zhoffm468 zhoffm468       60 Dec  4 12:13 dist -> 
/home/zhoffm468/go/src/github.com/apache/trafficcontrol/dist
   Failed to build ats.
   Results in 'dist':
   total 58376
   -rw-r--r-- 1 root      root        849202 Dec  4 12:22 build.log
   -rw-r--r-- 1 root      root      51845204 Dec  4 12:22 
trafficserver-debuginfo-8.0.8-11.3a53261.el7.x86_64.rpm
   -rw-r--r-- 1 root      root       7066360 Dec  4 12:22 
trafficserver-8.0.8-11.3a53261.el7.x86_64.rpm
   lrwxrwxrwx 1 zhoffm468 zhoffm468       60 Dec  4 12:13 dist -> 
/home/zhoffm468/go/src/github.com/apache/trafficcontrol/dist
   ```
   
   All of our Docker builders use `clean_build.sh`, which set artifact 
ownership on exist:
   
   
https://github.com/apache/trafficcontrol/blob/ac0b3917a76fc9963599d8c72ca414e9fbaf9732/build/clean_build.sh#L22-L26
   
   Ownership should be set within Docker so that root privileges is not a 
requirement for running `pkg`.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to