[pacman-dev] [PATCH] set .SRCINFO time stamp to PKGBUILD modification
As the .SRCINFO is mandatory for a git push to AUR, it is tempting to automate its generation, for example in a git hook. This also saves the developer from accidentally uploading a change to the PKGBUILD without it being properly reflected in the .SRCINFO. But when only files other than the PKGBUILD were changed, or a change to the PKGBUILD did not affect the contents of the .SRCINFO, the time stamp still changes on each run of mksrcinfo, introducing an unnecessary and possibly misleading change to the otherwise unaltered .SRCINFO file. This especially impairs the use of commands examining the history, like "git log .SRCINFO". Using the last modification time of the PKGBUILD in place of the date the .SRCINFO was generated alleviates at least part of this problem. --- More than a ready proposal for a change, this patch is an inquiry about the reason for the time stamp. As noted above, I find it quite impractical while maintaining packages in the AUR. Above that, the information seems redundant, as all package repositories are versioned with git, where each commit already carries a date, usually only a few seconds behind the time stamp. I originally posted this issue to the pkgbuild-introspection project [1], but as pacman sets the standard for the .SRCINFO format, this mailing list is the more appropriate place for it. I am aware that git attributes and filters could be used to modify or delete the timestamp, but am reluctant to deviate from the norm be it only for a mere comment, as long a I do not know its purpose. Why is the time stamp there? Would it be sensible to switch it out for the PKGBUILD modification date? Could it even be removed? [1]: https://github.com/falconindy/pkgbuild-introspection/issues/32 scripts/makepkg.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 80b95f4..00e532b 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1084,7 +1084,7 @@ write_srcinfo() { local pkg printf "# Generated by makepkg %s\n" "$makepkg_version" - printf "# %s\n" "$(LC_ALL=C date -u)" + printf "# %s\n" "$(LC_ALL=C date -ud @$(stat -c %Y "$BUILDFILE"))" srcinfo_write_global -- 2.7.1
On Thu, Feb 18, 2016 at 07:56:55PM +0100, Dominik Fischer wrote:
As the .SRCINFO is mandatory for a git push to AUR, it is tempting to automate its generation, for example in a git hook. This also saves the developer from accidentally uploading a change to the PKGBUILD without it being properly reflected in the .SRCINFO.
But when only files other than the PKGBUILD were changed, or a change to the PKGBUILD did not affect the contents of the .SRCINFO, the time stamp still changes on each run of mksrcinfo, introducing an unnecessary and possibly misleading change to the otherwise unaltered .SRCINFO file. This especially impairs the use of commands examining the history, like "git log .SRCINFO".
Using the last modification time of the PKGBUILD in place of the date the .SRCINFO was generated alleviates at least part of this problem.
As you point out, this method has its downfalls (and would stress the downfalls you point out, because they're lousy). I ended up adding this to mksrcinfo in a different way: https://github.com/falconindy/pkgbuild-introspection/commit/f7f812bdea339a1
---
More than a ready proposal for a change, this patch is an inquiry about the reason for the time stamp. As noted above, I find it quite impractical while maintaining packages in the AUR. Above that, the information seems redundant, as all package repositories are versioned with git, where each commit already carries a date, usually only a few seconds behind the time stamp.
I originally posted this issue to the pkgbuild-introspection project [1], but as pacman sets the standard for the .SRCINFO format, this mailing list is the more appropriate place for it.
I am aware that git attributes and filters could be used to modify or delete the timestamp, but am reluctant to deviate from the norm be it only for a mere comment, as long a I do not know its purpose. Why is the time stamp there? Would it be sensible to switch it out for the PKGBUILD modification date? Could it even be removed?
[1]: https://github.com/falconindy/pkgbuild-introspection/issues/32
scripts/makepkg.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 80b95f4..00e532b 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1084,7 +1084,7 @@ write_srcinfo() { local pkg printf "# Generated by makepkg %s\n" "$makepkg_version" - printf "# %s\n" "$(LC_ALL=C date -u)" + printf "# %s\n" "$(LC_ALL=C date -ud @$(stat -c %Y "$BUILDFILE"))" srcinfo_write_global -- 2.7.1
On 19/02/16 04:56, Dominik Fischer wrote:
More than a ready proposal for a change, this patch is an inquiry about the reason for the time stamp. As noted above, I find it quite impractical while maintaining packages in the AUR. Above that, the information seems redundant, as all package repositories are versioned with git, where each commit already carries a date, usually only a few seconds behind the time stamp.
The .SRCINFO file is timestamped so we know the time that the source package is generated (much like the .PKGINFO file for packages). For those that distribute source packages, this is useful information. I will take a patch that only prints the comments when generating the .SRCINFO file and not when --printsrcinfo is used. A
This avoids introducing unnecessary changes to the time stamp into package repositories that regularly use --printsrcinfo to update the .SRCINFO file. --- I did not know that despite git-based AUR 4 source packages are still in active use. There, time stamps make some sense indeed. The mksrcinfo solution is quite similar to the workaround I implemented for my package repositories: When only the time stamp changed, keep the old .SRCINFO without modification. But omitting the comments in .SRCINFOs not intended for source packages gets us rid of this consideration altogether and thus seems like the most KISS solution to me, so I implemented a patch. scripts/makepkg.sh.in | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 80b95f4..a587af3 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1080,11 +1080,13 @@ srcinfo_write_package() { srcinfo_close_section } -write_srcinfo() { - local pkg - +write_srcinfo_header() { printf "# Generated by makepkg %s\n" "$makepkg_version" printf "# %s\n" "$(LC_ALL=C date -u)" +} + +write_srcinfo_content() { + local pkg srcinfo_write_global @@ -1093,6 +1095,11 @@ write_srcinfo() { done } +write_srcinfo() { + write_srcinfo_header + write_srcinfo_content +} + write_pkginfo() { local builddate=$(date -u "+%s") if [[ -n $PACKAGER ]]; then @@ -2089,7 +2096,7 @@ if (( PACKAGELIST )); then fi if (( PRINTSRCINFO )); then - write_srcinfo + write_srcinfo_content exit 0 fi -- 2.7.1
On 20/02/16 00:18, Dominik Fischer wrote:
I did not know that despite git-based AUR 4 source packages are still in active use. There, time stamps make some sense indeed.
FYI: ABS will be replace by source package repos at some stage. Also, not every distribution using pacman is Arch. Patch queued for 5.0.1.
On 20/02/16 14:08, Allan McRae wrote:
On 20/02/16 00:18, Dominik Fischer wrote:
I did not know that despite git-based AUR 4 source packages are still in active use. There, time stamps make some sense indeed.
FYI: ABS will be replace by source package repos at some stage. Also, not every distribution using pacman is Arch.
Patch queued for 5.0.1.
On second thoughts... provide an actual git patch and not a hand-crafted one that does not apply. A
This avoids introducing unnecessary changes to the time stamp into package repositories that regularly use --printsrcinfo to update the .SRCINFO file. --- Crafted by git-format-patch, but destroyed by MTU afterwards. I hope this will now come through clean. scripts/makepkg.sh.in | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 80b95f4..a587af3 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1080,11 +1080,13 @@ srcinfo_write_package() { srcinfo_close_section } -write_srcinfo() { - local pkg - +write_srcinfo_header() { printf "# Generated by makepkg %s\n" "$makepkg_version" printf "# %s\n" "$(LC_ALL=C date -u)" +} + +write_srcinfo_content() { + local pkg srcinfo_write_global @@ -1093,6 +1095,11 @@ write_srcinfo() { done } +write_srcinfo() { + write_srcinfo_header + write_srcinfo_content +} + write_pkginfo() { local builddate=$(date -u "+%s") if [[ -n $PACKAGER ]]; then @@ -2089,7 +2096,7 @@ if (( PACKAGELIST )); then fi if (( PRINTSRCINFO )); then - write_srcinfo + write_srcinfo_content exit 0 fi -- 2.7.1
On 21/02/16 03:35, Dominik Fischer wrote:
This avoids introducing unnecessary changes to the time stamp into package repositories that regularly use --printsrcinfo to update the .SRCINFO file. ---
Crafted by git-format-patch, but destroyed by MTU afterwards. I hope this will now come through clean.
Thanks!
participants (3)
-
Allan McRae
-
Dave Reisner
-
Dominik Fischer