├── .github └── workflows │ ├── release.yml │ └── test.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libs └── libncursesw.6.dylib ├── scripts ├── build-postgres-alpine.sh ├── build-postgres-debian.sh ├── repack-postgres.sh ├── test-postgres-alpine.sh ├── test-postgres-darwin.sh ├── test-postgres-linux.sh └── test-postgres-windows.sh ├── settings.gradle └── zonky.jpg /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | milestone: 4 | types: [closed] 5 | jobs: 6 | debian-arm32v7: 7 | name: Debian - arm32v7 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout code 11 | uses: actions/checkout@v3 12 | with: 13 | ref: master 14 | - name: Set up JDK 15 | uses: actions/setup-java@v3 16 | with: 17 | distribution: 'zulu' 18 | java-version: 15 19 | - name: Set environment variables 20 | env: 21 | MILESTONE_VERSION: ${{ github.event.milestone.title }} 22 | run: | 23 | echo "RELEASE_VERSION=$MILESTONE_VERSION" >> $GITHUB_ENV 24 | echo "POSTGRES_VERSION=${MILESTONE_VERSION%.*}" >> $GITHUB_ENV 25 | - name: Register QEMU 26 | run: docker run --rm --privileged multiarch/qemu-user-static:register --reset 27 | - name: Build Bundle 28 | run: ./gradlew :debian-platforms:buildArm32v7DebianBundle -Pversion=$RELEASE_VERSION -PpgVersion=$POSTGRES_VERSION 29 | - name: Upload bundle 30 | uses: actions/upload-artifact@v4 31 | with: 32 | name: arm32v7DebianBundle 33 | path: debian-platforms/build/tmp/buildArm32v7DebianBundle/bundle/postgres-linux-debian.txz 34 | debian-arm64v8: 35 | name: Debian - arm64v8 36 | runs-on: ubuntu-latest 37 | steps: 38 | - name: Checkout code 39 | uses: actions/checkout@v3 40 | with: 41 | ref: master 42 | - name: Set up JDK 43 | uses: actions/setup-java@v3 44 | with: 45 | distribution: 'zulu' 46 | java-version: 15 47 | - name: Set environment variables 48 | env: 49 | MILESTONE_VERSION: ${{ github.event.milestone.title }} 50 | run: | 51 | echo "RELEASE_VERSION=$MILESTONE_VERSION" >> $GITHUB_ENV 52 | echo "POSTGRES_VERSION=${MILESTONE_VERSION%.*}" >> $GITHUB_ENV 53 | - name: Register QEMU 54 | run: docker run --rm --privileged multiarch/qemu-user-static:register --reset 55 | - name: Build Bundle 56 | run: ./gradlew :debian-platforms:buildArm64v8DebianBundle -Pversion=$RELEASE_VERSION -PpgVersion=$POSTGRES_VERSION 57 | - name: Upload bundle 58 | uses: actions/upload-artifact@v4 59 | with: 60 | name: arm64v8DebianBundle 61 | path: debian-platforms/build/tmp/buildArm64v8DebianBundle/bundle/postgres-linux-debian.txz 62 | debian-ppc64le: 63 | name: Debian - ppc64le 64 | runs-on: ubuntu-latest 65 | steps: 66 | - name: Checkout code 67 | uses: actions/checkout@v3 68 | with: 69 | ref: master 70 | - name: Set up JDK 71 | uses: actions/setup-java@v3 72 | with: 73 | distribution: 'zulu' 74 | java-version: 15 75 | - name: Set environment variables 76 | env: 77 | MILESTONE_VERSION: ${{ github.event.milestone.title }} 78 | run: | 79 | echo "RELEASE_VERSION=$MILESTONE_VERSION" >> $GITHUB_ENV 80 | echo "POSTGRES_VERSION=${MILESTONE_VERSION%.*}" >> $GITHUB_ENV 81 | - name: Register QEMU 82 | run: docker run --rm --privileged multiarch/qemu-user-static:register --reset 83 | - name: Build Bundle 84 | run: ./gradlew :debian-platforms:buildPpc64leDebianBundle -Pversion=$RELEASE_VERSION -PpgVersion=$POSTGRES_VERSION 85 | - name: Upload bundle 86 | uses: actions/upload-artifact@v4 87 | with: 88 | name: ppc64leDebianBundle 89 | path: debian-platforms/build/tmp/buildPpc64leDebianBundle/bundle/postgres-linux-debian.txz 90 | alpine-arm32v6: 91 | name: Alpine - arm32v6 92 | runs-on: ubuntu-latest 93 | steps: 94 | - name: Checkout code 95 | uses: actions/checkout@v3 96 | with: 97 | ref: master 98 | - name: Set up JDK 99 | uses: actions/setup-java@v3 100 | with: 101 | distribution: 'zulu' 102 | java-version: 15 103 | - name: Set environment variables 104 | env: 105 | MILESTONE_VERSION: ${{ github.event.milestone.title }} 106 | run: | 107 | echo "RELEASE_VERSION=$MILESTONE_VERSION" >> $GITHUB_ENV 108 | echo "POSTGRES_VERSION=${MILESTONE_VERSION%.*}" >> $GITHUB_ENV 109 | - name: Register QEMU 110 | run: docker run --rm --privileged multiarch/qemu-user-static:register --reset 111 | - name: Build Bundle 112 | run: ./gradlew :alpine-platforms:buildArm32v6AlpineBundle -Pversion=$RELEASE_VERSION -PpgVersion=$POSTGRES_VERSION 113 | - name: Upload bundle 114 | uses: actions/upload-artifact@v4 115 | with: 116 | name: arm32v6AlpineBundle 117 | path: alpine-platforms/build/tmp/buildArm32v6AlpineBundle/bundle/postgres-linux-alpine_linux.txz 118 | alpine-arm64v8: 119 | name: Alpine - arm64v8 120 | runs-on: ubuntu-latest 121 | steps: 122 | - name: Checkout code 123 | uses: actions/checkout@v3 124 | with: 125 | ref: master 126 | - name: Set up JDK 127 | uses: actions/setup-java@v3 128 | with: 129 | distribution: 'zulu' 130 | java-version: 15 131 | - name: Set environment variables 132 | env: 133 | MILESTONE_VERSION: ${{ github.event.milestone.title }} 134 | run: | 135 | echo "RELEASE_VERSION=$MILESTONE_VERSION" >> $GITHUB_ENV 136 | echo "POSTGRES_VERSION=${MILESTONE_VERSION%.*}" >> $GITHUB_ENV 137 | - name: Register QEMU 138 | run: docker run --rm --privileged multiarch/qemu-user-static:register --reset 139 | - name: Build Bundle 140 | run: ./gradlew :alpine-platforms:buildArm64v8AlpineBundle -Pversion=$RELEASE_VERSION -PpgVersion=$POSTGRES_VERSION 141 | - name: Upload bundle 142 | uses: actions/upload-artifact@v4 143 | with: 144 | name: arm64v8AlpineBundle 145 | path: alpine-platforms/build/tmp/buildArm64v8AlpineBundle/bundle/postgres-linux-alpine_linux.txz 146 | alpine-ppc64le: 147 | name: Alpine - ppc64le 148 | runs-on: ubuntu-latest 149 | steps: 150 | - name: Checkout code 151 | uses: actions/checkout@v3 152 | with: 153 | ref: master 154 | - name: Set up JDK 155 | uses: actions/setup-java@v3 156 | with: 157 | distribution: 'zulu' 158 | java-version: 15 159 | - name: Set environment variables 160 | env: 161 | MILESTONE_VERSION: ${{ github.event.milestone.title }} 162 | run: | 163 | echo "RELEASE_VERSION=$MILESTONE_VERSION" >> $GITHUB_ENV 164 | echo "POSTGRES_VERSION=${MILESTONE_VERSION%.*}" >> $GITHUB_ENV 165 | - name: Register QEMU 166 | run: docker run --rm --privileged multiarch/qemu-user-static:register --reset 167 | - name: Build Bundle 168 | run: ./gradlew :alpine-platforms:buildPpc64leAlpineBundle -Pversion=$RELEASE_VERSION -PpgVersion=$POSTGRES_VERSION 169 | - name: Upload bundle 170 | uses: actions/upload-artifact@v4 171 | with: 172 | name: ppc64leAlpineBundle 173 | path: alpine-platforms/build/tmp/buildPpc64leAlpineBundle/bundle/postgres-linux-alpine_linux.txz 174 | alpine-lite-arm32v6: 175 | name: Alpine - arm32v6 (Lite) 176 | runs-on: ubuntu-latest 177 | if: ${{ startsWith(github.event.milestone.title, '10.') || startsWith(github.event.milestone.title, '11.') || startsWith(github.event.milestone.title, '12.') || startsWith(github.event.milestone.title, '13.') || startsWith(github.event.milestone.title, '14.') || startsWith(github.event.milestone.title, '15.') }} 178 | steps: 179 | - name: Checkout code 180 | uses: actions/checkout@v3 181 | with: 182 | ref: master 183 | - name: Set up JDK 184 | uses: actions/setup-java@v3 185 | with: 186 | distribution: 'zulu' 187 | java-version: 15 188 | - name: Set environment variables 189 | env: 190 | MILESTONE_VERSION: ${{ github.event.milestone.title }} 191 | run: | 192 | echo "RELEASE_VERSION=$MILESTONE_VERSION" >> $GITHUB_ENV 193 | echo "POSTGRES_VERSION=${MILESTONE_VERSION%.*}" >> $GITHUB_ENV 194 | - name: Register QEMU 195 | run: docker run --rm --privileged multiarch/qemu-user-static:register --reset 196 | - name: Build Bundle 197 | run: ./gradlew :alpine-lite-platforms:buildArm32v6AlpineLiteBundle -Pversion=$RELEASE_VERSION -PpgVersion=$POSTGRES_VERSION 198 | - name: Upload bundle 199 | uses: actions/upload-artifact@v4 200 | with: 201 | name: arm32v6AlpineLiteBundle 202 | path: alpine-lite-platforms/build/tmp/buildArm32v6AlpineLiteBundle/bundle/postgres-linux-alpine_linux.txz 203 | alpine-lite-arm64v8: 204 | name: Alpine - arm64v8 (Lite) 205 | runs-on: ubuntu-latest 206 | if: ${{ startsWith(github.event.milestone.title, '10.') || startsWith(github.event.milestone.title, '11.') || startsWith(github.event.milestone.title, '12.') || startsWith(github.event.milestone.title, '13.') || startsWith(github.event.milestone.title, '14.') || startsWith(github.event.milestone.title, '15.') }} 207 | steps: 208 | - name: Checkout code 209 | uses: actions/checkout@v3 210 | with: 211 | ref: master 212 | - name: Set up JDK 213 | uses: actions/setup-java@v3 214 | with: 215 | distribution: 'zulu' 216 | java-version: 15 217 | - name: Set environment variables 218 | env: 219 | MILESTONE_VERSION: ${{ github.event.milestone.title }} 220 | run: | 221 | echo "RELEASE_VERSION=$MILESTONE_VERSION" >> $GITHUB_ENV 222 | echo "POSTGRES_VERSION=${MILESTONE_VERSION%.*}" >> $GITHUB_ENV 223 | - name: Register QEMU 224 | run: docker run --rm --privileged multiarch/qemu-user-static:register --reset 225 | - name: Build Bundle 226 | run: ./gradlew :alpine-lite-platforms:buildArm64v8AlpineLiteBundle -Pversion=$RELEASE_VERSION -PpgVersion=$POSTGRES_VERSION 227 | - name: Upload bundle 228 | uses: actions/upload-artifact@v4 229 | with: 230 | name: arm64v8AlpineLiteBundle 231 | path: alpine-lite-platforms/build/tmp/buildArm64v8AlpineLiteBundle/bundle/postgres-linux-alpine_linux.txz 232 | alpine-lite-ppc64le: 233 | name: Alpine - ppc64le (Lite) 234 | runs-on: ubuntu-latest 235 | if: ${{ startsWith(github.event.milestone.title, '10.') || startsWith(github.event.milestone.title, '11.') || startsWith(github.event.milestone.title, '12.') || startsWith(github.event.milestone.title, '13.') || startsWith(github.event.milestone.title, '14.') || startsWith(github.event.milestone.title, '15.') }} 236 | steps: 237 | - name: Checkout code 238 | uses: actions/checkout@v3 239 | with: 240 | ref: master 241 | - name: Set up JDK 242 | uses: actions/setup-java@v3 243 | with: 244 | distribution: 'zulu' 245 | java-version: 15 246 | - name: Set environment variables 247 | env: 248 | MILESTONE_VERSION: ${{ github.event.milestone.title }} 249 | run: | 250 | echo "RELEASE_VERSION=$MILESTONE_VERSION" >> $GITHUB_ENV 251 | echo "POSTGRES_VERSION=${MILESTONE_VERSION%.*}" >> $GITHUB_ENV 252 | - name: Register QEMU 253 | run: docker run --rm --privileged multiarch/qemu-user-static:register --reset 254 | - name: Build Bundle 255 | run: ./gradlew :alpine-lite-platforms:buildPpc64leAlpineLiteBundle -Pversion=$RELEASE_VERSION -PpgVersion=$POSTGRES_VERSION 256 | - name: Upload bundle 257 | uses: actions/upload-artifact@v4 258 | with: 259 | name: ppc64leAlpineLiteBundle 260 | path: alpine-lite-platforms/build/tmp/buildPpc64leAlpineLiteBundle/bundle/postgres-linux-alpine_linux.txz 261 | release: 262 | name: Collect artifacts & Release ${{ github.event.milestone.title }} 263 | needs: [debian-arm32v7, debian-arm64v8, debian-ppc64le, alpine-arm32v6, alpine-arm64v8, alpine-ppc64le, alpine-lite-arm32v6, alpine-lite-arm64v8, alpine-lite-ppc64le] 264 | if: ${{ !failure() }} 265 | runs-on: ubuntu-latest 266 | steps: 267 | - name: Checkout code 268 | uses: actions/checkout@v3 269 | with: 270 | ref: master 271 | - name: Set up Git 272 | run: | 273 | git config user.name "Zonky Bot" 274 | git config user.email "bot@zonky.com" 275 | - name: Set up JDK 276 | uses: actions/setup-java@v3 277 | with: 278 | distribution: 'zulu' 279 | java-version: 15 280 | - name: Set environment variables 281 | env: 282 | MILESTONE_VERSION: ${{ github.event.milestone.title }} 283 | run: | 284 | echo "RELEASE_VERSION=$MILESTONE_VERSION" >> $GITHUB_ENV 285 | echo "POSTGRES_VERSION=${MILESTONE_VERSION%.*}" >> $GITHUB_ENV 286 | - name: Download bundle - arm32v7Debian 287 | uses: actions/download-artifact@v4 288 | with: 289 | name: arm32v7DebianBundle 290 | path: debian-platforms/build/tmp/buildArm32v7DebianBundle/bundle 291 | - name: Download bundle - arm64v8Debian 292 | uses: actions/download-artifact@v4 293 | with: 294 | name: arm64v8DebianBundle 295 | path: debian-platforms/build/tmp/buildArm64v8DebianBundle/bundle 296 | - name: Download bundle - ppc64leDebian 297 | uses: actions/download-artifact@v4 298 | with: 299 | name: ppc64leDebianBundle 300 | path: debian-platforms/build/tmp/buildPpc64leDebianBundle/bundle 301 | - name: Download bundle - arm32v6Alpine 302 | uses: actions/download-artifact@v4 303 | with: 304 | name: arm32v6AlpineBundle 305 | path: alpine-platforms/build/tmp/buildArm32v6AlpineBundle/bundle 306 | - name: Download bundle - arm64v8Alpine 307 | uses: actions/download-artifact@v4 308 | with: 309 | name: arm64v8AlpineBundle 310 | path: alpine-platforms/build/tmp/buildArm64v8AlpineBundle/bundle 311 | - name: Download bundle - ppc64leAlpine 312 | uses: actions/download-artifact@v4 313 | with: 314 | name: ppc64leAlpineBundle 315 | path: alpine-platforms/build/tmp/buildPpc64leAlpineBundle/bundle 316 | - name: Download bundle - arm32v6AlpineLite 317 | if: ${{ startsWith(github.event.milestone.title, '10.') || startsWith(github.event.milestone.title, '11.') || startsWith(github.event.milestone.title, '12.') || startsWith(github.event.milestone.title, '13.') || startsWith(github.event.milestone.title, '14.') || startsWith(github.event.milestone.title, '15.') }} 318 | uses: actions/download-artifact@v4 319 | with: 320 | name: arm32v6AlpineLiteBundle 321 | path: alpine-lite-platforms/build/tmp/buildArm32v6AlpineLiteBundle/bundle 322 | - name: Download bundle - arm64v8AlpineLite 323 | if: ${{ startsWith(github.event.milestone.title, '10.') || startsWith(github.event.milestone.title, '11.') || startsWith(github.event.milestone.title, '12.') || startsWith(github.event.milestone.title, '13.') || startsWith(github.event.milestone.title, '14.') || startsWith(github.event.milestone.title, '15.') }} 324 | uses: actions/download-artifact@v4 325 | with: 326 | name: arm64v8AlpineLiteBundle 327 | path: alpine-lite-platforms/build/tmp/buildArm64v8AlpineLiteBundle/bundle 328 | - name: Download bundle - ppc64leAlpineLite 329 | if: ${{ startsWith(github.event.milestone.title, '10.') || startsWith(github.event.milestone.title, '11.') || startsWith(github.event.milestone.title, '12.') || startsWith(github.event.milestone.title, '13.') || startsWith(github.event.milestone.title, '14.') || startsWith(github.event.milestone.title, '15.') }} 330 | uses: actions/download-artifact@v4 331 | with: 332 | name: ppc64leAlpineLiteBundle 333 | path: alpine-lite-platforms/build/tmp/buildPpc64leAlpineLiteBundle/bundle 334 | - name: Release with Gradle 335 | if: ${{ startsWith(github.event.milestone.title, '10.') || startsWith(github.event.milestone.title, '11.') || startsWith(github.event.milestone.title, '12.') || startsWith(github.event.milestone.title, '13.') || startsWith(github.event.milestone.title, '14.') || startsWith(github.event.milestone.title, '15.') }} 336 | env: 337 | MAVEN_USER: ${{ secrets.MAVEN_USER }} 338 | MAVEN_PASS: ${{ secrets.MAVEN_PASS }} 339 | ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} 340 | ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_CERT }} 341 | ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASS }} 342 | run: | 343 | ./gradlew uploadArchives --info \ 344 | -x buildArm32v7DebianBundle \ 345 | -x buildArm64v8DebianBundle \ 346 | -x buildPpc64leDebianBundle \ 347 | -x buildArm32v6AlpineBundle \ 348 | -x buildArm64v8AlpineBundle \ 349 | -x buildPpc64leAlpineBundle \ 350 | -x buildArm32v6AlpineLiteBundle \ 351 | -x buildArm64v8AlpineLiteBundle \ 352 | -x buildPpc64leAlpineLiteBundle \ 353 | -Pversion=$RELEASE_VERSION \ 354 | -PpgVersion=$POSTGRES_VERSION \ 355 | -Possrh.username=$MAVEN_USER \ 356 | -Possrh.password=$MAVEN_PASS 357 | - name: Release with Gradle 2 358 | if: ${{ !startsWith(github.event.milestone.title, '10.') && !startsWith(github.event.milestone.title, '11.') && !startsWith(github.event.milestone.title, '12.') && !startsWith(github.event.milestone.title, '13.') && !startsWith(github.event.milestone.title, '14.') && !startsWith(github.event.milestone.title, '15.') }} 359 | env: 360 | MAVEN_USER: ${{ secrets.MAVEN_USER }} 361 | MAVEN_PASS: ${{ secrets.MAVEN_PASS }} 362 | ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} 363 | ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_CERT }} 364 | ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASS }} 365 | run: | 366 | ./gradlew uploadArchives --info \ 367 | -x buildArm32v7DebianBundle \ 368 | -x buildArm64v8DebianBundle \ 369 | -x buildPpc64leDebianBundle \ 370 | -x buildArm32v6AlpineBundle \ 371 | -x buildArm64v8AlpineBundle \ 372 | -x buildPpc64leAlpineBundle \ 373 | -Pversion=$RELEASE_VERSION \ 374 | -PpgVersion=$POSTGRES_VERSION \ 375 | -Possrh.username=$MAVEN_USER \ 376 | -Possrh.password=$MAVEN_PASS 377 | - name: Create tag 378 | env: 379 | GIT_COMMITTER_DATE: ${{ github.event.milestone.created_at }} 380 | run: | 381 | git tag -a v$RELEASE_VERSION -m "PostgreSQL $POSTGRES_VERSION" 382 | git push -f origin v$RELEASE_VERSION -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Checks 2 | on: [push, pull_request] 3 | jobs: 4 | linux: 5 | name: PostgreSQL ${{ matrix.postgres }} (Linux) 6 | runs-on: ubuntu-latest 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | postgres: ["17.5", "16.9", "15.13", "14.18", "13.21"] 11 | steps: 12 | - name: Checkout project 13 | uses: actions/checkout@v3 14 | - name: Set up JDK 15 | uses: actions/setup-java@v3 16 | with: 17 | distribution: 'zulu' 18 | java-version: 15 19 | - name: Test PostgreSQL bundle 20 | if: ${{ !(startsWith(matrix.postgres, '10.') || startsWith(matrix.postgres, '9.')) }} 21 | run: ./gradlew :debian-platforms:testAmd64DebianJar -Pversion=${{ matrix.postgres }}-TEST -PpgVersion=${{ matrix.postgres }} 22 | timeout-minutes: 10 23 | - name: Test PostgreSQL bundle (repacked) 24 | if: ${{ startsWith(matrix.postgres, '10.') || startsWith(matrix.postgres, '9.') }} 25 | run: ./gradlew :repacked-platforms:testAmd64LinuxJar -Pversion=${{ matrix.postgres }}-TEST -PpgVersion=${{ matrix.postgres }} 26 | timeout-minutes: 10 27 | - name: Test PostgreSQL bundle (compiled) 28 | if: ${{ startsWith(matrix.postgres, '10.') || startsWith(matrix.postgres, '9.') }} 29 | run: ./gradlew :custom-debian-platform:testCustomDebianJar -Pversion=${{ matrix.postgres }}-TEST -PpgVersion=${{ matrix.postgres }} -ParchName=amd64 30 | timeout-minutes: 10 31 | alpine-linux: 32 | name: PostgreSQL ${{ matrix.postgres }} (Alpine Linux) 33 | runs-on: ubuntu-latest 34 | strategy: 35 | fail-fast: false 36 | matrix: 37 | postgres: ["17.5", "16.9", "15.13", "14.18", "13.21"] 38 | steps: 39 | - name: Checkout project 40 | uses: actions/checkout@v3 41 | - name: Set up JDK 42 | uses: actions/setup-java@v3 43 | with: 44 | distribution: 'zulu' 45 | java-version: 15 46 | - name: Test PostgreSQL bundle 47 | run: ./gradlew :alpine-platforms:testAmd64AlpineJar -Pversion=${{ matrix.postgres }}-TEST -PpgVersion=${{ matrix.postgres }} 48 | timeout-minutes: 10 49 | - name: Test PostgreSQL bundle (lite) 50 | if: ${{ startsWith(matrix.postgres, '10.') || startsWith(matrix.postgres, '11.') || startsWith(matrix.postgres, '12.') || startsWith(matrix.postgres, '13.') || startsWith(matrix.postgres, '14.') || startsWith(matrix.postgres, '15.') }} 51 | run: ./gradlew :alpine-lite-platforms:testAmd64AlpineLiteJar -Pversion=${{ matrix.postgres }}-TEST -PpgVersion=${{ matrix.postgres }} 52 | timeout-minutes: 10 53 | macos: 54 | name: PostgreSQL ${{ matrix.postgres }} (MacOS) 55 | runs-on: macos-latest 56 | strategy: 57 | fail-fast: false 58 | matrix: 59 | postgres: ["17.5", "16.9", "15.13", "14.18", "13.21"] 60 | steps: 61 | - name: Checkout project 62 | uses: actions/checkout@v3 63 | - name: Set up JDK 64 | uses: actions/setup-java@v3 65 | with: 66 | distribution: 'zulu' 67 | java-version: 15 68 | - name: Install psql executables 69 | run: | 70 | brew update 71 | brew install postgresql 72 | - name: Test PostgreSQL bundle 73 | run: ./gradlew :repacked-platforms:testAmd64DarwinJar -Pversion=${{ matrix.postgres }}-TEST -PpgVersion=${{ matrix.postgres }} 74 | timeout-minutes: 10 75 | windows: 76 | name: PostgreSQL ${{ matrix.postgres }} (Windows) 77 | runs-on: windows-latest 78 | strategy: 79 | fail-fast: false 80 | matrix: 81 | postgres: ["17.5", "16.9", "15.13", "14.18", "13.21"] 82 | steps: 83 | - name: Checkout project 84 | uses: actions/checkout@v3 85 | - name: Set up JDK 86 | uses: actions/setup-java@v3 87 | with: 88 | distribution: 'zulu' 89 | java-version: 15 90 | - name: Install GNU Wget 91 | run: choco install wget 92 | - name: Update system paths 93 | run: echo $PGBIN >> $GITHUB_PATH 94 | shell: bash 95 | - name: Test PostgreSQL bundle 96 | run: ./gradlew :repacked-platforms:testAmd64WindowsJar -Pversion=${{ matrix.postgres }}-TEST -PpgVersion=${{ matrix.postgres }} 97 | shell: bash 98 | timeout-minutes: 10 99 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Class files # 2 | target/ 3 | *.class 4 | 5 | # Gradle files # 6 | .gradle/ 7 | build/ 8 | 9 | # Package files # 10 | *.jar 11 | *.war 12 | *.ear 13 | 14 | # Eclipse specific files # 15 | .classpath 16 | .project 17 | .settings/ 18 | 19 | # Idea specific files # 20 | .idea/ 21 | *.iml 22 | *.iws 23 | 24 | # Virtual machine crash logs 25 | hs_err_pid* 26 | 27 | # Gradle wrapper files 28 | !gradle/wrapper/ 29 | !gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Embedded Postgres Binaries 2 | 3 | ## Introduction 4 | 5 | This project provides lightweight bundles of PostgreSQL binaries with reduced size that are intended for testing purposes. 6 | It is a supporting project for the primary [io.zonky.test:embedded-database-spring-test](https://github.com/zonkyio/embedded-database-spring-test) and [io.zonky.test:embedded-postgres](https://github.com/zonkyio/embedded-postgres) projects. 7 | However, with a little effort, the embedded binaries can also be integrated with other projects. 8 | 9 | ## Provided features 10 | 11 | * Lightweight bundles of PostgreSQL binaries with reduced size (~10MB) 12 | * Embedded PostgreSQL 11+ binaries even for Linux platform 13 | * Configurable version of PostgreSQL binaries 14 | 15 | ## Projects using the embedded binaries 16 | 17 | * [zonkyio/embedded-database-spring-test](https://github.com/zonkyio/embedded-database-spring-test) (Java - Spring) 18 | * [zonkyio/embedded-postgres](https://github.com/zonkyio/embedded-postgres) (Java) 19 | * [hgschmie/pg-embedded](https://github.com/hgschmie/pg-embedded) (Java) 20 | * [fergusstrange/embedded-postgres](https://github.com/fergusstrange/embedded-postgres) (Go) 21 | * [theseus-rs/postgresql-embedded](https://github.com/theseus-rs/postgresql-embedded) (Rust) 22 | * [faokunega/pg-embed](https://github.com/faokunega/pg-embed) (Rust) 23 | * [leinelissen/embedded-postgres](https://github.com/leinelissen/embedded-postgres) (NodeJS) 24 | 25 | ## Postgres version 26 | 27 | The version of the postgres binaries can be managed by importing `embedded-postgres-binaries-bom` in a required version in your dependency management section. 28 | 29 | ```xml 30 | 31 | 32 | 33 | io.zonky.test.postgres 34 | embedded-postgres-binaries-bom 35 | 16.0.0 36 | pom 37 | import 38 | 39 | 40 | 41 | ``` 42 | 43 | A list of all available versions of postgres binaries is here: https://mvnrepository.com/artifact/io.zonky.test.postgres/embedded-postgres-binaries-bom 44 | 45 | ## Supported architectures 46 | 47 | By default, only dependencies for `amd64` architecture, in the [io.zonky.test:embedded-database-spring-test](https://github.com/zonkyio/embedded-database-spring-test) and [io.zonky.test:embedded-postgres](https://github.com/zonkyio/embedded-postgres) projects, are included. 48 | Support for other architectures can be enabled by adding the corresponding Maven dependencies as shown in the example below. 49 | 50 | ```xml 51 | 52 | io.zonky.test.postgres 53 | embedded-postgres-binaries-linux-i386 54 | test 55 | 56 | ``` 57 | 58 | **Supported platforms:** `Darwin`, `Windows`, `Linux`, `Alpine Linux` 59 | **Supported architectures:** `amd64`, `i386`, `arm32v6`, `arm32v7`, `arm64v8`, `ppc64le` 60 | 61 | Note that not all architectures are supported by all platforms, you can find an exhaustive list of all available artifacts here: https://mvnrepository.com/artifact/io.zonky.test.postgres 62 | 63 | ## Building from Source 64 | The project uses a [Gradle](http://gradle.org)-based build system. In the instructions 65 | below, [`./gradlew`](http://vimeo.com/34436402) is invoked from the root of the source tree and serves as 66 | a cross-platform, self-contained bootstrap mechanism for the build. 67 | 68 | ### Prerequisites 69 | 70 | [Git](http://help.github.com/set-up-git-redirect), [JDK 6 or later](http://www.oracle.com/technetwork/java/javase/downloads) and [Docker](https://www.docker.com/get-started) 71 | 72 | Be sure that your `JAVA_HOME` environment variable points to the `jdk1.6.0` folder 73 | extracted from the JDK download. 74 | 75 | Compiling non-native architectures rely on emulation, so it is necessary to register `qemu-*-static` executables: 76 | 77 | `docker run --rm --privileged multiarch/qemu-user-static:register --reset` 78 | 79 | **Note that the complete build of all supported architectures is now supported only on Linux platform.** 80 | 81 | ### Check out sources 82 | `git clone git@github.com:zonkyio/embedded-postgres-binaries.git` 83 | 84 | ### Make complete build 85 | 86 | Builds all supported artifacts for all supported platforms and architectures, and also builds a BOM to control the versions of postgres binaries. 87 | 88 | `./gradlew clean install --parallel -Pversion=10.6.0 -PpgVersion=10.6` 89 | 90 | Note that the complete build can take a very long time, even a few hours, depending on the performance of the machine on which the build is running. 91 | 92 | ### Make partial build 93 | 94 | Builds only binaries for a specified platform/submodule. 95 | 96 | `./gradlew clean :repacked-platforms:install -Pversion=10.6.0 -PpgVersion=10.6` 97 | 98 | ### Build only a single binary 99 | 100 | Builds only a single binary for a specified platform and architecture. 101 | 102 | `./gradlew clean install -Pversion=10.6.0 -PpgVersion=10.6 -ParchName=arm64v8 -PdistName=alpine` 103 | 104 | It is also possible to include the PostGIS extension by passing the `postgisVersion` parameter, e.g. `-PpostgisVersion=2.5.2`. Note that this option is not (yet) available for Windows and Mac OS platforms. 105 | 106 | Optional parameters: 107 | - *postgisVersion* 108 | - default value: unset 109 | - supported values: a postgis version number (only 2.5.2+, 2.4.7+, 2.3.9+ versions are supported) 110 | - *archName* 111 | - default value: `amd64` 112 | - supported values: `amd64`, `i386`, `arm32v6`, `arm32v7`, `arm64v8`, `ppc64le` 113 | - *distName* 114 | - default value: debian-like distribution 115 | - supported values: the default value or `alpine` 116 | - *dockerImage* 117 | - default value: resolved based on the platform 118 | - supported values: any supported docker image 119 | - *qemuPath* 120 | - default value: executables are resolved from `/usr/bin` directory or downloaded from https://github.com/multiarch/qemu-user-static/releases/download/v2.12.0 121 | - supported values: a path to a directory containing qemu executables 122 | 123 | ## License 124 | The project is released under version 2.0 of the [Apache License](http://www.apache.org/licenses/LICENSE-2.0.html). 125 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | import org.gradle.internal.os.OperatingSystem 2 | 3 | plugins { 4 | id "de.undercouch.download" version "4.1.1" 5 | } 6 | 7 | ext { 8 | ossrhUsername = project.findProperty('ossrh.username') 9 | ossrhPassword = project.findProperty('ossrh.password') 10 | 11 | pgVersionParam = project.findProperty('pgVersion') ?: ("${project.version}" - '-SNAPSHOT') 12 | pgBinVersionParam = project.findProperty('pgBinVersion') ?: "${pgVersionParam}-1" 13 | postgisVersionParam = project.findProperty('postgisVersion') ?: '' 14 | archNameParam = project.findProperty('archName') ?: '' 15 | distNameParam = project.findProperty('distName') ?: '' 16 | dockerImageParam = project.findProperty('dockerImage') ?: '' 17 | qemuPathParam = project.findProperty('qemuPath') ?: '' 18 | 19 | pgMajorVersionParam = (pgVersionParam =~ /(\d+).+/).with { matches() ? it[0][1].toInteger() : null } 20 | pgMinorVersionParam = (pgVersionParam =~ /\d+\.(\d+).*/).with { matches() ? it[0][1].toInteger() : null } 21 | } 22 | 23 | allprojects { 24 | apply plugin: 'java' 25 | apply plugin: 'maven-publish' 26 | apply plugin: 'signing' 27 | 28 | group 'io.zonky.test.postgres' 29 | version += postgisVersionParam ? "-postgis-$postgisVersionParam" : '' 30 | archivesBaseName = 'embedded-postgres-binaries' 31 | sourceCompatibility = 1.6 32 | 33 | repositories { 34 | mavenCentral() 35 | } 36 | 37 | configurations { 38 | bundles 39 | } 40 | } 41 | 42 | task validateInputs { 43 | doFirst { 44 | println "version: ${project.version}" 45 | println "pgVersion: $pgVersionParam" 46 | println "pgBinVersion: $pgBinVersionParam" 47 | 48 | if (!project.version || project.version == 'unspecified') { 49 | throw new GradleException("The 'version' property must be set") 50 | } 51 | if (distNameParam && distNameParam != 'alpine') { 52 | throw new GradleException("Currently only the 'alpine' distribution is supported") 53 | } 54 | if (archNameParam && !(archNameParam ==~ /^[a-z0-9]+$/)) { 55 | throw new GradleException("The 'archName' property must contain only alphanumeric characters") 56 | } 57 | } 58 | } 59 | 60 | task downloadQemuExecutables(type: Download, dependsOn: validateInputs) { 61 | onlyIfModified true 62 | onlyIf { !qemuPathParam && OperatingSystem.current().isLinux() && OperatingSystem.current().getArch() == 'amd64' } 63 | src(['arm', 'aarch64', 'ppc64le'].collect { arch -> 64 | "https://github.com/multiarch/qemu-user-static/releases/download/v2.12.0/qemu-$arch-static" 65 | }) 66 | overwrite false 67 | dest file("$temporaryDir/downloads") 68 | } 69 | 70 | task prepareQemuExecutables(type: Copy, dependsOn: downloadQemuExecutables) { 71 | from downloadQemuExecutables.dest 72 | into file("$temporaryDir/executables") 73 | fileMode = 0755 74 | } 75 | 76 | def repackedPlatforms = [ 77 | ['name':'darwin', 'arch':'amd64'], 78 | ['name':'windows', 'arch':'amd64'] 79 | ] 80 | 81 | if (pgMajorVersionParam > 14 82 | || (pgMajorVersionParam == 14 && pgMinorVersionParam >= 1)) { 83 | repackedPlatforms << ['name':'darwin', 'arch':'arm64v8'] 84 | } 85 | 86 | if (pgMajorVersionParam < 11) { 87 | repackedPlatforms << ['name':'windows', 'arch':'i386'] 88 | if (pgVersionParam != '9.5.19') { 89 | repackedPlatforms << ['name':'linux', 'arch':'i386'] 90 | repackedPlatforms << ['name':'linux', 'arch':'amd64'] 91 | } 92 | } 93 | 94 | def debianPlatforms = [ 95 | // ['arch':'arm32v6', 'image':'resin/rpi-raspbian:jessie'], 96 | ['arch':'arm32v7'], 97 | ['arch':'arm64v8'], 98 | ['arch':'ppc64le'] 99 | ] 100 | 101 | if (pgMajorVersionParam >= 11 || pgVersionParam == '9.5.19') { 102 | debianPlatforms << ['arch':'i386'] 103 | debianPlatforms << ['arch':'amd64'] 104 | } 105 | 106 | def alpinePlatforms = [ 107 | ['arch':'i386'], 108 | ['arch':'amd64'], 109 | ['arch':'arm32v6'], 110 | ['arch':'arm64v8'], 111 | ['arch':'ppc64le'] 112 | ] 113 | 114 | def alpineVariants = [ 115 | ['name':'', 'opt':'', 'enabled': true], 116 | ['name':'lite', 'opt':'-l', 'enabled': pgMajorVersionParam >= 10 && pgMajorVersionParam < 16] 117 | ] 118 | 119 | project(':repacked-platforms') { 120 | if (!distNameParam && !archNameParam && !dockerImageParam && !postgisVersionParam) { 121 | repackedPlatforms.each { platform -> 122 | task "build${platform.arch.capitalize()}${platform.name.capitalize()}Bundle"(group: "build (${platform.arch})", type: Exec, dependsOn: validateInputs) { 123 | inputs.property('pgBinVersionParam', pgBinVersionParam) 124 | inputs.property('platformName', platform.name) 125 | inputs.property('archName', platform.arch) 126 | 127 | inputs.file("$rootDir/scripts/repack-postgres.sh") 128 | outputs.dir("$temporaryDir/bundle") 129 | 130 | workingDir temporaryDir 131 | commandLine 'sh', "$rootDir/scripts/repack-postgres.sh", '-v', "$pgBinVersionParam", '-p', "${platform.name}", '-a', "${platform.arch}" 132 | } 133 | 134 | task "${platform.arch}${platform.name.capitalize()}Jar"(group: "build (${platform.arch})", type: Jar) { 135 | from tasks.getByName("build${platform.arch.capitalize()}${platform.name.capitalize()}Bundle") 136 | include "postgres-${platform.name}-${normalizeArchName(platform.arch)}.txz" 137 | appendix = "${platform.name}-${platform.arch}" 138 | } 139 | 140 | task "test${platform.arch.capitalize()}${platform.name.capitalize()}Jar"(group: "build (${platform.arch})", type: LazyExec, dependsOn: [validateInputs, "${platform.arch}${platform.name.capitalize()}Jar"]) { 141 | onlyIf { 142 | def system = OperatingSystem.current() 143 | return gradle.startParameter.taskNames.any { taskName -> taskName.endsWith(name) } || 144 | (system.isLinux() && platform.name == 'linux' && platform.arch == system.getArch()) || 145 | (system.isMacOsX() && platform.name == 'darwin' && platform.arch == system.getArch()) || 146 | (system.isWindows() && platform.name == 'windows') 147 | } 148 | 149 | def qemuBindings = { resolveQemuBindings() } 150 | def dockerImage = { defaultDebianImage(platform.arch, qemuBindings()) } 151 | 152 | inputs.property('pgVersion', pgVersionParam) 153 | inputs.property('platformName', platform.name) 154 | inputs.property('archName', platform.arch) 155 | 156 | if (platform.name == 'linux') { 157 | inputs.property('dockerImage', dockerImage) 158 | } 159 | 160 | inputs.file("$rootDir/scripts/test-postgres-${platform.name}.sh") 161 | 162 | workingDir tasks.getByName("${platform.arch}${platform.name.capitalize()}Jar").destinationDirectory 163 | 164 | if (platform.name == 'linux') { 165 | commandLine 'sh', "$rootDir/scripts/test-postgres-${platform.name}.sh", 166 | '-j', "embedded-postgres-binaries-${platform.name}-${platform.arch}-${version}.jar", 167 | '-z', "postgres-${platform.name}-${normalizeArchName(platform.arch)}.txz", 168 | '-v', "$pgVersionParam", '-i', dockerImage, '-o', qemuBindings 169 | } else { 170 | commandLine 'sh', "$rootDir/scripts/test-postgres-${platform.name}.sh", 171 | '-j', "embedded-postgres-binaries-${platform.name}-${platform.arch}-${version}.jar", 172 | '-z', "postgres-${platform.name}-${normalizeArchName(platform.arch)}.txz", 173 | '-v', "$pgVersionParam" 174 | } 175 | } 176 | 177 | artifacts.add('bundles', tasks.getByName("${platform.arch}${platform.name.capitalize()}Jar")) 178 | } 179 | } 180 | } 181 | 182 | project(':debian-platforms') { 183 | if (!distNameParam && !archNameParam && !dockerImageParam && !postgisVersionParam) { 184 | debianPlatforms.each { platform -> 185 | task "build${platform.arch.capitalize()}DebianBundle"(group: "build (${platform.arch})", type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables]) { 186 | def qemuBindings = { resolveQemuBindings() } 187 | def dockerImage = { platform.image ?: defaultDebianImage(platform.arch, qemuBindings) } 188 | 189 | doFirst { 190 | println "dockerImage: ${dockerImage()}" 191 | println "qemuBindings: ${qemuBindings()}" 192 | println '' 193 | } 194 | 195 | inputs.property('pgVersion', pgVersionParam) 196 | inputs.property('archName', platform.arch) 197 | inputs.property('dockerImage', dockerImage) 198 | 199 | inputs.file("$rootDir/scripts/build-postgres-debian.sh") 200 | outputs.dir("$temporaryDir/bundle") 201 | 202 | workingDir temporaryDir 203 | commandLine 'sh', "$rootDir/scripts/build-postgres-debian.sh", '-v', "$pgVersionParam", '-i', dockerImage, '-o', qemuBindings 204 | } 205 | 206 | task "${platform.arch}DebianJar"(group: "build (${platform.arch})", type: Jar) { 207 | from tasks.getByName("build${platform.arch.capitalize()}DebianBundle") 208 | include "postgres-linux-debian.txz" 209 | rename "postgres-linux-debian.txz", "postgres-linux-${normalizeArchName(platform.arch)}.txz" 210 | appendix = "linux-${platform.arch}" 211 | } 212 | 213 | task "test${platform.arch.capitalize()}DebianJar"(group: "build (${platform.arch})", type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables, "${platform.arch}DebianJar"]) { 214 | def qemuBindings = { resolveQemuBindings() } 215 | def dockerImage = { platform.image ?: defaultDebianImage(platform.arch, qemuBindings) } 216 | 217 | inputs.property('pgVersion', pgVersionParam) 218 | inputs.property('archName', platform.arch) 219 | inputs.property('dockerImage', dockerImage) 220 | 221 | inputs.file("$rootDir/scripts/test-postgres-linux.sh") 222 | 223 | workingDir tasks.getByName("${platform.arch}DebianJar").destinationDirectory 224 | commandLine 'sh', "$rootDir/scripts/test-postgres-linux.sh", 225 | '-j', "embedded-postgres-binaries-linux-${platform.arch}-${version}.jar", 226 | '-z', "postgres-linux-${normalizeArchName(platform.arch)}.txz", 227 | '-i', dockerImage, '-v', "$pgVersionParam", '-g', postgisVersionParam, '-o', qemuBindings 228 | } 229 | 230 | artifacts.add('bundles', tasks.getByName("${platform.arch}DebianJar")) 231 | } 232 | } 233 | } 234 | 235 | alpineVariants.each { variant -> 236 | project(":alpine${variant.name ? '-' + variant.name : ''}-platforms") { 237 | if (!distNameParam && !archNameParam && !dockerImageParam && !postgisVersionParam && variant.enabled) { 238 | alpinePlatforms.each { platform -> 239 | 240 | task "build${platform.arch.capitalize()}Alpine${variant.name.capitalize()}Bundle"(group: "build (${platform.arch})", type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables]) { 241 | def qemuBindings = { resolveQemuBindings() } 242 | def dockerImage = { platform.image ?: defaultAlpineImage(platform.arch, qemuBindings) } 243 | 244 | doFirst { 245 | println "dockerImage: ${dockerImage()}" 246 | println "qemuBindings: ${qemuBindings()}" 247 | println '' 248 | } 249 | 250 | inputs.property('pgVersion', pgVersionParam) 251 | inputs.property('archName', platform.arch) 252 | inputs.property('dockerImage', dockerImage) 253 | 254 | inputs.file("$rootDir/scripts/build-postgres-alpine.sh") 255 | outputs.dir("$temporaryDir/bundle") 256 | 257 | workingDir temporaryDir 258 | commandLine 'sh', "$rootDir/scripts/build-postgres-alpine.sh", '-v', "$pgVersionParam", '-i', dockerImage, '-o', qemuBindings, "${variant.opt}" 259 | } 260 | 261 | task "${platform.arch}Alpine${variant.name.capitalize()}Jar"(group: "build (${platform.arch})", type: Jar) { 262 | from tasks.getByName("build${platform.arch.capitalize()}Alpine${variant.name.capitalize()}Bundle") 263 | include "postgres-linux-alpine_linux.txz" 264 | rename "postgres-linux-alpine_linux.txz", "postgres-linux-${normalizeArchName(platform.arch)}-alpine_linux.txz" 265 | appendix = "linux-${platform.arch}-alpine${variant.name ? '-' + variant.name : ''}" 266 | } 267 | 268 | task "test${platform.arch.capitalize()}Alpine${variant.name.capitalize()}Jar"(group: "build (${platform.arch})", type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables, "${platform.arch}Alpine${variant.name.capitalize()}Jar"]) { 269 | def qemuBindings = { resolveQemuBindings() } 270 | def dockerImage = { platform.image ?: defaultAlpineImage(platform.arch, qemuBindings) } 271 | 272 | inputs.property('pgVersion', pgVersionParam) 273 | inputs.property('archName', platform.arch) 274 | inputs.property('dockerImage', dockerImage) 275 | 276 | inputs.file("$rootDir/scripts/test-postgres-alpine.sh") 277 | 278 | workingDir tasks.getByName("${platform.arch}Alpine${variant.name.capitalize()}Jar").destinationDirectory 279 | commandLine 'sh', "$rootDir/scripts/test-postgres-alpine.sh", 280 | '-j', "embedded-postgres-binaries-linux-${platform.arch}-alpine${variant.name ? '-' + variant.name : ''}-${version}.jar", 281 | '-z', "postgres-linux-${normalizeArchName(platform.arch)}-alpine_linux.txz", 282 | '-i', dockerImage, '-v', "$pgVersionParam", '-g', postgisVersionParam, '-o', qemuBindings 283 | } 284 | 285 | artifacts.add('bundles', tasks.getByName("${platform.arch}Alpine${variant.name.capitalize()}Jar")) 286 | } 287 | } 288 | } 289 | } 290 | 291 | project(':custom-debian-platform') { 292 | if (!distNameParam && (archNameParam || dockerImageParam || postgisVersionParam)) { 293 | def archName = archNameParam ?: 'amd64' 294 | 295 | task buildCustomDebianBundle(group: 'build (custom)', type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables]) { 296 | def qemuBindings = { resolveQemuBindings() } 297 | def dockerImage = { dockerImageParam ?: defaultDebianImage(archName, qemuBindings()) } 298 | 299 | doFirst { 300 | println "archName: $archName" 301 | println "distName: debian-like" 302 | println "dockerImage: ${dockerImage()}" 303 | println "qemuBindings: ${qemuBindings()}" 304 | println '' 305 | 306 | if (postgisVersionParam) { 307 | println '===== Extensions =====' 308 | println "postgisVersion: $postgisVersionParam" 309 | println '======================' 310 | println '' 311 | } 312 | } 313 | 314 | inputs.property('pgVersion', pgVersionParam) 315 | inputs.property('archName', archName) 316 | inputs.property('dockerImage', dockerImage) 317 | inputs.property('postgisVersion', postgisVersionParam) 318 | 319 | inputs.file("$rootDir/scripts/build-postgres-debian.sh") 320 | outputs.dir("$temporaryDir/bundle") 321 | 322 | workingDir temporaryDir 323 | commandLine 'sh', "$rootDir/scripts/build-postgres-debian.sh", '-v', "$pgVersionParam", '-i', dockerImage, '-g', postgisVersionParam, '-o', qemuBindings 324 | } 325 | 326 | task customDebianJar(group: 'build (custom)', type: Jar) { 327 | from buildCustomDebianBundle 328 | include "postgres-linux-debian.txz" 329 | rename "postgres-linux-debian.txz", "postgres-linux-${normalizeArchName(archName)}.txz" 330 | appendix = "linux-${archName}" 331 | } 332 | 333 | task testCustomDebianJar(group: 'build (custom)', type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables, customDebianJar]) { 334 | def qemuBindings = { resolveQemuBindings() } 335 | def dockerImage = { dockerImageParam ?: defaultDebianImage(archName, qemuBindings()) } 336 | 337 | inputs.property('pgVersion', pgVersionParam) 338 | inputs.property('archName', archName) 339 | inputs.property('dockerImage', dockerImage) 340 | inputs.property('postgisVersion', postgisVersionParam) 341 | 342 | inputs.file("$rootDir/scripts/test-postgres-linux.sh") 343 | 344 | workingDir customDebianJar.destinationDirectory 345 | commandLine 'sh', "$rootDir/scripts/test-postgres-linux.sh", 346 | '-j', "embedded-postgres-binaries-linux-${archName}-${version}.jar", 347 | '-z', "postgres-linux-${normalizeArchName(archName)}.txz", 348 | '-i', dockerImage, '-v', "$pgVersionParam", '-g', postgisVersionParam, '-o', qemuBindings 349 | } 350 | 351 | artifacts.add('bundles', tasks.getByName('customDebianJar')) 352 | } 353 | } 354 | 355 | alpineVariants.each { variant -> 356 | project(":custom-alpine${variant.name ? '-' + variant.name : ''}-platform") { 357 | if (distNameParam == 'alpine' && variant.enabled) { 358 | def archName = archNameParam ?: 'amd64' 359 | 360 | task "buildCustomAlpine${variant.name.capitalize()}Bundle"(group: 'build (custom)', type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables]) { 361 | def qemuBindings = { resolveQemuBindings() } 362 | def dockerImage = { dockerImageParam ?: defaultAlpineImage(archName, qemuBindings) } 363 | 364 | doFirst { 365 | println "archName: $archName" 366 | println "distName: alpine" 367 | println "dockerImage: ${dockerImage()}" 368 | println "qemuBindings: ${qemuBindings()}" 369 | println '' 370 | 371 | if (postgisVersionParam) { 372 | println '===== Extensions =====' 373 | println "postgisVersion: $postgisVersionParam" 374 | println '======================' 375 | println '' 376 | } 377 | } 378 | 379 | inputs.property('pgVersion', pgVersionParam) 380 | inputs.property('archName', archName) 381 | inputs.property('dockerImage', dockerImage) 382 | inputs.property('postgisVersion', postgisVersionParam) 383 | 384 | inputs.file("$rootDir/scripts/build-postgres-alpine.sh") 385 | outputs.dir("$temporaryDir/bundle") 386 | 387 | workingDir temporaryDir 388 | commandLine 'sh', "$rootDir/scripts/build-postgres-alpine.sh", '-v', "$pgVersionParam", '-i', dockerImage, '-g', postgisVersionParam, '-o', qemuBindings, "${variant.opt}" 389 | } 390 | 391 | task "customAlpine${variant.name.capitalize()}Jar"(group: 'build (custom)', type: Jar) { 392 | from tasks.getByName("buildCustomAlpine${variant.name.capitalize()}Bundle") 393 | 394 | include "postgres-linux-alpine_linux.txz" 395 | rename "postgres-linux-alpine_linux.txz", "postgres-linux-${normalizeArchName(archName)}-alpine_linux.txz" 396 | appendix = "linux-${archName}-alpine${variant.name ? '-' + variant.name : ''}" 397 | } 398 | 399 | task "testCustomAlpine${variant.name.capitalize()}Jar"(group: 'build (custom)', type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables, "customAlpine${variant.name.capitalize()}Jar"]) { 400 | def qemuBindings = { resolveQemuBindings() } 401 | def dockerImage = { dockerImageParam ?: defaultAlpineImage(archName, qemuBindings) } 402 | 403 | inputs.property('pgVersion', pgVersionParam) 404 | inputs.property('archName', archName) 405 | inputs.property('dockerImage', dockerImage) 406 | inputs.property('postgisVersion', postgisVersionParam) 407 | 408 | inputs.file("$rootDir/scripts/test-postgres-alpine.sh") 409 | 410 | workingDir tasks.getByName("customAlpine${variant.name.capitalize()}Jar").destinationDirectory 411 | commandLine 'sh', "$rootDir/scripts/test-postgres-alpine.sh", 412 | '-j', "embedded-postgres-binaries-linux-${archName}-alpine${variant.name ? '-' + variant.name : ''}-${version}.jar", 413 | '-z', "postgres-linux-${normalizeArchName(archName)}-alpine_linux.txz", 414 | '-i', dockerImage, '-v', "$pgVersionParam", '-g', postgisVersionParam, '-o', qemuBindings 415 | } 416 | 417 | artifacts.add('bundles', tasks.getByName("customAlpine${variant.name.capitalize()}Jar")) 418 | } 419 | } 420 | } 421 | 422 | subprojects { 423 | task sourcesJar(type: Jar, dependsOn: classes) { 424 | from sourceSets.main.allSource 425 | classifier = 'sources' 426 | } 427 | 428 | task javadocJar(type: Jar, dependsOn: javadoc) { 429 | from javadoc.destinationDir 430 | classifier = 'javadoc' 431 | } 432 | 433 | publishing { 434 | publications { 435 | configurations.bundles.artifacts.all { archive -> 436 | def publicationName = archive.archiveTask.name - 'Jar' 437 | "$publicationName"(MavenPublication) { 438 | artifactId "${archive.name}" 439 | configurePom(pom, artifactId, 'A lightweight bundle of PostgreSQL database with reduced size') 440 | 441 | artifact archive 442 | artifact sourcesJar 443 | artifact javadocJar 444 | } 445 | } 446 | } 447 | } 448 | } 449 | 450 | publishing { 451 | publications { 452 | if (!distNameParam && !archNameParam && !dockerImageParam) { 453 | bom(MavenPublication) { 454 | artifactId 'embedded-postgres-binaries-bom' 455 | configurePom(pom, artifactId, 'Bill of Materials') 456 | 457 | pom.withXml { 458 | def root = asNode() 459 | root.children().last() + { 460 | resolveStrategy = Closure.DELEGATE_FIRST 461 | 462 | dependencyManagement { 463 | dependencies { 464 | project.subprojects.collectMany { it.configurations.bundles.artifacts } 465 | .sort { archive -> 466 | archive.name.replaceFirst(/^embedded-postgres-binaries-([^-]+-([^-]+).*)$/, { all, suffix, arch -> 467 | ['amd64', 'i386'].indexOf(arch).with { it != -1 ? it : 9 } + suffix 468 | }) 469 | } 470 | .each { archive -> 471 | dependency { 472 | groupId "${project.group}" 473 | artifactId "${archive.name}" 474 | version "${project.version}" 475 | 476 | if (!archive.name.contains('amd64') || archive.name.contains('lite')) { 477 | optional 'true' 478 | } 479 | } 480 | } 481 | } 482 | } 483 | } 484 | } 485 | } 486 | } 487 | } 488 | } 489 | 490 | allprojects { 491 | 492 | publishing { 493 | repositories { 494 | maven { 495 | def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" 496 | def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/" 497 | url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl 498 | credentials { 499 | username ossrhUsername 500 | password ossrhPassword 501 | } 502 | } 503 | } 504 | } 505 | 506 | signing { 507 | required { gradle.taskGraph.hasTask("publish") } 508 | 509 | def signingKey = findProperty("signingKey") 510 | def signingKeyId = findProperty("signingKeyId") 511 | def signingPassword = findProperty("signingPassword") 512 | useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) 513 | 514 | publishing.publications.all { publication -> 515 | sign publication 516 | } 517 | } 518 | 519 | task install(group: 'publishing') {} 520 | 521 | configurations.bundles.artifacts.all { archive -> 522 | def publicationName = archive.archiveTask.name - 'Jar' 523 | 524 | jar.dependsOn "${archive.archiveTask.name}" 525 | test.dependsOn "test${archive.archiveTask.name.capitalize()}" 526 | install.dependsOn "publish${publicationName.capitalize()}PublicationToMavenLocal" 527 | } 528 | 529 | task uploadArchives(group: 'publishing') { 530 | dependsOn publish 531 | } 532 | 533 | tasks.whenTaskAdded { task -> 534 | if (task.name == 'publishBomPublicationToMavenLocal') { 535 | install.dependsOn task 536 | } 537 | } 538 | } 539 | 540 | def configurePom(pom, artifact, desc) { 541 | pom.withXml { 542 | def root = asNode() 543 | 544 | root.children().last() + { 545 | resolveStrategy = Closure.DELEGATE_FIRST 546 | 547 | name artifact 548 | description desc 549 | url 'https://github.com/zonkyio/embedded-postgres-binaries' 550 | 551 | scm { 552 | connection 'scm:git:git://github.com/zonkyio/embedded-postgres-binaries.git' 553 | developerConnection 'scm:git:ssh://github.com:zonkyio/embedded-postgres-binaries.git' 554 | url 'https://github.com/zonkyio/embedded-postgres-binaries/tree/master' 555 | } 556 | 557 | licenses { 558 | license { 559 | name 'The Apache License, Version 2.0' 560 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 561 | } 562 | } 563 | 564 | developers { 565 | developer { 566 | name 'Tomas Vanek' 567 | email 'tomix26@gmail.com' 568 | } 569 | developer { 570 | name 'Zonky Developers' 571 | email 'developers@zonky.cz' 572 | } 573 | } 574 | } 575 | } 576 | } 577 | 578 | def resolveQemuBindings() { 579 | def bindings = fileTree(dir:"${qemuPathParam ? qemuPathParam : '/usr/bin'}", includes:['qemu-*-static']).getFiles() 580 | if (!bindings && !qemuPathParam) { 581 | bindings = fileTree(dir:prepareQemuExecutables.destinationDir, includes:['qemu-*-static']).getFiles() 582 | } 583 | return bindings.collect { "-v ${it.path}:/usr/bin/${it.name}" }.join(' ') 584 | } 585 | 586 | static def defaultDebianImage(archName, useEmulation) { 587 | def system = OperatingSystem.current() 588 | 589 | if (archName == system.getArch()) { 590 | return 'ubuntu:18.04' 591 | } else if (system.isMacOsX() || useEmulation) { 592 | return "$archName/ubuntu:18.04" 593 | } else if (system.isLinux()) { 594 | def archMappings = ['arm32v6':'armel', 'arm32v7':'armhf', 'arm64v8':'arm64', 'ppc64le':'ppc64el'] 595 | return "multiarch/ubuntu-core:${archMappings[archName] ?: archName}-bionic" 596 | } else { 597 | throw new GradleException("Cross-building is not supported on the current platform: $system") 598 | } 599 | } 600 | 601 | static def defaultAlpineImage(archName, useEmulation) { 602 | def system = OperatingSystem.current() 603 | 604 | if (archName == system.getArch()) { 605 | return 'alpine:3.6' 606 | } else if (system.isMacOsX() || useEmulation) { 607 | return "$archName/alpine:3.6" 608 | } else if (system.isLinux()) { 609 | def archMappings = ['arm32v5':'armel', 'arm32v6':'armhf', 'arm64v8':'arm64'] 610 | return "multiarch/alpine:${archMappings[archName] ?: archName}-v3.6" 611 | } else { 612 | throw new GradleException("Cross-building is not supported on the current platform: $system") 613 | } 614 | } 615 | 616 | static def normalizeArchName(String input) { 617 | String arch = input.toLowerCase(Locale.US).replaceAll('[^a-z0-9]+', '') 618 | 619 | if (arch ==~ /^(x8664|amd64|ia32e|em64t|x64)$/) { 620 | return 'x86_64' 621 | } 622 | if (arch ==~ /^(x8632|x86|i[3-6]86|ia32|x32)$/) { 623 | return 'x86_32' 624 | } 625 | if (arch ==~ /^(ia64w?|itanium64)$/) { 626 | return 'itanium_64' 627 | } 628 | if (arch == 'ia64n') { 629 | return 'itanium_32' 630 | } 631 | if (arch ==~ /^(sparcv9|sparc64)$/) { 632 | return 'sparc_64' 633 | } 634 | if (arch ==~ /^(sparc|sparc32)$/) { 635 | return 'sparc_32' 636 | } 637 | if (arch ==~ /^(aarch64|armv8|arm64).*$/) { 638 | return 'arm_64' 639 | } 640 | if (arch ==~ /^(arm|arm32).*$/) { 641 | return 'arm_32' 642 | } 643 | if (arch ==~ /^(mips|mips32)$/) { 644 | return 'mips_32' 645 | } 646 | if (arch ==~ /^(mipsel|mips32el)$/) { 647 | return 'mipsel_32' 648 | } 649 | if (arch == 'mips64') { 650 | return 'mips_64' 651 | } 652 | if (arch == 'mips64el') { 653 | return 'mipsel_64' 654 | } 655 | if (arch ==~ /^(ppc|ppc32)$/) { 656 | return 'ppc_32' 657 | } 658 | if (arch ==~ /^(ppcle|ppc32le)$/) { 659 | return 'ppcle_32' 660 | } 661 | if (arch == 'ppc64') { 662 | return 'ppc_64' 663 | } 664 | if (arch == 'ppc64le') { 665 | return 'ppcle_64' 666 | } 667 | if (arch == 's390') { 668 | return 's390_32' 669 | } 670 | if (arch == 's390x') { 671 | return 's390_64' 672 | } 673 | 674 | throw new GradleException("Unsupported architecture: $arch") 675 | } 676 | 677 | class LazyExec extends AbstractExecTask { 678 | 679 | LazyExec() { 680 | super(LazyExec.class) 681 | } 682 | 683 | @Override 684 | LazyExec commandLine(Object... arguments) { 685 | return super.commandLine(arguments.collect { argument -> 686 | if (argument instanceof Closure) { 687 | Closure closure = (Closure) argument; 688 | return new Object() { 689 | @Override 690 | String toString() { 691 | return closure() 692 | } 693 | } 694 | } else { 695 | return argument 696 | } 697 | }) as LazyExec 698 | } 699 | } 700 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zonkyio/embedded-postgres-binaries/e2f6d440cd0f06a774d37c26dea6e606a71b8abb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=`expr $i + 1` 158 | done 159 | case $i in 160 | 0) set -- ;; 161 | 1) set -- "$args0" ;; 162 | 2) set -- "$args0" "$args1" ;; 163 | 3) set -- "$args0" "$args1" "$args2" ;; 164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=`save "$@"` 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | exec "$JAVACMD" "$@" 184 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /libs/libncursesw.6.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zonkyio/embedded-postgres-binaries/e2f6d440cd0f06a774d37c26dea6e606a71b8abb/libs/libncursesw.6.dylib -------------------------------------------------------------------------------- /scripts/build-postgres-alpine.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | DOCKER_OPTS= 5 | POSTGIS_VERSION= 6 | LITE_OPT=false 7 | 8 | while getopts "v:i:g:o:l" opt; do 9 | case $opt in 10 | v) PG_VERSION=$OPTARG ;; 11 | i) IMG_NAME=$OPTARG ;; 12 | g) POSTGIS_VERSION=$OPTARG ;; 13 | o) DOCKER_OPTS=$OPTARG ;; 14 | l) LITE_OPT=true ;; 15 | \?) exit 1 ;; 16 | esac 17 | done 18 | 19 | if [ -z "$PG_VERSION" ] ; then 20 | echo "Postgres version parameter is required!" && exit 1; 21 | fi 22 | if [ -z "$IMG_NAME" ] ; then 23 | echo "Docker image parameter is required!" && exit 1; 24 | fi 25 | if echo "$PG_VERSION" | grep -q '^9\.' && [ "$LITE_OPT" = true ] ; then 26 | echo "Lite option is supported only for PostgreSQL 10 or later!" && exit 1; 27 | fi 28 | 29 | E2FS_ENABLED=$(echo "$PG_VERSION" | grep -qv '^9\.[0-3]\.' && echo true || echo false); 30 | ICU_ENABLED=$(echo "$PG_VERSION" | grep -qv '^9\.' && [ "$LITE_OPT" != true ] && echo true || echo false); 31 | 32 | TRG_DIR=$PWD/bundle 33 | mkdir -p $TRG_DIR 34 | 35 | docker run -i --rm -v ${TRG_DIR}:/usr/local/pg-dist \ 36 | -e PG_VERSION=$PG_VERSION \ 37 | -e POSTGIS_VERSION=$POSTGIS_VERSION \ 38 | -e E2FS_ENABLED=$E2FS_ENABLED \ 39 | -e ICU_ENABLED=$ICU_ENABLED \ 40 | -e PROJ_VERSION=6.0.0 \ 41 | -e PROJ_DATUMGRID_VERSION=1.8 \ 42 | -e GEOS_VERSION=3.7.2 \ 43 | -e GDAL_VERSION=2.4.1 \ 44 | $DOCKER_OPTS $IMG_NAME /bin/sh -ex -c 'echo "Starting building postgres binaries" \ 45 | && apk add --no-cache \ 46 | coreutils \ 47 | ca-certificates \ 48 | wget \ 49 | tar \ 50 | xz \ 51 | gcc \ 52 | make \ 53 | libc-dev \ 54 | icu-dev \ 55 | linux-headers \ 56 | util-linux-dev \ 57 | libxml2-dev \ 58 | libxslt-dev \ 59 | openssl-dev \ 60 | zlib-dev \ 61 | perl-dev \ 62 | python3-dev \ 63 | tcl-dev \ 64 | chrpath \ 65 | flex \ 66 | bison \ 67 | \ 68 | && if [ "$E2FS_ENABLED" = false ]; then \ 69 | wget -O uuid.tar.gz "https://www.mirrorservice.org/sites/ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz" \ 70 | && mkdir -p /usr/src/ossp-uuid \ 71 | && tar -xf uuid.tar.gz -C /usr/src/ossp-uuid --strip-components 1 \ 72 | && cd /usr/src/ossp-uuid \ 73 | && wget -O config.guess "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/8de5d272823855dd8d81fee50418f4ebf7e79ed9/config.guess" \ 74 | && wget -O config.sub "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/b8ee5f79949d1d40e8820a774d813660e1be52d3/config.sub" \ 75 | && ./configure --prefix=/usr/local \ 76 | && make -j$(nproc) \ 77 | && make install \ 78 | && cp --no-dereference /usr/local/lib/libuuid.* /lib; \ 79 | fi \ 80 | \ 81 | && wget -O postgresql.tar.bz2 "https://ftp.postgresql.org/pub/source/v$PG_VERSION/postgresql-$PG_VERSION.tar.bz2" \ 82 | && mkdir -p /usr/src/postgresql \ 83 | && tar -xf postgresql.tar.bz2 -C /usr/src/postgresql --strip-components 1 \ 84 | && cd /usr/src/postgresql \ 85 | && wget -O config/config.guess "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/8de5d272823855dd8d81fee50418f4ebf7e79ed9/config.guess" \ 86 | && wget -O config/config.sub "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/b8ee5f79949d1d40e8820a774d813660e1be52d3/config.sub" \ 87 | && ./configure \ 88 | CFLAGS="-Os" \ 89 | PYTHON=/usr/bin/python3 \ 90 | --prefix=/usr/local/pg-build \ 91 | --enable-integer-datetimes \ 92 | --enable-thread-safety \ 93 | $([ "$E2FS_ENABLED" = true ] && echo "--with-uuid=e2fs" || echo "--with-ossp-uuid") \ 94 | --with-gnu-ld \ 95 | --with-includes=/usr/local/include \ 96 | --with-libraries=/usr/local/lib \ 97 | $([ "$ICU_ENABLED" = true ] && echo "--with-icu") \ 98 | --with-libxml \ 99 | --with-libxslt \ 100 | --with-openssl \ 101 | --with-perl \ 102 | --with-python \ 103 | --with-tcl \ 104 | --without-readline \ 105 | && make -j$(nproc) world-bin \ 106 | && make install-world-bin \ 107 | && make -C contrib install \ 108 | \ 109 | && if [ -n "$POSTGIS_VERSION" ]; then \ 110 | apk add --no-cache curl g++ json-c-dev linux-headers sqlite sqlite-dev sqlite-libs unzip \ 111 | && mkdir -p /usr/src/proj \ 112 | && curl -sL "https://download.osgeo.org/proj/proj-$PROJ_VERSION.tar.gz" | tar -xzf - -C /usr/src/proj --strip-components 1 \ 113 | && cd /usr/src/proj \ 114 | && curl -sL "https://download.osgeo.org/proj/proj-datumgrid-$PROJ_DATUMGRID_VERSION.zip" > proj-datumgrid.zip \ 115 | && unzip -o proj-datumgrid.zip -d data\ 116 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/8de5d272823855dd8d81fee50418f4ebf7e79ed9/config.guess" > config.guess \ 117 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/b8ee5f79949d1d40e8820a774d813660e1be52d3/config.sub" > config.sub \ 118 | && ./configure --disable-static --prefix=/usr/local/pg-build \ 119 | && make -j$(nproc) \ 120 | && make install \ 121 | && mkdir -p /usr/src/geos \ 122 | && curl -sL "https://download.osgeo.org/geos/geos-$GEOS_VERSION.tar.bz2" | tar -xjf - -C /usr/src/geos --strip-components 1 \ 123 | && cd /usr/src/geos \ 124 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/8de5d272823855dd8d81fee50418f4ebf7e79ed9/config.guess" > config.guess \ 125 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/b8ee5f79949d1d40e8820a774d813660e1be52d3/config.sub" > config.sub \ 126 | && ./configure --disable-static --prefix=/usr/local/pg-build \ 127 | && make -j$(nproc) \ 128 | && make install \ 129 | && mkdir -p /usr/src/gdal \ 130 | && curl -sL "https://download.osgeo.org/gdal/$GDAL_VERSION/gdal-$GDAL_VERSION.tar.xz" | tar -xJf - -C /usr/src/gdal --strip-components 1 \ 131 | && cd /usr/src/gdal \ 132 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/8de5d272823855dd8d81fee50418f4ebf7e79ed9/config.guess" > config.guess \ 133 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/b8ee5f79949d1d40e8820a774d813660e1be52d3/config.sub" > config.sub \ 134 | && ./configure --disable-static --prefix=/usr/local/pg-build \ 135 | && make -j$(nproc) \ 136 | && make install \ 137 | && mkdir -p /usr/src/postgis \ 138 | && curl -sL "https://postgis.net/stuff/postgis-$POSTGIS_VERSION.tar.gz" | tar -xzf - -C /usr/src/postgis --strip-components 1 \ 139 | && cd /usr/src/postgis \ 140 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/8de5d272823855dd8d81fee50418f4ebf7e79ed9/config.guess" > config.guess \ 141 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/b8ee5f79949d1d40e8820a774d813660e1be52d3/config.sub" > config.sub \ 142 | && ./configure \ 143 | --prefix=/usr/local/pg-build \ 144 | --with-pgconfig=/usr/local/pg-build/bin/pg_config \ 145 | --with-geosconfig=/usr/local/pg-build/bin/geos-config \ 146 | --with-projdir=/usr/local/pg-build \ 147 | --with-gdalconfig=/usr/local/pg-build/bin/gdal-config \ 148 | && make -j$(nproc) \ 149 | && make install \ 150 | ; fi \ 151 | \ 152 | && cd /usr/local/pg-build \ 153 | && cp /lib/libuuid.so.1 /lib/libz.so.1 /lib/libssl.so.1.0.0 /lib/libcrypto.so.1.0.0 /usr/lib/libxml2.so.2 /usr/lib/libxslt.so.1 ./lib \ 154 | && if [ "$ICU_ENABLED" = true ]; then cp --no-dereference /usr/lib/libicudata.so* /usr/lib/libicuuc.so* /usr/lib/libicui18n.so* /usr/lib/libstdc++.so* /usr/lib/libgcc_s.so* ./lib; fi \ 155 | && if [ -n "$POSTGIS_VERSION" ]; then cp --no-dereference /usr/lib/libjson-c.so* /usr/lib/libsqlite3.so* ./lib ; fi \ 156 | && find ./bin -type f \( -name "initdb" -o -name "pg_ctl" -o -name "postgres" \) -print0 | xargs -0 -n1 chrpath -r "\$ORIGIN/../lib" \ 157 | && tar -cJvf /usr/local/pg-dist/postgres-linux-alpine_linux.txz --hard-dereference \ 158 | share/postgresql \ 159 | lib \ 160 | bin/initdb \ 161 | bin/pg_ctl \ 162 | bin/postgres' -------------------------------------------------------------------------------- /scripts/build-postgres-debian.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | DOCKER_OPTS= 5 | POSTGIS_VERSION= 6 | LITE_OPT=false 7 | 8 | while getopts "v:i:g:o:l" opt; do 9 | case $opt in 10 | v) PG_VERSION=$OPTARG ;; 11 | i) IMG_NAME=$OPTARG ;; 12 | g) POSTGIS_VERSION=$OPTARG ;; 13 | o) DOCKER_OPTS=$OPTARG ;; 14 | l) LITE_OPT=true ;; 15 | \?) exit 1 ;; 16 | esac 17 | done 18 | 19 | if [ -z "$PG_VERSION" ] ; then 20 | echo "Postgres version parameter is required!" && exit 1; 21 | fi 22 | if [ -z "$IMG_NAME" ] ; then 23 | echo "Docker image parameter is required!" && exit 1; 24 | fi 25 | if echo "$PG_VERSION" | grep -q '^9\.' && [ "$LITE_OPT" = true ] ; then 26 | echo "Lite option is supported only for PostgreSQL 10 or later!" && exit 1; 27 | fi 28 | 29 | ICU_ENABLED=$(echo "$PG_VERSION" | grep -qv '^9\.' && [ "$LITE_OPT" != true ] && echo true || echo false); 30 | 31 | TRG_DIR=$PWD/bundle 32 | mkdir -p $TRG_DIR 33 | 34 | docker run -i --rm -v ${TRG_DIR}:/usr/local/pg-dist \ 35 | -e PG_VERSION=$PG_VERSION \ 36 | -e POSTGIS_VERSION=$POSTGIS_VERSION \ 37 | -e ICU_ENABLED=$ICU_ENABLED \ 38 | -e PROJ_VERSION=6.0.0 \ 39 | -e PROJ_DATUMGRID_VERSION=1.8 \ 40 | -e GEOS_VERSION=3.7.2 \ 41 | -e GDAL_VERSION=2.4.1 \ 42 | $DOCKER_OPTS $IMG_NAME /bin/bash -ex -c 'echo "Starting building postgres binaries" \ 43 | && ln -snf /usr/share/zoneinfo/Etc/UTC /etc/localtime && echo "Etc/UTC" > /etc/timezone \ 44 | && apt-get update && apt-get install -y --no-install-recommends \ 45 | ca-certificates \ 46 | wget \ 47 | bzip2 \ 48 | xz-utils \ 49 | gcc \ 50 | g++ \ 51 | make \ 52 | pkg-config \ 53 | libc-dev \ 54 | libicu-dev \ 55 | libossp-uuid-dev \ 56 | libxml2-dev \ 57 | libxslt1-dev \ 58 | libssl-dev \ 59 | libz-dev \ 60 | libperl-dev \ 61 | python3-dev \ 62 | tcl-dev \ 63 | flex \ 64 | bison \ 65 | \ 66 | && wget -O patchelf.tar.gz "https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.gz" \ 67 | && mkdir -p /usr/src/patchelf \ 68 | && tar -xf patchelf.tar.gz -C /usr/src/patchelf --strip-components 1 \ 69 | && cd /usr/src/patchelf \ 70 | && wget -O config.guess "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/8de5d272823855dd8d81fee50418f4ebf7e79ed9/config.guess" \ 71 | && wget -O config.sub "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/b8ee5f79949d1d40e8820a774d813660e1be52d3/config.sub" \ 72 | && ./configure --prefix=/usr/local \ 73 | && make -j$(nproc) \ 74 | && make install \ 75 | \ 76 | && wget -O postgresql.tar.bz2 "https://ftp.postgresql.org/pub/source/v$PG_VERSION/postgresql-$PG_VERSION.tar.bz2" \ 77 | && mkdir -p /usr/src/postgresql \ 78 | && tar -xf postgresql.tar.bz2 -C /usr/src/postgresql --strip-components 1 \ 79 | && cd /usr/src/postgresql \ 80 | && wget -O config/config.guess "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/8de5d272823855dd8d81fee50418f4ebf7e79ed9/config.guess" \ 81 | && wget -O config/config.sub "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/b8ee5f79949d1d40e8820a774d813660e1be52d3/config.sub" \ 82 | && ./configure \ 83 | CFLAGS="-Os -DMAP_HUGETLB=0x40000" \ 84 | PYTHON=/usr/bin/python3 \ 85 | --prefix=/usr/local/pg-build \ 86 | --enable-integer-datetimes \ 87 | --enable-thread-safety \ 88 | --with-ossp-uuid \ 89 | $([ "$ICU_ENABLED" = true ] && echo "--with-icu") \ 90 | --with-libxml \ 91 | --with-libxslt \ 92 | --with-openssl \ 93 | --with-perl \ 94 | --with-python \ 95 | --with-tcl \ 96 | --without-readline \ 97 | && make -j$(nproc) world-bin \ 98 | && make install-world-bin \ 99 | && make -C contrib install \ 100 | \ 101 | && if [ -n "$POSTGIS_VERSION" ]; then \ 102 | apt-get install -y --no-install-recommends curl libjson-c-dev libsqlite3-0 libsqlite3-dev sqlite3 unzip \ 103 | && mkdir -p /usr/src/proj \ 104 | && curl -sL "https://download.osgeo.org/proj/proj-$PROJ_VERSION.tar.gz" | tar -xzf - -C /usr/src/proj --strip-components 1 \ 105 | && cd /usr/src/proj \ 106 | && curl -sL "https://download.osgeo.org/proj/proj-datumgrid-$PROJ_DATUMGRID_VERSION.zip" > proj-datumgrid.zip \ 107 | && unzip -o proj-datumgrid.zip -d data\ 108 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/8de5d272823855dd8d81fee50418f4ebf7e79ed9/config.guess" > config.guess \ 109 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/b8ee5f79949d1d40e8820a774d813660e1be52d3/config.sub" > config.sub \ 110 | && ./configure --disable-static --prefix=/usr/local/pg-build \ 111 | && make -j$(nproc) \ 112 | && make install \ 113 | && mkdir -p /usr/src/geos \ 114 | && curl -sL "https://download.osgeo.org/geos/geos-$GEOS_VERSION.tar.bz2" | tar -xjf - -C /usr/src/geos --strip-components 1 \ 115 | && cd /usr/src/geos \ 116 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/8de5d272823855dd8d81fee50418f4ebf7e79ed9/config.guess" > config.guess \ 117 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/b8ee5f79949d1d40e8820a774d813660e1be52d3/config.sub" > config.sub \ 118 | && ./configure --disable-static --prefix=/usr/local/pg-build \ 119 | && make -j$(nproc) \ 120 | && make install \ 121 | && mkdir -p /usr/src/gdal \ 122 | && curl -sL "https://download.osgeo.org/gdal/$GDAL_VERSION/gdal-$GDAL_VERSION.tar.xz" | tar -xJf - -C /usr/src/gdal --strip-components 1 \ 123 | && cd /usr/src/gdal \ 124 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/8de5d272823855dd8d81fee50418f4ebf7e79ed9/config.guess" > config.guess \ 125 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/b8ee5f79949d1d40e8820a774d813660e1be52d3/config.sub" > config.sub \ 126 | && ./configure --disable-static --prefix=/usr/local/pg-build \ 127 | && make -j$(nproc) \ 128 | && make install \ 129 | && mkdir -p /usr/src/postgis \ 130 | && curl -sL "https://postgis.net/stuff/postgis-$POSTGIS_VERSION.tar.gz" | tar -xzf - -C /usr/src/postgis --strip-components 1 \ 131 | && cd /usr/src/postgis \ 132 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/8de5d272823855dd8d81fee50418f4ebf7e79ed9/config.guess" > config.guess \ 133 | && curl -sL "https://gitlab.com/freedesktop-sdk/mirrors/savannah/config/-/raw/b8ee5f79949d1d40e8820a774d813660e1be52d3/config.sub" > config.sub \ 134 | && ./configure \ 135 | --prefix=/usr/local/pg-build \ 136 | --with-pgconfig=/usr/local/pg-build/bin/pg_config \ 137 | --with-geosconfig=/usr/local/pg-build/bin/geos-config \ 138 | --with-projdir=/usr/local/pg-build \ 139 | --with-gdalconfig=/usr/local/pg-build/bin/gdal-config \ 140 | && make -j$(nproc) \ 141 | && make install \ 142 | ; fi \ 143 | \ 144 | && cd /usr/local/pg-build \ 145 | && cp /usr/lib/libossp-uuid.so.16 ./lib || cp /usr/lib/*/libossp-uuid.so.16 ./lib \ 146 | && cp /lib/*/libz.so.1 /lib/*/liblzma.so.5 /usr/lib/*/libxml2.so.2 /usr/lib/*/libxslt.so.1 ./lib \ 147 | && cp /lib/*/libssl.so.1* /lib/*/libcrypto.so.1* ./lib || cp /usr/lib/*/libssl.so.1* /usr/lib/*/libcrypto.so.1* ./lib \ 148 | && if [ "$ICU_ENABLED" = true ]; then cp --no-dereference /usr/lib/*/libicudata.so* /usr/lib/*/libicuuc.so* /usr/lib/*/libicui18n.so* ./lib; fi \ 149 | && if [ -n "$POSTGIS_VERSION" ]; then cp --no-dereference /lib/*/libjson-c.so* /usr/lib/*/libsqlite3.so* ./lib ; fi \ 150 | && find ./bin -type f \( -name "initdb" -o -name "pg_ctl" -o -name "postgres" \) -print0 | xargs -0 -n1 patchelf --set-rpath "\$ORIGIN/../lib" \ 151 | && find ./lib -maxdepth 1 -type f -name "*.so*" -print0 | xargs -0 -n1 patchelf --set-rpath "\$ORIGIN" \ 152 | && find ./lib/postgresql -maxdepth 1 -type f -name "*.so*" -print0 | xargs -0 -n1 patchelf --set-rpath "\$ORIGIN/.." \ 153 | && tar -cJvf /usr/local/pg-dist/postgres-linux-debian.txz --hard-dereference \ 154 | share/postgresql \ 155 | lib \ 156 | bin/initdb \ 157 | bin/pg_ctl \ 158 | bin/postgres' 159 | -------------------------------------------------------------------------------- /scripts/repack-postgres.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | ARCH_NAME=amd64 5 | 6 | while getopts "v:p:a:" opt; do 7 | case $opt in 8 | v) PG_VERSION=$OPTARG ;; 9 | p) PLATFORM_NAME=$OPTARG ;; 10 | a) ARCH_NAME=$OPTARG ;; 11 | \?) exit 1 ;; 12 | esac 13 | done 14 | 15 | if [ -z "$PG_VERSION" ] ; then 16 | echo "Postgres version parameter is required!" && exit 1; 17 | fi 18 | if [ "$PLATFORM_NAME" != "darwin" ] && [ "$PLATFORM_NAME" != "windows" ] && [ "$PLATFORM_NAME" != "linux" ] ; then 19 | echo "Platform $PLATFORM_NAME is not supported!" && exit 1; 20 | fi 21 | if [ "$ARCH_NAME" != "amd64" ] && [ "$ARCH_NAME" != "i386" ] && [ "$ARCH_NAME" != "arm64v8" ] ; then 22 | echo "Architecture $ARCH_NAME is not supported!" && exit 1; 23 | fi 24 | if [ "$PLATFORM_NAME" = "darwin" ] && [ "$ARCH_NAME" = "i386" ] ; then 25 | echo "Darwin platform supports only amd64 or arm64v8 architecture!" && exit 1; 26 | fi 27 | 28 | 29 | FILE_NAME="postgresql-$PG_VERSION" 30 | 31 | if [ "$PLATFORM_NAME" = "darwin" ] ; then 32 | FILE_NAME="$FILE_NAME-osx" 33 | else 34 | FILE_NAME="$FILE_NAME-$PLATFORM_NAME" 35 | fi 36 | 37 | if [ "$ARCH_NAME" = "amd64" ] && [ "$PLATFORM_NAME" != "darwin" ] ; then 38 | FILE_NAME="$FILE_NAME-x64-binaries" 39 | else 40 | FILE_NAME="$FILE_NAME-binaries" 41 | fi 42 | 43 | if [ "$PLATFORM_NAME" = "linux" ] ; then 44 | FILE_NAME="$FILE_NAME.tar.gz" 45 | else 46 | FILE_NAME="$FILE_NAME.zip" 47 | fi 48 | 49 | if [ "$ARCH_NAME" = "amd64" ] ; then 50 | NORM_ARCH_NAME="x86_64" 51 | elif [ "$ARCH_NAME" = "arm64v8" ] ; then 52 | NORM_ARCH_NAME="arm_64" 53 | else 54 | NORM_ARCH_NAME="x86_32" 55 | fi 56 | 57 | 58 | DIST_DIR=$PWD/dist 59 | PKG_DIR=$PWD/package 60 | TRG_DIR=$PWD/bundle 61 | DIST_FILE=$DIST_DIR/$FILE_NAME 62 | 63 | 64 | mkdir -p $DIST_DIR $TRG_DIR 65 | 66 | [ -e $DIST_FILE ] || wget -O $DIST_FILE "https://get.enterprisedb.com/postgresql/$FILE_NAME" 67 | 68 | rm -rf $PKG_DIR && mkdir -p $PKG_DIR 69 | 70 | if [ "$PLATFORM_NAME" = "linux" ] ; then 71 | tar -xzf $DIST_FILE -C $PKG_DIR 72 | else 73 | unzip -q -d $PKG_DIR $DIST_FILE 74 | fi 75 | 76 | cd $PKG_DIR/pgsql 77 | 78 | 79 | if [ "$PLATFORM_NAME" = "darwin" ] ; then 80 | 81 | if [ "$PG_VERSION" = "13.5-1" ] || [ "$PG_VERSION" = "13.6-1" ] || [ "$PG_VERSION" = "13.7-1" ] || [ "$PG_VERSION" = "13.8-1" ] || [ "$PG_VERSION" = "13.9-1" ] ; then 82 | mkdir -p ./opt/local/lib 83 | cp $PKG_DIR/../../../../../libs/libncursesw.6.dylib ./lib/ 84 | ln -s ../../../lib/libncursesw.6.dylib ./opt/local/lib/libncurses.6.dylib 85 | fi 86 | 87 | tar -cJvf $TRG_DIR/postgres-darwin-$NORM_ARCH_NAME.txz \ 88 | share/postgresql \ 89 | $([ -f lib/libiconv.2.dylib ] && echo lib/libiconv.2.dylib || echo ) \ 90 | $([ -f lib/libicudata.dylib ] && echo lib/libicudata*.dylib lib/libicui18n*.dylib lib/libicuuc*.dylib || echo ) \ 91 | $([ -f lib/libncursesw.6.dylib ] && echo lib/libncurses*.dylib || echo ) \ 92 | $([ -f lib/liblz4.dylib ] && echo lib/liblz*.dylib || echo ) \ 93 | $([ -f lib/libgssapi_krb5.dylib ] && echo lib/libgssapi_krb5.*.*.dylib || echo ) \ 94 | $([ -f lib/libkrb5.dylib ] && echo lib/libkrb5.*.*.dylib || echo ) \ 95 | $([ -f lib/libkrb5support.dylib ] && echo lib/libkrb5support.*.*.dylib || echo ) \ 96 | $([ -f lib/libk5crypto.dylib ] && echo lib/libk5crypto.*.*.dylib || echo ) \ 97 | $([ -f lib/libcom_err.dylib ] && echo lib/libcom_err.*.*.dylib || echo ) \ 98 | $([ -f lib/libintl.dylib ] && echo lib/libintl.*.dylib || echo ) \ 99 | $([ -f opt/local/lib/libncurses.6.dylib ] && echo opt || echo ) \ 100 | lib/libz*.dylib \ 101 | lib/libpq*.dylib \ 102 | lib/libuuid*.dylib \ 103 | lib/libxml2*.dylib \ 104 | lib/libssl*.dylib \ 105 | lib/libcrypto*.dylib \ 106 | lib/libedit*.dylib \ 107 | lib/postgresql/*.* \ 108 | bin/initdb \ 109 | bin/pg_ctl \ 110 | bin/postgres 111 | 112 | elif [ "$PLATFORM_NAME" = "windows" ] ; then 113 | 114 | tar -cJvf $TRG_DIR/postgres-windows-$NORM_ARCH_NAME.txz \ 115 | share \ 116 | lib/iconv.lib \ 117 | lib/libxml2.lib \ 118 | $([ -f lib/ssleay32.lib ] && echo lib/ssleay32.lib lib/ssleay32MD.lib || echo lib/libssl.lib lib/libcrypto.lib) \ 119 | lib/*.dll \ 120 | bin/initdb.exe \ 121 | bin/pg_ctl.exe \ 122 | bin/postgres.exe \ 123 | bin/*.dll 124 | 125 | elif [ "$PLATFORM_NAME" = "linux" ] ; then 126 | 127 | tar -cJvf $TRG_DIR/postgres-linux-$NORM_ARCH_NAME.txz \ 128 | share/postgresql \ 129 | lib \ 130 | bin/initdb \ 131 | bin/pg_ctl \ 132 | bin/postgres 133 | 134 | fi -------------------------------------------------------------------------------- /scripts/test-postgres-alpine.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | DOCKER_OPTS= 5 | POSTGIS_VERSION= 6 | 7 | while getopts "j:z:i:v:g:o:" opt; do 8 | case $opt in 9 | j) JAR_FILE=$OPTARG ;; 10 | z) ZIP_FILE=$OPTARG ;; 11 | i) IMG_NAME=$OPTARG ;; 12 | v) PG_VERSION=$OPTARG ;; 13 | g) POSTGIS_VERSION=$OPTARG ;; 14 | o) DOCKER_OPTS=$OPTARG ;; 15 | \?) exit 1 ;; 16 | esac 17 | done 18 | 19 | if [ -z "$JAR_FILE" ] ; then 20 | echo "Jar file parameter is required!" && exit 1; 21 | fi 22 | if [ -z "$ZIP_FILE" ] ; then 23 | echo "Zip file parameter is required!" && exit 1; 24 | fi 25 | if [ -z "$PG_VERSION" ] ; then 26 | echo "Postgres version parameter is required!" && exit 1; 27 | fi 28 | if [ -z "$IMG_NAME" ] ; then 29 | echo "Docker image parameter is required!" && exit 1; 30 | fi 31 | 32 | LIB_DIR=$PWD 33 | 34 | docker run -i --rm -v ${LIB_DIR}:/usr/local/pg-lib:ro \ 35 | -e JAR_FILE=$JAR_FILE \ 36 | -e ZIP_FILE=$ZIP_FILE \ 37 | -e PG_VERSION=$PG_VERSION \ 38 | -e POSTGIS_VERSION=$POSTGIS_VERSION \ 39 | $DOCKER_OPTS $IMG_NAME /bin/sh -ex -c 'echo "Starting building postgres binaries" \ 40 | && apk add --no-cache \ 41 | postgresql-client \ 42 | tar \ 43 | xz \ 44 | unzip \ 45 | \ 46 | && addgroup -S -g 1000 test \ 47 | && adduser -D -S -G test -u 1000 -s /bin/ash test \ 48 | \ 49 | && mkdir -p /usr/local/pg-dist \ 50 | && unzip -q -d /usr/local/pg-dist /usr/local/pg-lib/$JAR_FILE \ 51 | \ 52 | && mkdir -p /usr/local/pg-test/data \ 53 | && tar -xJf /usr/local/pg-dist/$ZIP_FILE -C /usr/local/pg-test \ 54 | && chown test:test /usr/local/pg-test/data \ 55 | \ 56 | && su test -c '\''/usr/local/pg-test/bin/initdb -A trust -U postgres -D /usr/local/pg-test/data -E UTF-8'\'' \ 57 | && su test -c '\''/usr/local/pg-test/bin/pg_ctl -w -D /usr/local/pg-test/data -o "-p 65432 -F -c timezone=UTC -c synchronous_commit=off -c max_connections=300" start'\'' \ 58 | \ 59 | && test $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c "SHOW SERVER_VERSION") = $PG_VERSION \ 60 | && test $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c "CREATE EXTENSION pgcrypto; SELECT digest('\''test'\'', '\''sha256'\'');") = "\x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" \ 61 | && echo $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c '\''CREATE EXTENSION "uuid-ossp"; SELECT uuid_generate_v4();'\'') | grep -E '\''^[^-]{8}-[^-]{4}-[^-]{4}-[^-]{4}-[^-]{12}$'\'' \ 62 | \ 63 | && if echo "$PG_VERSION" | grep -qvE '\''^(10|9)\.'\'' ; then test $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c '\''SET jit_above_cost = 10; SELECT SUM(relpages) FROM pg_class;'\'') -gt 0 ; fi \ 64 | \ 65 | && if [ -n "$POSTGIS_VERSION" ]; then test $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c "CREATE EXTENSION postgis; SELECT PostGIS_Lib_Version();") = $POSTGIS_VERSION ; fi' -------------------------------------------------------------------------------- /scripts/test-postgres-darwin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | while getopts "j:z:v:" opt; do 5 | case $opt in 6 | j) JAR_FILE=$OPTARG ;; 7 | z) ZIP_FILE=$OPTARG ;; 8 | v) PG_VERSION=$OPTARG ;; 9 | \?) exit 1 ;; 10 | esac 11 | done 12 | 13 | if [ -z "$JAR_FILE" ] ; then 14 | echo "Jar file parameter is required!" && exit 1; 15 | fi 16 | if [ -z "$ZIP_FILE" ] ; then 17 | echo "Zip file parameter is required!" && exit 1; 18 | fi 19 | if [ -z "$PG_VERSION" ] ; then 20 | echo "Postgres version parameter is required!" && exit 1; 21 | fi 22 | 23 | LIB_DIR=$PWD 24 | TRG_DIR=$(mktemp -d) 25 | 26 | mkdir -p $TRG_DIR/pg-dist 27 | unzip -q -d $TRG_DIR/pg-dist $LIB_DIR/$JAR_FILE 28 | 29 | mkdir -p $TRG_DIR/pg-test/data 30 | tar -xJf $TRG_DIR/pg-dist/$ZIP_FILE -C $TRG_DIR/pg-test 31 | 32 | $TRG_DIR/pg-test/bin/initdb -A trust -U postgres -D $TRG_DIR/pg-test/data -E UTF-8 33 | $TRG_DIR/pg-test/bin/pg_ctl -w -D $TRG_DIR/pg-test/data -o '-p 65432 -F -c timezone=UTC -c synchronous_commit=off -c max_connections=300' start 34 | 35 | # Shutdown DB server and do cleanup on exit 36 | function cleanup() { 37 | local errcode=$? 38 | $TRG_DIR/pg-test/bin/pg_ctl -w -D $TRG_DIR/pg-test/data stop 39 | rm -rf $TRG_DIR 40 | return $errcode 41 | } 42 | 43 | trap cleanup EXIT 44 | 45 | test $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c "SHOW SERVER_VERSION") = $PG_VERSION 46 | test $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c "CREATE EXTENSION pgcrypto; SELECT digest('test', 'sha256');") = "\x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" 47 | echo $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c 'CREATE EXTENSION "uuid-ossp"; SELECT uuid_generate_v4();') | grep -E '^[^-]{8}-[^-]{4}-[^-]{4}-[^-]{4}-[^-]{12}$' 48 | 49 | if echo "$PG_VERSION" | grep -qvE '^(10|9)\.' ; then 50 | count=$(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c 'SET jit_above_cost = 10; SELECT SUM(relpages) FROM pg_class;') 51 | test $count -gt 0 52 | fi 53 | -------------------------------------------------------------------------------- /scripts/test-postgres-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | DOCKER_OPTS= 5 | POSTGIS_VERSION= 6 | 7 | while getopts "j:z:i:v:g:o:" opt; do 8 | case $opt in 9 | j) JAR_FILE=$OPTARG ;; 10 | z) ZIP_FILE=$OPTARG ;; 11 | i) IMG_NAME=$OPTARG ;; 12 | v) PG_VERSION=$OPTARG ;; 13 | g) POSTGIS_VERSION=$OPTARG ;; 14 | o) DOCKER_OPTS=$OPTARG ;; 15 | \?) exit 1 ;; 16 | esac 17 | done 18 | 19 | if [ -z "$JAR_FILE" ] ; then 20 | echo "Jar file parameter is required!" && exit 1; 21 | fi 22 | if [ -z "$ZIP_FILE" ] ; then 23 | echo "Zip file parameter is required!" && exit 1; 24 | fi 25 | if [ -z "$PG_VERSION" ] ; then 26 | echo "Postgres version parameter is required!" && exit 1; 27 | fi 28 | if [ -z "$IMG_NAME" ] ; then 29 | echo "Docker image parameter is required!" && exit 1; 30 | fi 31 | 32 | LIB_DIR=$PWD 33 | 34 | docker run -i --rm -v ${LIB_DIR}:/usr/local/pg-lib:ro \ 35 | -e JAR_FILE=$JAR_FILE \ 36 | -e ZIP_FILE=$ZIP_FILE \ 37 | -e PG_VERSION=$PG_VERSION \ 38 | -e POSTGIS_VERSION=$POSTGIS_VERSION \ 39 | $DOCKER_OPTS $IMG_NAME /bin/bash -ex -c 'echo "Starting testing postgres binaries" \ 40 | && apt-get update && apt-get install -y --no-install-recommends \ 41 | postgresql-client \ 42 | xz-utils \ 43 | unzip \ 44 | \ 45 | && groupadd --system --gid 1000 test \ 46 | && useradd --system --gid test --uid 1000 --shell /bin/bash --create-home test \ 47 | \ 48 | && mkdir -p /usr/local/pg-dist \ 49 | && unzip -q -d /usr/local/pg-dist /usr/local/pg-lib/$JAR_FILE \ 50 | \ 51 | && mkdir -p /usr/local/pg-test/data \ 52 | && tar -xJf /usr/local/pg-dist/$ZIP_FILE -C /usr/local/pg-test \ 53 | && chown test:test /usr/local/pg-test/data \ 54 | \ 55 | && su test -c '\''/usr/local/pg-test/bin/initdb -A trust -U postgres -D /usr/local/pg-test/data -E UTF-8'\'' \ 56 | && su test -c '\''/usr/local/pg-test/bin/pg_ctl -w -D /usr/local/pg-test/data -o "-p 65432 -F -c timezone=UTC -c synchronous_commit=off -c max_connections=300" start'\'' \ 57 | \ 58 | && test $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c "SHOW SERVER_VERSION") = $PG_VERSION \ 59 | && test $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c "CREATE EXTENSION pgcrypto; SELECT digest('\''test'\'', '\''sha256'\'');") = "\x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" \ 60 | && echo $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c '\''CREATE EXTENSION "uuid-ossp"; SELECT uuid_generate_v4();'\'') | grep -E '\''^[^-]{8}-[^-]{4}-[^-]{4}-[^-]{4}-[^-]{12}$'\'' \ 61 | \ 62 | && if echo "$PG_VERSION" | grep -qvE '\''^(10|9)\.'\'' ; then test $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c '\''SET jit_above_cost = 10; SELECT SUM(relpages) FROM pg_class;'\'') -gt 0 ; fi \ 63 | \ 64 | && if [ -n "$POSTGIS_VERSION" ]; then test $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c "CREATE EXTENSION postgis; SELECT PostGIS_Lib_Version();") = $POSTGIS_VERSION ; fi' -------------------------------------------------------------------------------- /scripts/test-postgres-windows.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | while getopts "j:z:v:" opt; do 5 | case $opt in 6 | j) JAR_FILE=$OPTARG ;; 7 | z) ZIP_FILE=$OPTARG ;; 8 | v) PG_VERSION=$OPTARG ;; 9 | \?) exit 1 ;; 10 | esac 11 | done 12 | 13 | if [ -z "$JAR_FILE" ] ; then 14 | echo "Jar file parameter is required!" && exit 1; 15 | fi 16 | if [ -z "$ZIP_FILE" ] ; then 17 | echo "Zip file parameter is required!" && exit 1; 18 | fi 19 | if [ -z "$PG_VERSION" ] ; then 20 | echo "Postgres version parameter is required!" && exit 1; 21 | fi 22 | 23 | LIB_DIR=$PWD 24 | TRG_DIR=$(mktemp -d) 25 | 26 | mkdir -p $TRG_DIR/pg-dist 27 | unzip -q -d $TRG_DIR/pg-dist $LIB_DIR/$JAR_FILE 28 | 29 | mkdir -p $TRG_DIR/pg-test/data 30 | tar -xJf $TRG_DIR/pg-dist/$ZIP_FILE -C $TRG_DIR/pg-test 31 | 32 | $TRG_DIR/pg-test/bin/initdb -A trust -U postgres -D $TRG_DIR/pg-test/data -E UTF-8 33 | $TRG_DIR/pg-test/bin/pg_ctl -w -D $TRG_DIR/pg-test/data -o '-p 65432 -F -c timezone=UTC -c synchronous_commit=off -c max_connections=300' start 34 | 35 | # Shutdown DB server and do cleanup on exit 36 | function cleanup() { 37 | local errcode=$? 38 | $TRG_DIR/pg-test/bin/pg_ctl -w -D $TRG_DIR/pg-test/data stop 39 | rm -rf $TRG_DIR 40 | return $errcode 41 | } 42 | 43 | trap cleanup EXIT 44 | 45 | test $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c "SHOW SERVER_VERSION") = $PG_VERSION 46 | test $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c "CREATE EXTENSION pgcrypto; SELECT digest('test', 'sha256');") = "\x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" 47 | echo $(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c 'CREATE EXTENSION "uuid-ossp"; SELECT uuid_generate_v4();') | grep -E '^[^-]{8}-[^-]{4}-[^-]{4}-[^-]{4}-[^-]{12}$' 48 | 49 | if echo "$PG_VERSION" | grep -qvE '^(10|9)\.' ; then 50 | count=$(psql -qAtX -h localhost -p 65432 -U postgres -d postgres -c 'SET jit_above_cost = 10; SELECT SUM(relpages) FROM pg_class;') 51 | test $count -gt 0 52 | fi 53 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'embedded-postgres-binaries' 2 | 3 | include 'repacked-platforms' 4 | 5 | include 'debian-platforms' 6 | include 'alpine-platforms' 7 | include 'alpine-lite-platforms' 8 | 9 | include 'custom-debian-platform' 10 | include 'custom-alpine-platform' 11 | include 'custom-alpine-lite-platform' -------------------------------------------------------------------------------- /zonky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zonkyio/embedded-postgres-binaries/e2f6d440cd0f06a774d37c26dea6e606a71b8abb/zonky.jpg --------------------------------------------------------------------------------