From b45c7132c14ce8005a422a9aa4100fd7566b46ef Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Fri, 6 Jan 2017 13:24:25 -0800 Subject: [PATCH] Restructure installer.py and updatecheck.py --- code/client/munkilib/installer/__init__.py | 1 + .../{installer.py => installer/core.py} | 39 ++++++++++--------- .../{copyfromdmg.py => installer/dmg.py} | 10 ++--- .../{pkginstalls.py => installer/pkg.py} | 20 +++++----- code/client/munkilib/updatecheck/__init__.py | 1 + .../munkilib/{ => updatecheck}/catalogs.py | 15 +++---- .../munkilib/{ => updatecheck}/compare.py | 16 ++++---- .../{updatecheck.py => updatecheck/core.py} | 13 ++++--- .../munkilib/{ => updatecheck}/download.py | 16 ++++---- .../{ => updatecheck}/installationstate.py | 11 +++--- .../munkilib/{ => updatecheck}/licensing.py | 10 ++--- .../{ => updatecheck}/manifestutils.py | 10 ++--- 12 files changed, 85 insertions(+), 77 deletions(-) create mode 100644 code/client/munkilib/installer/__init__.py rename code/client/munkilib/{installer.py => installer/core.py} (98%) rename code/client/munkilib/{copyfromdmg.py => installer/dmg.py} (98%) rename code/client/munkilib/{pkginstalls.py => installer/pkg.py} (97%) create mode 100644 code/client/munkilib/updatecheck/__init__.py rename code/client/munkilib/{ => updatecheck}/catalogs.py (99%) rename code/client/munkilib/{ => updatecheck}/compare.py (98%) mode change 100644 => 100755 rename code/client/munkilib/{updatecheck.py => updatecheck/core.py} (99%) mode change 100644 => 100755 rename code/client/munkilib/{ => updatecheck}/download.py (98%) mode change 100644 => 100755 rename code/client/munkilib/{ => updatecheck}/installationstate.py (98%) mode change 100644 => 100755 rename code/client/munkilib/{ => updatecheck}/licensing.py (96%) mode change 100644 => 100755 rename code/client/munkilib/{ => updatecheck}/manifestutils.py (98%) mode change 100644 => 100755 diff --git a/code/client/munkilib/installer/__init__.py b/code/client/munkilib/installer/__init__.py new file mode 100644 index 00000000..a8ce586c --- /dev/null +++ b/code/client/munkilib/installer/__init__.py @@ -0,0 +1 @@ +from .core import * \ No newline at end of file diff --git a/code/client/munkilib/installer.py b/code/client/munkilib/installer/core.py similarity index 98% rename from code/client/munkilib/installer.py rename to code/client/munkilib/installer/core.py index 8113acad..77fdb0b1 100755 --- a/code/client/munkilib/installer.py +++ b/code/client/munkilib/installer/core.py @@ -15,7 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -installer.py +installer.core + munki module to automatically install pkgs, mpkgs, and dmgs (containing pkgs and mpkgs) from a defined folder. """ @@ -24,18 +25,20 @@ import datetime import os import subprocess -import adobeutils -import catalogs -import copyfromdmg -import munkicommon -import munkistatus -import pkginstalls -import pkgutils -import powermgr -import processes -import profiles -import FoundationPlist -from removepackages import removepackages +from . import dmg +from . import pkg + +from ..updatecheck import catalogs + +from .. import adobeutils +from .. import munkicommon +from .. import munkistatus +from .. import pkgutils +from .. import powermgr +from .. import processes +from .. import profiles +from .. import FoundationPlist +from ..removepackages import removepackages # PyLint cannot properly find names inside Cocoa libraries, so issues bogus # No name 'Foo' in module 'Bar' warnings. Disable them. @@ -221,7 +224,7 @@ def installWithInfo( restartflag = True retcode = 0 elif installer_type == "copy_from_dmg": - retcode = copyfromdmg.copy_from_dmg( + retcode = dmg.copy_from_dmg( itempath, item.get('items_to_copy')) if retcode == 0: if (item.get("RestartAction") == "RequireRestart" or @@ -230,7 +233,7 @@ def installWithInfo( elif installer_type == "appdmg": munkicommon.display_warning( "install_type 'appdmg' is deprecated. Use 'copy_from_dmg'.") - retcode = copyfromdmg.copy_app_from_dmg(itempath) + retcode = dmg.copy_app_from_dmg(itempath) elif installer_type == 'profile': # profiles.install_profile returns True/False retcode = 0 @@ -291,14 +294,14 @@ def installWithInfo( fullpkgpath = os.path.join( mountpoints[0], item['package_path']) if os.path.exists(fullpkgpath): - (retcode, needtorestart) = pkginstalls.install( + (retcode, needtorestart) = pkg.install( fullpkgpath, display_name, choicesXMLfile, suppressBundleRelocation, installer_environment) else: # no relative path to pkg on dmg, so just install all # pkgs found at the root of the first mountpoint # (hopefully there's only one) - (retcode, needtorestart) = pkginstalls.installall( + (retcode, needtorestart) = pkg.installall( mountpoints[0], display_name, choicesXMLfile, suppressBundleRelocation, installer_environment) if (needtorestart or @@ -308,7 +311,7 @@ def installWithInfo( munkicommon.unmountdmg(mountpoints[0]) elif (munkicommon.hasValidPackageExt(itempath) or itempath.endswith(".dist")): - (retcode, needtorestart) = pkginstalls.install( + (retcode, needtorestart) = pkg.install( itempath, display_name, choicesXMLfile, suppressBundleRelocation, installer_environment) if (needtorestart or diff --git a/code/client/munkilib/copyfromdmg.py b/code/client/munkilib/installer/dmg.py similarity index 98% rename from code/client/munkilib/copyfromdmg.py rename to code/client/munkilib/installer/dmg.py index 4aaa00ff..09687336 100755 --- a/code/client/munkilib/copyfromdmg.py +++ b/code/client/munkilib/installer/dmg.py @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -copyfromdmg.py +installer.dmg Created by Greg Neagle on 2017-01-03. @@ -27,10 +27,10 @@ import stat import subprocess import xattr -from . import display -from . import dmgutils -from . import osutils -from . import pkgutils +from .. import display +from .. import dmgutils +from .. import osutils +from .. import pkgutils def copy_items_from_mountpoint(mountpoint, itemlist): diff --git a/code/client/munkilib/pkginstalls.py b/code/client/munkilib/installer/pkg.py similarity index 97% rename from code/client/munkilib/pkginstalls.py rename to code/client/munkilib/installer/pkg.py index 01507d13..8d532c32 100755 --- a/code/client/munkilib/pkginstalls.py +++ b/code/client/munkilib/installer/pkg.py @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -pkginstalls.py +installer.pkg Created by Greg Neagle on 2017-01-03. @@ -27,15 +27,15 @@ import pwd import subprocess import time -from . import display -from . import dmgutils -from . import launchd -from . import munkilog -from . import munkistatus -from . import osutils -from . import processes -from . import pkgutils -from . import FoundationPlist +from .. import display +from .. import dmgutils +from .. import launchd +from .. import munkilog +from .. import munkistatus +from .. import osutils +from .. import processes +from .. import pkgutils +from .. import FoundationPlist def remove_bundle_relocation_info(pkgpath): diff --git a/code/client/munkilib/updatecheck/__init__.py b/code/client/munkilib/updatecheck/__init__.py new file mode 100644 index 00000000..a8ce586c --- /dev/null +++ b/code/client/munkilib/updatecheck/__init__.py @@ -0,0 +1 @@ +from .core import * \ No newline at end of file diff --git a/code/client/munkilib/catalogs.py b/code/client/munkilib/updatecheck/catalogs.py similarity index 99% rename from code/client/munkilib/catalogs.py rename to code/client/munkilib/updatecheck/catalogs.py index f468bda8..e6ef3c35 100755 --- a/code/client/munkilib/catalogs.py +++ b/code/client/munkilib/updatecheck/catalogs.py @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -catalogs.py +updatecheck.catalogs Created by Greg Neagle on 2017-01-01. @@ -24,13 +24,14 @@ Functions for working with Munki catalogs import os -from . import display from . import download -from . import info -from . import pkgutils -from . import prefs -from . import utils -from . import FoundationPlist + +from .. import display +from .. import info +from .. import pkgutils +from .. import prefs +from .. import utils +from .. import FoundationPlist def make_catalog_db(catalogitems): diff --git a/code/client/munkilib/compare.py b/code/client/munkilib/updatecheck/compare.py old mode 100644 new mode 100755 similarity index 98% rename from code/client/munkilib/compare.py rename to code/client/munkilib/updatecheck/compare.py index 0cc8b21c..663257b3 --- a/code/client/munkilib/compare.py +++ b/code/client/munkilib/updatecheck/compare.py @@ -15,21 +15,21 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -compare.py +updatecheck.compare Created by Greg Neagle on 2016-12-13. -Comparsion/checking functions used by updatecheck.py +Comparsion/checking functions used by updatecheck """ import os -from . import display -from . import munkihash -from . import info -from . import pkgutils -from . import utils -from . import FoundationPlist +from .. import display +from .. import munkihash +from .. import info +from .. import pkgutils +from .. import utils +from .. import FoundationPlist # we use lots of camelCase-style names. Deal with it. diff --git a/code/client/munkilib/updatecheck.py b/code/client/munkilib/updatecheck/core.py old mode 100644 new mode 100755 similarity index 99% rename from code/client/munkilib/updatecheck.py rename to code/client/munkilib/updatecheck/core.py index e76b0158..6ae4e5f1 --- a/code/client/munkilib/updatecheck.py +++ b/code/client/munkilib/updatecheck/core.py @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -updatecheck.py +updatecheck.core Created by Greg Neagle on 2008-11-13. @@ -29,14 +29,15 @@ import os from . import catalogs from . import compare from . import download -from . import fetch from . import installationstate -from . import keychain from . import licensing from . import manifestutils -from . import munkicommon -from . import munkistatus -from . import FoundationPlist + +from .. import fetch +from .. import keychain +from .. import munkicommon +from .. import munkistatus +from .. import FoundationPlist # Disable PyLint complaining about 'invalid' camelCase names diff --git a/code/client/munkilib/download.py b/code/client/munkilib/updatecheck/download.py old mode 100644 new mode 100755 similarity index 98% rename from code/client/munkilib/download.py rename to code/client/munkilib/updatecheck/download.py index 0d9421ad..8f8a8160 --- a/code/client/munkilib/download.py +++ b/code/client/munkilib/updatecheck/download.py @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -download.py +updatecheck.download Created by Greg Neagle on 2016-12-31. @@ -27,13 +27,13 @@ import os import urllib2 import urlparse -from . import display -from . import fetch -from . import info -from . import munkihash -from . import osutils -from . import prefs -from . import reports +from .. import display +from .. import fetch +from .. import info +from .. import munkihash +from .. import osutils +from .. import prefs +from .. import reports def enough_disk_space(item_pl, installlist=None, uninstalling=False, warn=True): diff --git a/code/client/munkilib/installationstate.py b/code/client/munkilib/updatecheck/installationstate.py old mode 100644 new mode 100755 similarity index 98% rename from code/client/munkilib/installationstate.py rename to code/client/munkilib/updatecheck/installationstate.py index c7fee856..bdec4943 --- a/code/client/munkilib/installationstate.py +++ b/code/client/munkilib/updatecheck/installationstate.py @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -installationstate.py +updatecheck.installationstate Created by Greg Neagle on 2017-01-01. @@ -26,10 +26,11 @@ import os from . import catalogs from . import compare -from . import display -from . import profiles -from . import scriptutils -from . import utils + +from .. import display +from .. import profiles +from .. import scriptutils +from .. import utils def installed_state(item_pl): diff --git a/code/client/munkilib/licensing.py b/code/client/munkilib/updatecheck/licensing.py old mode 100644 new mode 100755 similarity index 96% rename from code/client/munkilib/licensing.py rename to code/client/munkilib/updatecheck/licensing.py index f9b4363e..cde914f5 --- a/code/client/munkilib/licensing.py +++ b/code/client/munkilib/updatecheck/licensing.py @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -licensing.py +updatecheck.licensing Created by Greg Neagle on 2017-01-01. @@ -23,10 +23,10 @@ Created by Greg Neagle on 2017-01-01. from urllib import quote_plus -from . import display -from . import fetch -from . import prefs -from . import FoundationPlist +from .. import display +from .. import fetch +from .. import prefs +from .. import FoundationPlist def update_available_license_seats(installinfo): diff --git a/code/client/munkilib/manifestutils.py b/code/client/munkilib/updatecheck/manifestutils.py old mode 100644 new mode 100755 similarity index 98% rename from code/client/munkilib/manifestutils.py rename to code/client/munkilib/updatecheck/manifestutils.py index 6f220bd7..29a35d23 --- a/code/client/munkilib/manifestutils.py +++ b/code/client/munkilib/updatecheck/manifestutils.py @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """ -manifestutils.py +updatecheck.manifestutils Created by Greg Neagle on 2016-12-16. @@ -26,10 +26,10 @@ Functions for working with manifest files import os import urllib2 -from . import fetch -from . import keychain -from . import munkicommon -from . import FoundationPlist +from .. import fetch +from .. import keychain +from .. import munkicommon +from .. import FoundationPlist PRIMARY_MANIFEST_TAG = '_primary_manifest_'