mirror of
https://github.com/munki/munki.git
synced 2026-04-23 13:29:26 -05:00
Stash build number and git revision in munkilib/version.plist; update munkicommon.get_version() to read build number from munkilib/version.plist
This commit is contained in:
@@ -211,11 +211,10 @@ class Popen(subprocess.Popen):
|
||||
|
||||
|
||||
def get_version():
|
||||
"""Returns version of munkitools, reading version.plist
|
||||
and svnversion"""
|
||||
"""Returns version of munkitools, reading version.plist"""
|
||||
vers = "UNKNOWN"
|
||||
build = ""
|
||||
# find the munkilib directory, and the version files
|
||||
# find the munkilib directory, and the version file
|
||||
munkilibdir = os.path.dirname(os.path.abspath(__file__))
|
||||
versionfile = os.path.join(munkilibdir, "version.plist")
|
||||
if os.path.exists(versionfile):
|
||||
@@ -226,17 +225,9 @@ def get_version():
|
||||
else:
|
||||
try:
|
||||
vers = vers_plist['CFBundleShortVersionString']
|
||||
build = vers_plist['BuildNumber']
|
||||
except KeyError:
|
||||
pass
|
||||
svnversionfile = os.path.join(munkilibdir, "svnversion")
|
||||
if os.path.exists(svnversionfile):
|
||||
try:
|
||||
fileobj = open(svnversionfile, mode='r')
|
||||
contents = fileobj.read()
|
||||
fileobj.close()
|
||||
build = contents.splitlines()[0]
|
||||
except OSError:
|
||||
pass
|
||||
if build:
|
||||
vers = vers + " Build " + build
|
||||
return vers
|
||||
|
||||
@@ -281,8 +281,16 @@ done
|
||||
cp -X "$MUNKIROOT/code/client/munkilib/"*.py "$COREROOT/usr/local/munki/munkilib/"
|
||||
# Copy munki version.
|
||||
cp -X "$MUNKIROOT/code/client/munkilib/version.plist" "$COREROOT/usr/local/munki/munkilib/"
|
||||
echo $SVNREV > "$COREROOT/usr/local/munki/munkilib/svnversion"
|
||||
echo $GITREV > "$COREROOT/usr/local/munki/munkilib/gitrevision"
|
||||
# svnversion file was used when we were using subversion
|
||||
# we don't need this file if we have an updated get_version method in munkicommon.py
|
||||
if [ "$SVNREV" -lt "1310" ]; then
|
||||
echo $SVNREV > "$COREROOT/usr/local/munki/munkilib/svnversion"
|
||||
fi
|
||||
# add Build Number and Git Revision to version.plist
|
||||
defaults write "$COREROOT/usr/local/munki/munkilib/version" BuildNumber "$SVNREV"
|
||||
defaults write "$COREROOT/usr/local/munki/munkilib/version" GitRevision "$GITREV"
|
||||
# defaults write converts the file to binary format, so convert back to XML
|
||||
plutil -convert xml1 "$COREROOT/usr/local/munki/munkilib/version.plist"
|
||||
# Set permissions.
|
||||
chmod -R go-w "$COREROOT/usr/local/munki"
|
||||
chmod +x "$COREROOT/usr/local/munki"
|
||||
|
||||
Reference in New Issue
Block a user