I wrote up an article 반면에 Maven을 사용하여 결정론적인면을 뒷받침합니다.
어셈블리 플러그인을 사용하여 다음과 같이 구성합니다 :
src/main/assembly/zip.xml
: 여기 두드러진 점 압축을 푼 끝에 여분의 CRLF를 기억 자신의 MANIFEST.MF
에 추가
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>deterministic</id>
<baseDirectory>/</baseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.build.directory}/classes</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>
를하거나 원 유효하지 않습니다.
src/main/resources/META-INF/MANIFEST.MF
:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: yourapp
Build-Jdk: 1.7.0
당신의 pom.xml에 몇 가지 플러그인을 추가
의 pom.xml :
<plugins>
... other plugins ...
<!-- Step 1: Set all timestamps to same value -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>1-touch-classes</id>
<phase>prepare-package</phase>
<configuration>
<target>
<touch datetime="01/01/2000 00:10:00 am">
<fileset dir="target/classes"/>
</touch>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Step 2: Assemble as a ZIP to avoid MANIFEST.MF timestamp -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/zip.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>2-make-assembly</id>
<phase>prepare-package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Step 3: Rename ZIP as JAR -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>3-rename-assembly</id>
<phase>package</phase>
<configuration>
<target>
<move file="${project.build.directory}/${project.build.finalName}-deterministic.zip"
tofile="${project.build.directory}/${project.build.finalName}-deterministic.jar"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
... more plugins ...
</plugins>
이이 결정 JAR를 만들 것입니다,하지만 여전히에 따라 달라집니다 JVM과 운영 체제의 정확한 버전. Bitcoin Core 프로젝트가 사용하는 you should explore the gitian approach을 극복하고 VirtualBox 환경 내의 특정 JVM을 위임합니다. 이 방식으로 여러 개발자가 소스에서 독립적으로 빌드 한 다음 바이너리에 서명하여 계약 내용을 설명 할 수 있습니다. 특정 임계 값에 도달하면 코드는 결정적으로 판명 된 것으로 간주되어 해제 될 수 있습니다.
나는 그것을 얻지 않는다. 그 파일은 빌드가 일어난 시간을 기록하는 것으로 보입니다. 따라서 실행 과정마다 다를 것입니다. 아마도이 기능을 억제하고 싶을 것입니다. 아마도이 기능은 아마도 Maven의 표준 부분 일 것입니다. – amalloy
에 덧붙여, 나는 행동의 보통 과정이 영원히 이진 결과를 보관하는 것이라고 생각한다.그것이 바로 당신의 표준적인 진리의 근원입니다. 예를 들어, 다른 JDK에서 동일한 소스 코드를 컴파일하면 다른 바이트 코드가 발생할 수 있습니다. 진정으로 결정 론적 인 빌드를 원한다면 전체 환경 (및 물리적 하드웨어!)을 "체크인"해야합니다. – Shepmaster
@amalloy : * "결정 론적 빌드"*는 보안 관점에서 볼 때 매우 중요합니다. 최근 많은 소프트웨어 및 하드웨어에 백도어에 대한 "빅 브라더 (big brother)"계시가 있었지만 점점 더 많은 프로젝트가 결정형 빌드를 채택하고 있습니다. 예를 들어 모질라 파이어 폭스 (Mozilla Firefox)는 이제 결정 론적 빌드를 향해 진보하고 있습니다. 다른 아키텍처/하드웨어 (잠재적으로 손상 될 수 있음)에서 컴파일을 수행 한 다음 결과를 비교하는 것을 허용하는 것은 매우 바람직한 기능입니다. 결정 성있는 빌드를 방지하는 "기능"은 심각한 보안 취약점입니다. – bitcoinNeverSleeps