Page MenuHomeFreeBSD

release/vm: only include Makefile.azure if used
AbandonedPublic

Authored by brooks on Wed, Mar 26, 6:58 PM.
Tags
None
Referenced Files
F113999980: D49527.diff
Sun, Apr 6, 5:54 PM
Unknown Object (File)
Sun, Apr 6, 2:46 AM
Unknown Object (File)
Sat, Apr 5, 9:15 AM
Unknown Object (File)
Sat, Apr 5, 9:15 AM
Unknown Object (File)
Sat, Apr 5, 9:15 AM
Unknown Object (File)
Sat, Apr 5, 9:15 AM
Unknown Object (File)
Sat, Apr 5, 9:15 AM
Unknown Object (File)
Wed, Apr 2, 8:39 AM
Subscribers

Details

Reviewers
emaste
lwhsu
Group Reviewers
releng
Summary

Makefile.azure depends on the non-portable date option -v so only
include it if asked.

Reported by: def
Sponsored by: DARPA, AFRL

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 63144
Build 60028: arc lint + arc unit

Event Timeline

release/Makefile.vm
286

Would replacing:

START_DATE!=  $(printf "%s-%s-%0.2d\n" "$(date -u +%Y)" "$(date -u +%m)" $(( $(date -u +%d) - 1 )))
EXPIRY_DATE!= $(printf "%s-%0.2d-%s\n" "$(date -u +%Y)" $(( $(date -u +%m) + 1 )) "$(date -u +%d)")

in Makefile.azure avoid this? It is horrible, but portable.

Would replacing:

START_DATE!=  $(printf "%s-%s-%0.2d\n" "$(date -u +%Y)" "$(date -u +%m)" $(( $(date -u +%d) - 1 )))
EXPIRY_DATE!= $(printf "%s-%0.2d-%s\n" "$(date -u +%Y)" $(( $(date -u +%m) + 1 )) "$(date -u +%d)")

in Makefile.azure avoid this? It is horrible, but portable.

Never mind, this would fail on certain dates.

Would replacing:

START_DATE!=  $(printf "%s-%s-%0.2d\n" "$(date -u +%Y)" "$(date -u +%m)" $(( $(date -u +%d) - 1 )))
EXPIRY_DATE!= $(printf "%s-%0.2d-%s\n" "$(date -u +%Y)" $(( $(date -u +%m) + 1 )) "$(date -u +%d)")

in Makefile.azure avoid this? It is horrible, but portable.

Never mind, this would fail on certain dates.

Yeah and whilst date -d 'today + 1 month' is supported by GNU date, it's slightly different when dealing with invalid dates, it'll add on the number of days in the current month rather than clamping to the end of the next month (e.g. -v+1m on 31st January is 28th February, but -d today + 1 month is 3rd March). Though perhaps +1m is a bit odd to be using here, maybe we do in fact want, say, +28d or +30d, as having VM images built in February expire sooner than those built in March could be surprising and confusing.

Would replacing:

START_DATE!=  $(printf "%s-%s-%0.2d\n" "$(date -u +%Y)" "$(date -u +%m)" $(( $(date -u +%d) - 1 )))
EXPIRY_DATE!= $(printf "%s-%0.2d-%s\n" "$(date -u +%Y)" $(( $(date -u +%m) + 1 )) "$(date -u +%d)")

in Makefile.azure avoid this? It is horrible, but portable.

Never mind, this would fail on certain dates.

Yeah and whilst date -d 'today + 1 month' is supported by GNU date, it's slightly different when dealing with invalid dates, it'll add on the number of days in the current month rather than clamping to the end of the next month (e.g. -v+1m on 31st January is 28th February, but -d today + 1 month is 3rd March). Though perhaps +1m is a bit odd to be using here, maybe we do in fact want, say, +28d or +30d, as having VM images built in February expire sooner than those built in March could be surprising and confusing.

Nice insight, as usual, thank you! So maybe (attempt #2):

GNU_DATE!=	date --help 2>/dev/null | grep GNU || true

.if ${GNU_DATE}
START_DATE!=	date -d '-1 days' -I -u
EXPIRY_DATE!=	date -d '+30 days' -I -u
.else
START_DATE!=	date -v-1d -I -u
EXPIRY_DATE!=	date -v+30d -I -u
.endif

Is not POSIX, but a little more portable?
Dates are hard for me, sorry!

As for dates, you could use the raw date (%s) and add 1 day or 30 days to that.

In D49527#1129188, @imp wrote:

As for dates, you could use the raw date (%s) and add 1 day or 30 days to that.

That is another option, although we'll have to change the value from epoch (raw date) to Y-m-d'T'H:M'Z' per the API (https://learn.microsoft.com/en-us/cli/azure/storage/blob?view=azure-cli-latest).

I think that part uses ${START_DATE} and ${EXPIRY_DATE} can be removed and switch to newer publishing method. Let me modify Makefile.azure

BTW, I still like only including file when it get used only. I would like to have this for all other files. There are many != usage which causes unnecessary forks.