Skip to content

Commit

Permalink
Replace AdobeFlashURLProvider with new AdobeFlashDownloadDecoder
Browse files Browse the repository at this point in the history
- 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
timsutton committed Jan 26, 2015
1 parent 7362ba6 commit d3e9e71
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 104 deletions.
78 changes: 78 additions & 0 deletions AdobeFlashPlayer/AdobeFlashDownloadDecoder.py
@@ -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.

Copy link
@gregneagle

gregneagle Jan 26, 2015

Contributor

Got distracted mid-thought?
I'm confused as to what is happening here.

},
}

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()
15 changes: 11 additions & 4 deletions AdobeFlashPlayer/AdobeFlashPlayer.download.recipe
Expand Up @@ -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.

Copy link
@gregneagle

gregneagle Jan 26, 2015

Contributor

Why are we naming the download %NAME%.dmg ? It's not a valid dmg (yet). Why not just leave it "install_all_mac_pl_sgn.z"

<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>
Expand Down
100 changes: 0 additions & 100 deletions AdobeFlashPlayer/AdobeFlashURLProvider.py

This file was deleted.

0 comments on commit d3e9e71

Please sign in to comment.