Skip to content

Commit c490d46

Browse files
committed
packaged pgdiff, pgrun, and pgdiff.sh for OSX and Linux
Former-commit-id: 5a5b59f
1 parent d9cd22e commit c490d46

9 files changed

Lines changed: 70 additions & 20 deletions

File tree

bin-linux/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Linux pgdiff instructions
2+
3+
These instructions will guide you through the process of generating SQL, reviewing it, and optionally running it on the target database. It requires a familiarity with a Linux command-line shell.
4+
5+
1. download pgdiff.tgz to your machine
6+
1. untar pgdiff.tgz (a new directory will be created: called pgdiff)
7+
1. cd into the new pgdiff directory
8+
1. optionally edit pgdiff.sh to change the db access values... or set them at runtime (i.e. USER1=joe NAME1=mydb USER2=joe NAME2=myotherdb pgdiff.sh)
9+
1. run pgdiff.sh
10+
11+
## tar contents
12+
* pgdiff - a linux executable
13+
* pgrun - a linux executable for running SQL
14+
* pgdiff.sh - a bash shell script to coordinate your interaction with pgdiff and pgrun
15+
16+
If you write a Go version of pgdiff.sh, please share it and I'll include it for others to use (with your copyright information intact).

bin-linux/pgdiff.REMOVED.git-id

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
b33644e000965e421a9c120a899ac60ad17eab46

bin-osx/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## OSX / Mac pgdiff instructions
2+
3+
These instructions will guide you through the process of generating SQL, reviewing it, and optionally running it on the target database. It requires a familiarity with the bash shell in OSX.
4+
5+
1. download pgdiff.tgz to your machine
6+
1. untar pgdiff.tgz (a new directory will be created: called pgdiff)
7+
1. cd into the new pgdiff directory
8+
1. optionally edit pgdiff.sh to change the db access values... or set them at runtime (i.e. USER1=joe NAME1=mydb USER2=joe NAME2=myotherdb pgdiff.sh)
9+
1. run pgdiff.sh
10+
11+
## tar contents
12+
* pgdiff - an OSX executable
13+
* pgrun - an OSX executable for running SQL
14+
* pgdiff.sh - a bash shell script to coordinate your interaction with pgdiff and pgrun
15+
16+
If you write a Go version of pgdiff.sh, please share it and I'll include it for others to use (with your copyright information intact).

bin-osx/pgdiff.REMOVED.git-id

Lines changed: 0 additions & 1 deletion
This file was deleted.

bin-osx/pgdiff.tgz.REMOVED.git-id

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
b9845f185d9d08d675362c1e59d30a1eb077cbb6

bin-win/pgrun.exe.REMOVED.git-id

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1675e9f7afb3e2aa2a11db7aa34ccc08f7637a94

build.sh

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ SCRIPT_DIR="$(dirname `ls -l $0 | awk '{ print $NF }'`)"
55
[[ -z $APPNAME ]] && APPNAME=pgdiff
66

77
if [[ -d bin-linux ]]; then
8+
echo " ==== Building Linux ===="
89
tempdir="$(mktemp -d -t $APPNAME)"
910
workdir="$tempdir/$APPNAME"
1011
echo $workdir
@@ -16,27 +17,43 @@ if [[ -d bin-linux ]]; then
1617
# Copy the bash runtime script to the temp directory
1718
cp pgdiff.sh "$workdir/"
1819
cd "$tempdir"
19-
zip -r "${APPNAME}.zip" $APPNAME
20-
mv "${APPNAME}.zip" "$SCRIPT_DIR/bin-linux/"
20+
# Make everything executable
21+
chmod -v ugo+x $APPNAME/*
22+
COPYFILE_DISABLE=true tar -cvzf "${APPNAME}.tgz" $APPNAME
2123
cd -
24+
mv "${tempdir}/${APPNAME}.tgz" "${SCRIPT_DIR}/bin-linux/"
2225
echo "Built linux."
2326
else
2427
echo "Skipping linux. No bin-linux directory."
2528
fi
2629

27-
#### DON'T LEAVE THIS
28-
exit 1
29-
3030
if [[ -d bin-osx ]]; then
31-
GOOS=darwin GOARCH=386 go build -o bin-osx/${APPNAME}
31+
echo " ==== Building OSX ===="
32+
tempdir="$(mktemp -d -t $APPNAME)"
33+
workdir="$tempdir/$APPNAME"
34+
echo $workdir
35+
mkdir -p $workdir
36+
# Build the executable
37+
GOOS=darwin GOARCH=386 go build -o "$workdir/$APPNAME"
38+
# Download pgrun to the work directory
39+
wget -O "$workdir/pgrun" "https://github.com/joncrlsn/pgrun/raw/master/bin-osx/pgrun"
40+
# Copy the bash runtime script to the temp directory
41+
cp pgdiff.sh "$workdir/"
42+
cd "$tempdir"
43+
# Make everything executable
44+
chmod -v ugo+x $APPNAME/*
45+
COPYFILE_DISABLE=true tar -cvzf "${APPNAME}.tgz" $APPNAME
46+
cd -
47+
mv "${tempdir}/${APPNAME}.tgz" "${SCRIPT_DIR}/bin-osx/"
3248
echo "Built osx32."
3349
else
3450
echo "Skipping osx. No bin-osx directory."
3551
fi
3652

3753
if [[ -d bin-win ]]; then
54+
echo " ==== Building Windows ===="
3855
GOOS=windows GOARCH=386 go build -o bin-win/${APPNAME}.exe
39-
echo "Built win32."
56+
echo "Built win."
4057
else
4158
echo "Skipping win. No bin-win directory."
4259
fi

pgdiff.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22
#
3-
# pgdiff.sh runs a compare on each schema type in the order that creates the fewest conflicts. At each step you are allowed to review
4-
# and optionally change and/or run the generated SQL.
3+
# pgdiff.sh runs a compare on each schema type in the order that usually creates the fewest conflicts.
4+
# At each step you are allowed to review and optionally change and/or run the generated SQL.
55
#
6-
# If you convert this to a windows batch file, please share it.
6+
# If you convert this to a windows batch file (or, even better, a Go program), please share it.
77
#
88
# pgdiff -U postgres -W supersecret -D maindb -O sslmode=disable -u postgres -w supersecret -d stagingdb -o sslmode=disable COLUMN
99
#
@@ -51,16 +51,16 @@ function rundiff() {
5151
}
5252

5353
rundiff FUNCTION
54-
#rundiff ROLE
55-
#rundiff SEQUENCE
54+
rundiff ROLE
55+
rundiff SEQUENCE
5656
rundiff TABLE
57-
#rundiff VIEW
58-
#rundiff OWNER
57+
rundiff VIEW
58+
rundiff OWNER
5959
rundiff COLUMN
60-
#rundiff INDEX
61-
#rundiff FOREIGN_KEY
62-
#rundiff GRANT_RELATIONSHIP
63-
#rundiff GRANT_ATTRIBUTE
60+
rundiff INDEX
61+
rundiff FOREIGN_KEY
62+
rundiff GRANT_RELATIONSHIP
63+
rundiff GRANT_ATTRIBUTE
6464
rundiff TRIGGER
6565

6666
echo "Done!"

0 commit comments

Comments
 (0)