Skip to content
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

md5sum on bsd #477

Merged
merged 2 commits into from
Jun 15, 2012
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/ansible/runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ def _execute_fetch(self, conn, tmp):
# compare old and new md5 for support of change hooks
local_md5 = None
if os.path.exists(dest):
local_md5 = os.popen("md5sum %s" % dest).read().split()[0]
remote_md5 = self._low_level_exec_command(conn, "md5sum %s" % source, tmp, True).split()[0]
local_md5 = os.popen("/usr/bin/md5sum %(file)s 2> /dev/null || /sbin/md5 -q %(file)s" % {"file": dest}).read().split()[0]
remote_md5 = self._low_level_exec_command(conn, "/usr/bin/md5sum %(file)s 2> /dev/null || /sbin/md5 -q %(file)s" % {"file": source}, tmp, True).split()[0]

if remote_md5 != local_md5:
# create the containing directories, if needed
Expand All @@ -486,7 +486,7 @@ def _execute_fetch(self, conn, tmp):

# fetch the file and check for changes
conn.fetch_file(source, dest)
new_md5 = os.popen("md5sum %s" % dest).read().split()[0]
new_md5 = os.popen("/usr/bin/md5sum %(file)s 2> /dev/null || /sbin/md5 -q %(file)s" % {"file": dest}).read().split()[0]
if new_md5 != remote_md5:
result = dict(failed=True, msg="md5 mismatch", md5sum=new_md5)
return ReturnData(host=conn.host, result=result)
Expand Down
4 changes: 2 additions & 2 deletions library/copy
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ if not os.path.exists(src):
md5sum = None
changed = False
if os.path.exists(dest):
md5sum = os.popen("md5sum %s" % dest).read().split()[0]
md5sum = os.popen("/usr/bin/md5sum %(file)s 2> /dev/null || /sbin/md5 -q %(file)s" % {"file": dest}).read().split()[0]

md5sum2 = os.popen("md5sum %s" % src).read().split()[0]
md5sum2 = os.popen("/usr/bin/md5sum %(file)s 2> /dev/null || /sbin/md5 -q %(file)s" % {"file": src}).read().split()[0]

if md5sum != md5sum2:
os.system("cp %s %s" % (src, dest))
Expand Down
3 changes: 0 additions & 3 deletions library/file
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ changed = False
# ===========================================
# support functions

def md5sum(filename):
return os.popen("/usr/bin/md5sum %s" % f).read()

def user_and_group(filename):
st = os.stat(filename)
uid = st.st_uid
Expand Down
4 changes: 2 additions & 2 deletions library/setup
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ md5sum = None
if not os.path.exists(ansible_file):
changed = True
else:
md5sum = os.popen("md5sum %s" % ansible_file).read().split()[0]
md5sum = os.popen("/usr/bin/md5sum %(file)s 2> /dev/null || /sbin/md5 -q %(file)s" % {"file": ansible_file}).read().split()[0]

# Get some basic facts in case facter or ohai are not installed
for (k, v) in ansible_facts().items():
Expand Down Expand Up @@ -394,7 +394,7 @@ reformat = json.dumps(setup_options, sort_keys=True, indent=4)
f.write(reformat)
f.close()

md5sum2 = os.popen("md5sum %s" % ansible_file).read().split()[0]
md5sum2 = os.popen("/usr/bin/md5sum %(file)s 2> /dev/null || /sbin/md5 -q %(file)s" % {"file": ansible_file}).read().split()[0]

if md5sum != md5sum2:
changed = True
Expand Down