Репозитории ALT
S: | 3.2.2-alt4 |
D: | 2.2.2-alt1 |
5.1: | 2.2.4-alt4.M50P.1 |
4.1: | 2.2.0-alt3 |
4.0: | 2.2.0-alt2 |
3.0: | 1.0.10-alt1 |
Группа :: Разработка/Прочее
Пакет: fpc
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: fpc-honor_SOURCE_DATE_EPOCH_in_date.patch
Скачать
Скачать
Description: Reproducible builds requires that the build time stamp is not
recorded in binaries. In FPC they are fuild in via the $INCLUDE %DATE%
directive which calls getdatestr in globals.pas. To allow reproducible builds
we should honor the SOURCE_DATE_EPOCH environment variable. To not depend on
the dateutil unit, we include the required code from that package here.
Author: Paul Gevers <elbrus@debian.org>
Author: Abou Al Montacir <abou.almontacir@sfr.fr>
Index: fpc/fpcsrc/compiler/globals.pas
===================================================================
--- fpc.orig/fpcsrc/compiler/globals.pas
+++ fpc/fpcsrc/compiler/globals.pas
@@ -510,6 +510,7 @@ interface
starttime : real;
function getdatestr:string;
+ Function UnixToDateTime(const AValue: Int64): TDateTime;
function gettimestr:string;
function filetimestring( t : longint) : string;
function getrealtime : real;
@@ -766,11 +767,29 @@ implementation
}
var
Year,Month,Day: Word;
+ SourceDateEpoch: string;
begin
- DecodeDate(Date,year,month,day);
+ SourceDateEpoch := GetEnvironmentVariable('SOURCE_DATE_EPOCH');
+ if Length(SourceDateEpoch)>0 then
+ DecodeDate(UnixToDateTime(StrToInt64(SourceDateEpoch)),year,month,day)
+ else
+ DecodeDate(Date,year,month,day);
getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
end;
+ Function UnixToDateTime(const AValue: Int64): TDateTime;
+ { Code copied from fpcsrc/packages/rtl-objpas/src/inc/dateutil.inc and
+ fpcsrc/rtl/objpas/sysutils/datih.inc }
+ const
+ TDateTimeEpsilon = 2.2204460493e-16 ;
+ UnixEpoch = TDateTime(-2415018.5) + TDateTime(2440587.5) ;
+ begin
+ Result:=UnixEpoch + AValue/SecsPerDay;
+ if (UnixEpoch>=0) and (Result<-TDateTimeEpsilon) then
+ Result:=int(Result-1.0+TDateTimeEpsilon)-frac(1.0+frac(Result))
+ else if (UnixEpoch<=-1.0) and (Result>-1.0+TDateTimeEpsilon) then
+ Result:=int(Result+1.0-TDateTimeEpsilon)+frac(1.0-abs(frac(1.0+Result)));
+ end;
function filetimestring( t : longint) : string;
{