Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace AdobeFlashURLProvider with new AdobeFlashDownloadDecoder
- now we just download a (hopefully) stable URL and decode it with `security`, thanks to tip from @MagerValp - new AdobeFlashDownloadDecoder re-uses URLDownloader's 'pathname' output variable contain the scope of changes to only the .download recipe
- Loading branch information
Showing
3 changed files
with
89 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,78 @@ | |||
#!/usr/bin/python | |||
# | |||
# Copyright 2015 Tim Sutton | |||
# | |||
# Licensed under the Apache License, Version 2.0 (the "License"); | |||
# you may not use this file except in compliance with the License. | |||
# You may obtain a copy of the License at | |||
# | |||
# http://www.apache.org/licenses/LICENSE-2.0 | |||
# | |||
# Unless required by applicable law or agreed to in writing, software | |||
# distributed under the License is distributed on an "AS IS" BASIS, | |||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
"""See docstring for AdobeFlashDownloadDecoder class""" | |||
|
|||
import os | |||
import subprocess | |||
|
|||
from autopkglib import Processor, ProcessorError | |||
|
|||
|
|||
__all__ = ["AdobeFlashDownloadDecoder"] | |||
|
|||
#pylint: disable=missing-docstring | |||
#pylint: disable=e1101 | |||
|
|||
class AdobeFlashDownloadDecoder(Processor): | |||
'''Decodes an Adobe Flash Download using `security cms`. Thanks to Per | |||
Olofsson for documenting the use of the `security` command to decode the | |||
ASN-1 data from Adobe's Flash Player download.''' | |||
description = __doc__ | |||
input_variables = { | |||
"encoded_path": { | |||
"required": True, | |||
"description": ("Path to a downloaded, encoded DMG from Adobe's " | |||
"auto-update url."), | |||
}, | |||
} | |||
output_variables = { | |||
"pathname": { | |||
"description": ("Path to the decoded DMG file. Note that this is " | |||
"the same variable name as output by " | |||
"URLDownloader, since we have ."), | |||
This comment has been minimized.
Sorry, something went wrong. |
|||
}, | |||
} | |||
|
|||
def main(self): | |||
'''Decode the file specified at encoded_path to a new file stored | |||
in the pathname variable.''' | |||
inpath = self.env["encoded_path"] | |||
outpath = os.path.join(self.env["RECIPE_CACHE_DIR"], | |||
"flash_decoded.dmg") | |||
sec_cmd = ["/usr/bin/security", "cms", "-D", | |||
"-i", inpath, | |||
"-o", outpath] | |||
# wrap our call around a general exception in case of unexpected | |||
# issues calling `security` | |||
try: | |||
proc = subprocess.Popen(sec_cmd, | |||
stdout=subprocess.PIPE, | |||
stderr=subprocess.PIPE) | |||
_, err = proc.communicate() | |||
# we expect no output on success, so raise an error in case | |||
# of any non-zero return code or stderr output | |||
if proc.returncode or err: | |||
raise ProcessorError("`security` error: %s, return code: %s" | |||
% (err, proc.returncode)) | |||
except Exception as exp: | |||
raise ProcessorError("Unexpected exception in running `security` " | |||
"command: %s" % exp) | |||
self.env["pathname"] = outpath | |||
|
|||
|
|||
if __name__ == '__main__': | |||
PROCESSOR = AdobeFlashDownloadDecoder() | |||
PROCESSOR.execute_shell() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -15,17 +15,24 @@ | ||
<string>0.2.0</string> | <string>0.2.0</string> | ||
<key>Process</key> | <key>Process</key> | ||
<array> | <array> | ||
<dict> | |||
<key>Processor</key> | |||
<string>AdobeFlashURLProvider</string> | |||
</dict> | |||
<dict> | <dict> | ||
<key>Processor</key> | <key>Processor</key> | ||
<string>URLDownloader</string> | <string>URLDownloader</string> | ||
<key>Arguments</key> | <key>Arguments</key> | ||
<dict> | <dict> | ||
This comment has been minimized.
Sorry, something went wrong.
gregneagle
Contributor
|
|||
<key>filename</key> | <key>filename</key> | ||
<string>%NAME%.dmg</string> | <string>%NAME%.dmg</string> | ||
<key>url</key> | |||
<string>http://fpdownload2.macromedia.com/get/flashplayer/update/current/install/install_all_mac_pl_sgn.z</string> | |||
</dict> | |||
</dict> | |||
<dict> | |||
<key>Processor</key> | |||
<string>AdobeFlashDownloadDecoder</string> | |||
<key>Arguments</key> | |||
<dict> | |||
<key>encoded_path</key> | |||
<string>%pathname%</string> | |||
</dict> | </dict> | ||
</dict> | </dict> | ||
<dict> | <dict> | ||
|
This file was deleted.
Oops, something went wrong.
Got distracted mid-thought?
I'm confused as to what is happening here.