Skip to content

Fix building on macOS #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build
tmp
*.pyc
.idea
*.iml
2 changes: 1 addition & 1 deletion mongodb_consistent_backup/Upload/Rsync/Rsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def init(self):
def rsync_info(self):
if not self._rsync_info:
output = check_output([self.rsync_binary, "--version"])
search = re.search("^rsync\s+version\s([0-9.-]+)\s+protocol\sversion\s(\d+)", output)
search = re.search(r"^rsync\s+version\s([0-9.-]+)\s+protocol\sversion\s(\d+)", output)
self.rsync_version = search.group(1)
self._rsync_info = {"version": self.rsync_version, "protocol_version": int(search.group(2))}
return self._rsync_info
Expand Down
18 changes: 15 additions & 3 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

set -x

readlink_bin=readlink
cp_bin=cp
if [[ "`uname`" =~ "Darwin" ]]; then
if [[ -x /usr/local/bin/gcp && -x /usr/local/bin/greadlink ]]; then
readlink_bin=greadlink
cp_bin=gcp
else
echo "To run this on macOS, please install coreutils via homebrew first."
exit 1
fi
fi

name=${BIN_NAME:-mongodb-consistent-backup}
mod_name=mongodb_consistent_backup
rootdir=$(readlink -f $(dirname $0)/..)
rootdir=$(${readlink_bin} -f $(dirname $0)/..)
srcdir=${rootdir}/${mod_name}
bindir=${rootdir}/bin
builddir=${rootdir}/build
Expand Down Expand Up @@ -55,8 +67,8 @@ fi
if [ -d ${srcdir} ]; then
[ -e ${builddir} ] && rm -rf ${builddir}
mkdir -p ${builddir}
cp -dpR ${rootdir}/${mod_name} ${builddir}/${mod_name}
cp -dp ${rootdir}/{setup.py,requirements.txt,README.rst,VERSION} ${builddir}
${cp_bin} -dpR ${rootdir}/${mod_name} ${builddir}/${mod_name}
${cp_bin} -dp ${rootdir}/{setup.py,requirements.txt,README.rst,VERSION} ${builddir}
find ${builddir} -type f -name "*.pyc" -delete

# Replace version number in setup.py and mongodb_consistent_backup/__init__.py with number in VERSION:
Expand Down