@@ -1733,8 +1733,26 @@ generate_manifest() {
1733
1733
GENERATE_ARGS+=" --target $f "
1734
1734
done
1735
1735
fi
1736
- logcmd -p $PKGSEND generate $GENERATE_ARGS $DESTDIR > $outf \
1737
- || logerr " ------ Failed to generate manifest"
1736
+ # `pkgsend generate` will produce a manifest based on the files it
1737
+ # finds under $DESTDIR. It will set the ownership and group in generated
1738
+ # lines to root:bin, but will copy the mode attribute from the file it
1739
+ # finds. The modes of files in this directory do generally accurately
1740
+ # reflect executability, but other bits may be set depending on how the
1741
+ # temporary directory is set up. For example, in a shared build workspace
1742
+ # there could be extended ACLs to maintain writeability by the owning
1743
+ # group, or the sticky group attribute may be set on directories.
1744
+ # Rather than implicitly trusting the mode that is found, we normalise it
1745
+ # to something more generic.
1746
+ logcmd -p $PKGSEND generate $GENERATE_ARGS $DESTDIR | sed -E '
1747
+ # Strip off any special attributes such as setuid or sticky group
1748
+ s/\<mode=0[[:digit:]]+([[:digit:]]{3})\>/mode=0\1/
1749
+ # Reduce group/other permissions
1750
+ s/\<mode=0([75])[[:digit:]]{2}\>/mode=0\155/
1751
+ s/\<mode=0([64])[[:digit:]]{2}\>/mode=0\144/
1752
+ # Convert unexpected modes to something reasonable
1753
+ s/\<mode=02[[:digit:]]{2}\>/mode=0644/
1754
+ s/\<mode=0[13][[:digit:]]{2}\>/mode=0755/
1755
+ ' > $outf || logerr " ------ Failed to generate manifest"
1738
1756
}
1739
1757
1740
1758
convert_version () {
0 commit comments