Commit Graph

176 Commits

Author SHA1 Message Date
Greg Neagle
48d9c296b2 munkiimport: if no options or arguments are given, print usage 2018-04-19 15:37:39 -07:00
Greg Neagle
c837176d19 Add 'featured' to the list of key/values to copy from the previous pkginfo. Fixes #815. 2018-04-18 13:47:53 -07:00
Greg Neagle
4f8b47746d Fix for #829. munkiimport: Don't crash with IndexError when --apple-update option is used. 2018-01-24 14:54:04 -08:00
Greg Neagle
1428c40d06 Update copyright notices to include 2018 2018-01-20 08:46:22 -08:00
Greg Neagle
ce5ddf2193 munkiimport: Fix issue where pkgs/ was prepended to the relative pkg path in the pkginfo. 2017-11-27 07:01:52 -08:00
Greg Neagle
833cd18806 Make some functions in munkiimportlib.py less chatty to make them easier to use in other code 2017-11-26 17:32:15 -08:00
Greg Neagle
dd6e936e80 munkiimport now calls code in munkilib/admin/makecatalogs.py to rebuild catalogs instead of subprocessing makecatalogs 2017-11-19 17:56:09 -08:00
Greg Neagle
dbf0c95b9d Move munkiimportlib.py and pkginfolib.py into munkilib/admin 2017-11-19 08:39:22 -08:00
Greg Neagle
810d5d833d Move lots of munkiimport functions into munkilib/munkiimportlib.py so they can be called by other code 2017-11-19 07:04:44 -08:00
Greg Neagle
b27aefe373 munkiimport now calls code in munkilib/pkginfolib to generate a pkginfo instead of subprocessing makepkginfo. 2017-11-18 15:09:16 -08:00
Arjen van Bochoven
21927438ae Localized pkgsinfo support (#809)
* Add support for localized_strings in pkgsinfo files

* Update Munkiitems.py

Use NSBundle.preferredLocalizationsFromArray_forPreferences_ instead of
NSLocale.currentLocale

* Move localized_strings to GenericItem

And add localized_strings to iteminfo

* Add localized_strings to munkiimport
2017-10-13 09:03:05 -07:00
Greg Neagle
c45b5e854b munkiimport: When attempting to get info on existing pkgs in the repo, only print a warning about failure to read catalogs/all if there are any items in pkgsinfo. Better first-import experience for new repos. 2017-09-08 11:00:46 -07:00
Greg Neagle
2826e601b4 Display an error and exit if no repo URL is defined or provided instead of crashing 2017-07-24 09:36:39 -07:00
Greg Neagle
4250ab564f munkiimport: When creating a disk image, explicitly specify HFS+ format 2017-07-03 12:56:32 -07:00
Clayton Burlison
e73c9bc652 fix: Don't print blank lines during munkiimport (#755) 2017-04-25 20:36:14 -07:00
Clayton Burlison
5e754bc5e7 fix: Remove duplicate --plugin flag (#751)
This removes the duplicate --plugin flag from the help menu of:
* iconimporter
* makecatalogs
* munkiimport
* repoclean
2017-04-22 00:03:43 -05:00
Greg Neagle
a64b1d7ab3 Add 'startosinstall' support to iconimporter, makepkginfo, and munkiimport 2017-04-01 12:33:35 -07:00
Greg Neagle
e697441de4 munkiimport: If plugin is not given at the CLI or available via preferences, set options.plugin to 'FileRepo' so it is properly forwarded to makecatalogs 2017-03-15 08:59:08 -07:00
Greg Neagle
aa437f7895 munkiimport: special case handling of FileRepo (and children) when 'importing' a pkg already in the repo's pkgs directory 2017-03-15 08:46:10 -07:00
Greg Neagle
70f2800170 munkiimport: Minor wording change when printing warnings/errors at the end of a makecatalogs run 2017-03-14 07:12:22 -07:00
Greg Neagle
e042a2c8d5 Move many functions shared by the various cli tools to munkilib/cliutils.py 2017-03-13 08:03:23 -07:00
Greg Neagle
553eb503e9 munkiimport: Add a TODO 2017-03-11 19:40:21 -08:00
Greg Neagle
a9f1bf672c For an API repo, munkiimport can now forward the repo.authtoken to makecatalogs 2017-03-11 18:59:22 -08:00
Greg Neagle
d1d3f5dcd2 Move code that uses FileRepo as a default if no repo is specified to munkilib/munkirepo/__init__.py 2017-03-11 09:06:09 -08:00
Greg Neagle
a5a9c9e73d Get rid of global variables; improve handling of options that could be defined in prefs or via cli options 2017-03-11 08:55:49 -08:00
Greg Neagle
60bea033cf Extra caution to always default to FileRepo if plugin value is None or '' 2017-03-10 12:16:37 -08:00
Greg Neagle
f327063a07 Merge branch 'Munki3' into new_repo_abstraction 2017-03-10 09:02:53 -08:00
Greg Neagle
d13a6c9926 Update prompt text for --configure 2017-03-10 06:59:27 -08:00
Greg Neagle
112aa3caa2 munkiimport: Remove prompt for repo_path 2017-03-09 18:38:51 -08:00
Greg Neagle
c3402ffce2 Minor naming changes 2017-03-09 10:17:47 -08:00
Per Olofsson
c773ebe7ac Implement featured_installs array in manifests. 2017-03-09 13:25:48 +01:00
Greg Neagle
f9ac3c776b makecatalogs and munkiimport working with new-style FileRepo plugin 2017-03-08 21:53:46 -08:00
Greg Neagle
9f3434c388 munkiimport working with new-style repo plugins 2017-03-08 13:54:13 -08:00
Greg Neagle
f47cd6ac1a Fix several incorrect .encode() methods called on strings returned from subprocess .readline() -- replace with .decode() method 2017-03-05 07:49:41 -08:00
Greg Neagle
0829c2406c Fix several incorrect .encode() methods called on strings returned from subprocess .readline() -- replace with .decode() method 2017-03-05 07:49:02 -08:00
Greg Neagle
ba0cb7c836 Missed an instance variable rename 2017-03-04 20:00:20 -08:00
Greg Neagle
0fb1d3cefa Begin reorg of repo plugins code 2017-03-04 08:19:29 -08:00
Greg Neagle
d6efe8b75f munkiimport: Properly record plugin in REPO_PLUGIN global and pass it to makecatalogs if/when we call it 2017-03-03 21:49:33 -08:00
Greg Neagle
92f5c895ae munkiimport: Remove munkicommon import; replace with refactored modules 2017-03-02 10:33:08 -08:00
Greg Neagle
9a8e3a4797 munkiimport: Copy unused_software_removal_info from prior package 2017-03-01 16:33:43 -08:00
Greg Neagle
aee6d005fb munkiimport copies 'featured' from prior version and also offers to edit it 2017-03-01 15:55:10 -08:00
Greg Neagle
1f90b8d039 Merge https://github.com/ryanyu91/munki into cloudrepo 2017-02-14 09:34:15 -08:00
Ryan Yu
67523fb58f replace REPO_PATH with repo.path since repo object keeps track of the path. 2017-02-02 16:17:45 -08:00
Ryan Yu
913a5fe2b1 in copy_pkginfo_to_repo , joined with REPO_PATH so pkginfo gets written to the correct path. 2017-02-02 15:57:23 -08:00
Ryan Yu
37cdff7f68 NEW CHANGES
************************************************************************************************************************************************************************************
https://github.com/munki/munki/pull/689#pullrequestreview-17297080
Commit based on comments by Greg Neagle on what to fix: munki#689 (master...ryanyu91:master)

FileRepo:
Move FileRepo to munkilib/plugins/

Repo:
Change plugins location for FileRepo

munkiimport:
Change plugins location for FileRepo in configure.

************************************************************************************************************************************************************************************
https://github.com/munki/munki/pull/689#pullrequestreview-17297080
Commit based on comments by Greg Neagle on what to fix: munki#689 (master...ryanyu91:master)

FileRepo:
Changed FileRepo class definition to not be old-style class

iconutils:
Deleted pkg_path join since passing in file anyways

munkiimport:
for --configure option, changed for relative paths support from same directory

Repo:
Changed for relative paths support from same directory

************************************************************************************************************************************************************************************
https://github.com/munki/munki/pull/689#pullrequestreview-16492427
Commit based on comments by Greg Neagle on what to fix: munki#689 (master...ryanyu91:master)

makecatalogs:
removed debugging print statements

manifestutil:
check if repo is initialized before checking if it is mounted

munkiimport:
check if repo is initialized before checking if it is mounted
for def add_icon_hash_to_pkginfo(pkginfo):, not opening file (icon_path) anymore
WE_MOUNTED_THE_REPO is a repo attribute now, instead of a global variable

FileRepo:
removed duplicate/unused imports
changed class to not be old-style
updated glob method since pkgs was uninitialized
made WE_MOUNTED_THE_REPO from global variable to FileRepo attribute variable initialized to False

iconimporter:
updated Repo call to include 3 parameters now..
changed old find_items_to_check calls to new call: findItemsToCheck

Repo.py
Added support for relative paths for importing plugins
************************************************************************************************************************************************************************************

Commit based on comments by Greg Neagle on what to fix: munki#685 (master...ryanyu91:master)
IconImporter:

Not opening DMG and then mounting it anymore, directly mounting like how it was before
ManifestUtil:
Checking if the repo is mounted as well as if we (munki) mounted it. Only this will display prompt whether we want to unmount or not
FileRepo.py, Repo.py:
not hardcoding import path anymore
FileRepo - added 10.12 mounting fileshares code
************************************************************************************************************************************************************************************

Changed Files:
code/client/munkiimport
code/client/iconimporter
code/client/makecatalogs
code/client/manifestutil
code/client/munkilib/iconutils.py

Added Files:
code/client/munkilib/FileRepo.py
code/client/munkilib/Repo.py

Reason For Changes:

The purpose for this change is to enable plugins to munki that will allow writes to the munki repo to be customized.

Changes:

The methods used to write to the munki repo are the target of this modification. A plugin can create new methods for overwriting the default behavior of writing to the munki repo.

The default behavior is retained in the absence of a plugin. This is accomplished via the introduction of FileRepo.py which continues to simply write changes to the munki repo. A plugin can be introduced to change this default behavior and allow munki repo writes to be redirected as desired by the plugin author.

In order to accomplish this we have refactored all of the os.path.* methods, as well as the mount, unmount and available methods from the following tools: (iconimporter, makecatalogs, munkiimport, manifestutil, iconutils), and put them into a different python script to be used as a library or common code module. By default, these are now in the FileRepo.py module. The plugin can be used to overwrite this common code module.

In addition to the above described changes, we also made the following changes to support this plugin
concept:
•	Added the ability to add a plugin either via the command line or via munkiimport –configure
•	The code will look for custom plugins in the /usr/local/munki/munkilib/plugins/ directory
•	If plugin is found in the plugins directory, munkiimport --configure will give the option to type in the plugin name. For example, if you plugin is Foo.py, you could specify a plugin name of Foo in munkiimport --configure
•	If no plugin is found the FileRepo.py module will be used as the default common code module for writing to the munki repo
•	Add the ability to set the plugin via the --plugin option for the following tools (makecatalogs, munkiimport, manifestutil)

Testing
Tested with munkiimport on local filesystem/network shares/our own custom plugins
Tested manifestutil on local filesystem/network
Verified through regression testing, all features of munkiimport, makecatalogs, iconimporter, manifestutil from before all still work (local filesystem/network shares)
2017-01-24 14:48:17 -08:00
Ryan Yu
2441eef7ed Ammending last commit: 77b7c95206
NEW CHANGES
************************************************************************************************************************************************************************************
https://github.com/munki/munki/pull/689#pullrequestreview-17297080
Commit based on comments by Greg Neagle on what to fix: munki#689 (master...ryanyu91:master)

FileRepo:
Changed FileRepo class definition to not be old-style class

iconutils:
Deleted pkg_path join since passing in file anyways

munkiimport:
for --configure option, changed for relative paths support from same directory

Repo:
Changed for relative paths support from same directory

************************************************************************************************************************************************************************************
https://github.com/munki/munki/pull/689#pullrequestreview-16492427
Commit based on comments by Greg Neagle on what to fix: munki#689 (master...ryanyu91:master)

makecatalogs:
removed debugging print statements

manifestutil:
check if repo is initialized before checking if it is mounted

munkiimport:
check if repo is initialized before checking if it is mounted
for def add_icon_hash_to_pkginfo(pkginfo):, not opening file (icon_path) anymore
WE_MOUNTED_THE_REPO is a repo attribute now, instead of a global variable

FileRepo:
removed duplicate/unused imports
changed class to not be old-style
updated glob method since pkgs was uninitialized
made WE_MOUNTED_THE_REPO from global variable to FileRepo attribute variable initialized to False

iconimporter:
updated Repo call to include 3 parameters now..
changed old find_items_to_check calls to new call: findItemsToCheck

Repo.py
Added support for relative paths for importing plugins
************************************************************************************************************************************************************************************

Commit based on comments by Greg Neagle on what to fix: munki#685 (master...ryanyu91:master)
IconImporter:

Not opening DMG and then mounting it anymore, directly mounting like how it was before
ManifestUtil:
Checking if the repo is mounted as well as if we (munki) mounted it. Only this will display prompt whether we want to unmount or not
FileRepo.py, Repo.py:
not hardcoding import path anymore
FileRepo - added 10.12 mounting fileshares code
************************************************************************************************************************************************************************************

Changed Files:
code/client/munkiimport
code/client/iconimporter
code/client/makecatalogs
code/client/manifestutil
code/client/munkilib/iconutils.py

Added Files:
code/client/munkilib/FileRepo.py
code/client/munkilib/Repo.py

Reason For Changes:

The purpose for this change is to enable plugins to munki that will allow writes to the munki repo to be customized.

Changes:

The methods used to write to the munki repo are the target of this modification. A plugin can create new methods for overwriting the default behavior of writing to the munki repo.

The default behavior is retained in the absence of a plugin. This is accomplished via the introduction of FileRepo.py which continues to simply write changes to the munki repo. A plugin can be introduced to change this default behavior and allow munki repo writes to be redirected as desired by the plugin author.

In order to accomplish this we have refactored all of the os.path.* methods, as well as the mount, unmount and available methods from the following tools: (iconimporter, makecatalogs, munkiimport, manifestutil, iconutils), and put them into a different python script to be used as a library or common code module. By default, these are now in the FileRepo.py module. The plugin can be used to overwrite this common code module.

In addition to the above described changes, we also made the following changes to support this plugin
concept:
•	Added the ability to add a plugin either via the command line or via munkiimport –configure
•	The code will look for custom plugins in the /usr/local/munki/munkilib/plugins/ directory
•	If plugin is found in the plugins directory, munkiimport --configure will give the option to type in the plugin name. For example, if you plugin is Foo.py, you could specify a plugin name of Foo in munkiimport --configure
•	If no plugin is found the FileRepo.py module will be used as the default common code module for writing to the munki repo
•	Add the ability to set the plugin via the --plugin option for the following tools (makecatalogs, munkiimport, manifestutil)

Testing
Tested with munkiimport on local filesystem/network shares/our own custom plugins
Tested manifestutil on local filesystem/network
Verified through regression testing, all features of munkiimport, makecatalogs, iconimporter, manifestutil from before all still work (local filesystem/network shares)
2017-01-20 10:37:30 -08:00
Greg Neagle
4053a0dbe7 Update copyright dates to 2017 2017-01-17 20:14:31 -08:00
Ryan Yu
0afd9e1913 NEW CHANGES
************************************************************************************************************************************************************************************
https://github.com/munki/munki/pull/689#pullrequestreview-16492427
Commit based on comments by Greg Neagle on what to fix: munki#689 (master...ryanyu91:master)

makecatalogs:
removed debugging print statements

manifestutil:
check if repo is initialized before checking if it is mounted

munkiimport:
check if repo is initialized before checking if it is mounted
for def add_icon_hash_to_pkginfo(pkginfo):, not opening file (icon_path) anymore
WE_MOUNTED_THE_REPO is a repo attribute now, instead of a global variable

FileRepo:
removed duplicate/unused imports
changed class to not be old-style
updated glob method since pkgs was uninitialized
made WE_MOUNTED_THE_REPO from global variable to FileRepo attribute variable initialized to False

iconimporter:
updated Repo call to include 3 parameters now..
changed old find_items_to_check calls to new call: findItemsToCheck

Repo.py
Added support for relative paths for importing plugins
************************************************************************************************************************************************************************************

Commit based on comments by Greg Neagle on what to fix: munki#685 (master...ryanyu91:master)
IconImporter:

Not opening DMG and then mounting it anymore, directly mounting like how it was before
ManifestUtil:
Checking if the repo is mounted as well as if we (munki) mounted it. Only this will display prompt whether we want to unmount or not
FileRepo.py, Repo.py:
not hardcoding import path anymore
FileRepo - added 10.12 mounting fileshares code
************************************************************************************************************************************************************************************

Changed Files:
code/client/munkiimport
code/client/iconimporter
code/client/makecatalogs
code/client/manifestutil
code/client/munkilib/iconutils.py

Added Files:
code/client/munkilib/FileRepo.py
code/client/munkilib/Repo.py

Reason For Changes:

The purpose for this change is to enable plugins to munki that will allow writes to the munki repo to be customized.

Changes:

The methods used to write to the munki repo are the target of this modification. A plugin can create new methods for overwriting the default behavior of writing to the munki repo.

The default behavior is retained in the absence of a plugin. This is accomplished via the introduction of FileRepo.py which continues to simply write changes to the munki repo. A plugin can be introduced to change this default behavior and allow munki repo writes to be redirected as desired by the plugin author.

In order to accomplish this we have refactored all of the os.path.* methods, as well as the mount, unmount and available methods from the following tools: (iconimporter, makecatalogs, munkiimport, manifestutil, iconutils), and put them into a different python script to be used as a library or common code module. By default, these are now in the FileRepo.py module. The plugin can be used to overwrite this common code module.

In addition to the above described changes, we also made the following changes to support this plugin
concept:
•	Added the ability to add a plugin either via the command line or via munkiimport –configure
•	The code will look for custom plugins in the /usr/local/munki/munkilib/plugins/ directory
•	If plugin is found in the plugins directory, munkiimport --configure will give the option to type in the plugin name. For example, if you plugin is Foo.py, you could specify a plugin name of Foo in munkiimport --configure
•	If no plugin is found the FileRepo.py module will be used as the default common code module for writing to the munki repo
•	Add the ability to set the plugin via the --plugin option for the following tools (makecatalogs, munkiimport, manifestutil)

Testing
Tested with munkiimport on local filesystem/network shares/our own custom plugins
Tested manifestutil on local filesystem/network
Verified through regression testing, all features of munkiimport, makecatalogs, iconimporter, manifestutil from before all still work (local filesystem/network shares)
2017-01-16 13:46:53 -08:00
Ryan Yu
515c42dda8 Revert "NEW CHANGES"
This reverts commit 543613a43f.
2017-01-16 13:29:58 -08:00
Ryan Yu
543613a43f NEW CHANGES
************************************************************************************************************************************************************************************
https://github.com/munki/munki/pull/689#pullrequestreview-16492427
Commit based on comments by Greg Neagle on what to fix: munki#689 (master...ryanyu91:master)

makecatalogs:
removed debugging print statements

manifestutil:
check if repo is initialized before checking if it is mounted

munkiimport:
check if repo is initialized before checking if it is mounted
for def add_icon_hash_to_pkginfo(pkginfo):, not opening file (icon_path) anymore
WE_MOUNTED_THE_REPO is a repo attribute now, instead of a global variable

FileRepo:
removed duplicate/unused imports
changed class to not be old-style
updated glob method since pkgs was uninitialized
made WE_MOUNTED_THE_REPO from global variable to FileRepo attribute variable initialized to False

iconimporter:
updated Repo call to include 3 parameters now..
changed old find_items_to_check calls to new call: findItemsToCheck

Repo.py
Added support for relative paths for importing plugins
************************************************************************************************************************************************************************************

Commit based on comments by Greg Neagle on what to fix: munki#685 (master...ryanyu91:master)
IconImporter:

Not opening DMG and then mounting it anymore, directly mounting like how it was before
ManifestUtil:
Checking if the repo is mounted as well as if we (munki) mounted it. Only this will display prompt whether we want to unmount or not
FileRepo.py, Repo.py:
not hardcoding import path anymore
FileRepo - added 10.12 mounting fileshares code
************************************************************************************************************************************************************************************

Changed Files:
code/client/munkiimport
code/client/iconimporter
code/client/makecatalogs
code/client/manifestutil
code/client/munkilib/iconutils.py

Added Files:
code/client/munkilib/FileRepo.py
code/client/munkilib/Repo.py

Reason For Changes:

The purpose for this change is to enable plugins to munki that will allow writes to the munki repo to be customized.

Changes:

The methods used to write to the munki repo are the target of this modification. A plugin can create new methods for overwriting the default behavior of writing to the munki repo.

The default behavior is retained in the absence of a plugin. This is accomplished via the introduction of FileRepo.py which continues to simply write changes to the munki repo. A plugin can be introduced to change this default behavior and allow munki repo writes to be redirected as desired by the plugin author.

In order to accomplish this we have refactored all of the os.path.* methods, as well as the mount, unmount and available methods from the following tools: (iconimporter, makecatalogs, munkiimport, manifestutil, iconutils), and put them into a different python script to be used as a library or common code module. By default, these are now in the FileRepo.py module. The plugin can be used to overwrite this common code module.

In addition to the above described changes, we also made the following changes to support this plugin
concept:
•	Added the ability to add a plugin either via the command line or via munkiimport –configure
•	The code will look for custom plugins in the /usr/local/munki/munkilib/plugins/ directory
•	If plugin is found in the plugins directory, munkiimport --configure will give the option to type in the plugin name. For example, if you plugin is Foo.py, you could specify a plugin name of Foo in munkiimport --configure
•	If no plugin is found the FileRepo.py module will be used as the default common code module for writing to the munki repo
•	Add the ability to set the plugin via the --plugin option for the following tools (makecatalogs, munkiimport, manifestutil)

Testing
Tested with munkiimport on local filesystem/network shares/our own custom plugins
Tested manifestutil on local filesystem/network
Verified through regression testing, all features of munkiimport, makecatalogs, iconimporter, manifestutil from before all still work (local filesystem/network shares)
2017-01-16 13:11:22 -08:00