mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 15:53:55 -04:00
multify: Respect SOURCE_DATE_EPOCH variable when used from command-line
That said, we should probably encourage the use of -T0 (which doesn't write out timestamps to begin with).
This commit is contained in:
parent
0b53355347
commit
3e1d98c105
@ -57,6 +57,7 @@ string dont_compress_str = "jpg,png,mp3,ogg";
|
|||||||
// Default text extensions. May be overridden with -X.
|
// Default text extensions. May be overridden with -X.
|
||||||
string text_ext_str = "txt";
|
string text_ext_str = "txt";
|
||||||
|
|
||||||
|
time_t source_date_epoch = (time_t)-1;
|
||||||
bool got_record_timestamp_flag = false;
|
bool got_record_timestamp_flag = false;
|
||||||
bool record_timestamp_flag = true;
|
bool record_timestamp_flag = true;
|
||||||
|
|
||||||
@ -430,6 +431,12 @@ add_files(const vector_string ¶ms) {
|
|||||||
needs_repack = true;
|
needs_repack = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (multifile->get_record_timestamp() && source_date_epoch != (time_t)-1) {
|
||||||
|
if (multifile->get_timestamp() > source_date_epoch) {
|
||||||
|
multifile->set_timestamp(source_date_epoch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (needs_repack) {
|
if (needs_repack) {
|
||||||
if (!multifile->repack()) {
|
if (!multifile->repack()) {
|
||||||
cerr << "Failed to write " << multifile_name << ".\n";
|
cerr << "Failed to write " << multifile_name << ".\n";
|
||||||
@ -533,6 +540,12 @@ kill_files(const vector_string ¶ms) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (multifile->get_record_timestamp() && source_date_epoch != (time_t)-1) {
|
||||||
|
if (multifile->get_timestamp() > source_date_epoch) {
|
||||||
|
multifile->set_timestamp(source_date_epoch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool okflag = true;
|
bool okflag = true;
|
||||||
|
|
||||||
if (multifile->needs_repack()) {
|
if (multifile->needs_repack()) {
|
||||||
@ -779,6 +792,11 @@ main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *source_date_epoch_str = getenv("SOURCE_DATE_EPOCH");
|
||||||
|
if (source_date_epoch_str != nullptr && source_date_epoch_str[0] != 0) {
|
||||||
|
source_date_epoch = (time_t)strtoll(source_date_epoch_str, nullptr, 10);
|
||||||
|
}
|
||||||
|
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
extern int optind;
|
extern int optind;
|
||||||
static const char *optflags = "crutxkvz123456789Z:T:X:S:f:OC:ep:P:F:h";
|
static const char *optflags = "crutxkvz123456789Z:T:X:S:f:OC:ep:P:F:h";
|
||||||
|
@ -67,6 +67,17 @@ get_timestamp() const {
|
|||||||
return _timestamp;
|
return _timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the overall mudification timestamp of the multifile. Note that this
|
||||||
|
* will be reset to the current time every time you modify a subfile.
|
||||||
|
* Only set this if you know what you are doing!
|
||||||
|
*/
|
||||||
|
INLINE void Multifile::
|
||||||
|
set_timestamp(time_t timestamp) {
|
||||||
|
_timestamp = timestamp;
|
||||||
|
_timestamp_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the flag indicating whether timestamps should be recorded within the
|
* Sets the flag indicating whether timestamps should be recorded within the
|
||||||
* Multifile or not. The default is true, indicating the Multifile will
|
* Multifile or not. The default is true, indicating the Multifile will
|
||||||
|
@ -59,6 +59,7 @@ PUBLISHED:
|
|||||||
INLINE bool needs_repack() const;
|
INLINE bool needs_repack() const;
|
||||||
|
|
||||||
INLINE time_t get_timestamp() const;
|
INLINE time_t get_timestamp() const;
|
||||||
|
INLINE void set_timestamp(time_t timestamp);
|
||||||
|
|
||||||
INLINE void set_record_timestamp(bool record_timestamp);
|
INLINE void set_record_timestamp(bool record_timestamp);
|
||||||
INLINE bool get_record_timestamp() const;
|
INLINE bool get_record_timestamp() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user