|
528 | 528 | pg_prove = pkgs.perlPackages.TAPParserSourceHandlerpgTAP;
|
529 | 529 | supabase-groonga = pkgs.callPackage ./nix/supabase-groonga.nix { };
|
530 | 530 | pg_regress = basePackages.pg_regress;
|
531 |
| - tmpDirCmd = if pkgs.stdenv.isDarwin then |
532 |
| - "$(pwd)/postgres-tmp" |
533 |
| - else |
534 |
| - "mktemp -d"; |
535 | 531 | in
|
536 | 532 | pkgs.runCommand "postgres-${pgpkg.version}-check-harness"
|
537 | 533 | {
|
538 | 534 | nativeBuildInputs = with pkgs; [ coreutils bash pgpkg pg_prove pg_regress procps supabase-groonga ];
|
539 | 535 | } ''
|
540 |
| - $WORKDIR=$(${tmpDirCmd}) |
| 536 | + TMPDIR=$(mktemp -d) |
541 | 537 | if [ $? -ne 0 ]; then
|
542 | 538 | echo "Failed to create temp directory" >&2
|
543 | 539 | exit 1
|
544 | 540 | fi
|
545 | 541 |
|
546 |
| - chmod 700 "$WORKDIR" |
547 |
| -
|
548 | 542 | # Ensure the temporary directory is removed on exit
|
549 |
| - #trap 'rm -rf "$WORKDIR"' EXIT |
| 543 | + trap 'rm -rf "$TMPDIR"' EXIT |
550 | 544 |
|
551 |
| - export PGDATA="$WORKDIR/pgdata" |
552 |
| - export PGSODIUM_DIR="$WORKDIR/pgsodium" |
| 545 | + export PGDATA="$TMPDIR/pgdata" |
| 546 | + export PGSODIUM_DIR="$TMPDIR/pgsodium" |
553 | 547 |
|
554 | 548 | mkdir -p $PGDATA
|
555 |
| - mkdir -p $WORKDIR/logfile |
| 549 | + mkdir -p $TMPDIR/logfile |
556 | 550 | # Generate a random key and store it in an environment variable
|
557 | 551 | export PGSODIUM_KEY=$(head -c 32 /dev/urandom | od -A n -t x1 | tr -d ' \n')
|
558 | 552 | export GRN_PLUGINS_DIR=${supabase-groonga}/lib/groonga/plugins
|
559 | 553 | # Create a simple script to echo the key
|
560 |
| - echo '#!/bin/sh' > $WORKDIR/getkey.sh |
561 |
| - echo 'echo $PGSODIUM_KEY' >> $WORKDIR/getkey.sh |
562 |
| - chmod +x $WORKDIR/getkey.sh |
| 554 | + echo '#!/bin/sh' > $TMPDIR/getkey.sh |
| 555 | + echo 'echo $PGSODIUM_KEY' >> $TMPDIR/getkey.sh |
| 556 | + chmod +x $TMPDIR/getkey.sh |
563 | 557 | initdb --locale=C --username=supabase_admin
|
564 | 558 | substitute ${./nix/tests/postgresql.conf.in} $PGDATA/postgresql.conf \
|
565 |
| - --subst-var-by PGSODIUM_GETKEY_SCRIPT "$WORKDIR/getkey.sh" |
| 559 | + --subst-var-by PGSODIUM_GETKEY_SCRIPT "$TMPDIR/getkey.sh" |
566 | 560 | echo "listen_addresses = '*'" >> $PGDATA/postgresql.conf
|
567 | 561 | echo "port = 5432" >> $PGDATA/postgresql.conf
|
568 | 562 | echo "host all all 127.0.0.1/32 trust" >> $PGDATA/pg_hba.conf
|
569 |
| - #postgres -D "$PGDATA" -k "$WORKDIR" -h localhost -p 5432 >$WORKDIR/logfile/postgresql.log 2>&1 & |
570 |
| - pg_ctl -D "$PGDATA" -l $WORKDIR/logfile/postgresql.log -o "-k $WORKDIR -p 5432" start |
| 563 | + #postgres -D "$PGDATA" -k "$TMPDIR" -h localhost -p 5432 >$TMPDIR/logfile/postgresql.log 2>&1 & |
| 564 | + pg_ctl -D "$PGDATA" -l $TMPDIR/logfile/postgresql.log -o "-k $TMPDIR -p 5432" start |
571 | 565 | for i in {1..60}; do
|
572 | 566 | if pg_isready -h localhost -p 5432; then
|
573 | 567 | echo "PostgreSQL is ready"
|
|
579 | 573 | echo "PostgreSQL status:"
|
580 | 574 | pg_ctl -D "$PGDATA" status
|
581 | 575 | echo "PostgreSQL log content:"
|
582 |
| - cat $WORKDIR/logfile/postgresql.log |
| 576 | + cat $TMPDIR/logfile/postgresql.log |
583 | 577 | exit 1
|
584 | 578 | fi
|
585 | 579 | done
|
586 | 580 | createdb -p 5432 -h localhost --username=supabase_admin testing
|
587 | 581 | if ! psql -p 5432 -h localhost --username=supabase_admin -d testing -v ON_ERROR_STOP=1 -Xaf ${./nix/tests/prime.sql}; then
|
588 | 582 | echo "Error executing SQL file. PostgreSQL log content:"
|
589 |
| - cat $WORKDIR/logfile/postgresql.log |
| 583 | + cat $TMPDIR/logfile/postgresql.log |
590 | 584 | pg_ctl -D "$PGDATA" stop
|
591 | 585 | exit 1
|
592 | 586 | fi
|
|
604 | 598 | $(ls ${./nix/tests/sql} | sed -e 's/\..*$//' | sort )
|
605 | 599 |
|
606 | 600 | pg_ctl -D "$PGDATA" stop
|
607 |
| - mv $WORKDIR/logfile/postgresql.log $out |
| 601 | + mv $TMPDIR/logfile/postgresql.log $out |
608 | 602 | echo ${pgpkg}
|
609 |
| - ''; |
| 603 | + ''; |
610 | 604 | in
|
611 | 605 | rec {
|
612 | 606 | # The list of all packages that can be built with 'nix build'. The list
|
|
0 commit comments