Closed primalcurve closed 1 year ago
Oh my! I've been wanting to figure out a way to fix my HP Print Driver override for so long.... It "worked" (I guess until recently), but 98 times out of 100, it would fail at the end of the download. When I looked at it forever ago, it was (vaguely something along the lines of) an issue with curl and FTP, where curl just didn't receive the proper closing it expected on the file and thought it was corrupted, but if you renamed the temp file that curl downloads, e.g. tmpfpuy0h20
with a valid .pkg
extension, it was just fine.
I've just been ignoring the failure for years as it would randomly work, while hoping HP would eventually stop using FTP as the service to distribute these drivers. And I didn't notice the error had changed from what it used to be.
I went to look into this again and find this PR, which is super exciting! (As much as an AutoPkg recipe, albeit working, can be.)
I've tested these changes and I can confirm they work as is, but it will not work if you try to use the original method and value, e.g. using
<key>HP_QUERY_TYPE</key>
<string>ProductNumber</string>
<key>HP_QUERY</key>
<string>E6B70A</string>
Due to software["Type"]
being of 'Type': 'MacSWSetup'
Which results in the variable recent_software
not being set and a Python error being thrown:
Traceback (most recent call last):
File "/Library/AutoPkg/autopkglib/__init__.py", line 840, in process
self.env = processor.process()
File "/Library/AutoPkg/autopkglib/__init__.py", line 626, in process
self.main()
File "~/Library/AutoPkg/RecipeRepos/com.github.autopkg.n8felton-recipes/SharedProcessors/HPSoftwareInfoProvider.py", line 144, in main
parsed_url = urlparse(recent_software["FtpURL"])
UnboundLocalError: local variable 'recent_software' referenced before assignment
File "/Library/AutoPkg/autopkglib/__init__.py", line 840, in process
self.env = processor.process()
local variable 'recent_software' referenced before assignment
This may want to be accounted for in the PR, but otherwise, I got an updated .pkg using the default values, with a newer .pkg version with all (actually more) of the same printer models PPDs files.
Great work @primalcurve, I really appreciate the contribution.
Great work on this! Sorry for my extended delayed response to this. I added a few extra bits to what you had. Give everything look over and if you're good with them, I'll finish up this PR.
Thanks again!
@n8felton Works great for me still. (I cleaned up some of the unnecessary output.)
% /usr/local/bin/autopkg run local.HPPrinterDrivers -vvv --prefs='/Library/AutoPkg/PkgBot/Settings/dev_autopkg_prefs.plist' --ignore-parent-trust-verification-errors
Processing local.HPPrinterDrivers...
{ 'AUTOPKG_VERSION': '2.7.1',
'CATEGORY': 'Printers',
'HP_QUERY': 'HP Color LaserJet Pro M453-4',
'HP_QUERY_TYPE': 'ModelName',
'NAME': 'HP Printer Drivers',
'PARENT_RECIPES': ['~/Library/AutoPkg/RecipeRepos/com.github.autopkg.n8felton-recipes/HPPrinterDrivers/HPPrinterDrivers.download.recipe'],
'PKG_ONLY': 'False',
'PKG_ONLY_PREDICATE': 'False == True',
'RECIPE_CACHE_DIR': '~/Library/AutoPkg/Cache/local.HPPrinterDrivers',
'RECIPE_DIR': '~/Library/AutoPkg/RecipeOverrides/HP Print Drivers',
'RECIPE_OVERRIDE_DIRS': ['~/Library/AutoPkg/RecipeOverrides'],
'RECIPE_PATH': '~/Library/AutoPkg/RecipeOverrides/HP Print '
'Drivers/HPPrinterDrivers.recipe.yaml',
'RECIPE_REPOS': {[...]
'RECIPE_REPO_DIR': '~/Library/AutoPkg/RecipeRepos',
'RECIPE_SEARCH_DIRS': [...]
'verbose': 3}
com.github.n8felton.shared/HPSoftwareInfoProvider
Use of undefined key in variable substitution: 'PRODUCT_NUMBER'
{'Input': {'HP_QUERY': 'HP Color LaserJet Pro M453-4',
'HP_QUERY_TYPE': 'ModelName',
'OPERATING_SYSTEM': 'macOS 12.0'}}
HPSoftwareInfoProvider: No value supplied for LANG_CODE, setting default value of: en
HPSoftwareInfoProvider: No value supplied for COUNTRY_CODE, setting default value of: us
HPSoftwareInfoProvider: Software URL: https://h20614.www2.hp.com/ediags/solutions/software/v3?ModelName=HP+Color+LaserJet+Pro+M453-4&OS=macOS%2012.0&lc=en&cc=us&client=hp-quick-start
HPSoftwareInfoProvider: [{'SoftwareId': 'mp-280205-1', 'PID': None, 'ProductNumber': None, 'ModelName': 'HP Color LaserJet Pro M453-4', 'lc': 'en', 'cc': 'us', 'Type': 'ESSENTIAL-REQUIRED', 'Identifier': 'com.hp.pkg.swls.printer-essentials-UniPS.version', 'IdentifierType': 'OSXPackageMakerPackage', 'Version': '6.0.0.6', 'MinVersion': None, 'Function': 'PSF', 'FtpURL': 'ftp://ftp.hp.com/pub/softlib/software12/HP_Quick_Start/osx/Installations/Essentials/macOS12/hp-printer-essentials-UniPS-6_0_0_6.pkg', 'HelpURL': None, 'Title': 'Essential Software', 'Description': 'Installs genuine HP Drivers and HP Utility - essential software for using the features of your HP product.'}, {'SoftwareId': 'mp-300092-1', 'PID': None, 'ProductNumber': None, 'ModelName': 'HP Color LaserJet Pro M453-4', 'lc': 'en', 'cc': 'us', 'Type': 'ESSENTIAL-REQUIRED', 'Identifier': 'com.hp.pkg.swls.printer-essentials-UniPS.version', 'IdentifierType': 'OSXPackageMakerPackage', 'Version': '6.1.0.1', 'MinVersion': None, 'Function': 'PSF', 'FtpURL': 'ftp://ftp.hp.com/pub/softlib/software12/HP_Quick_Start/osx/Installations/Essentials/macOS13/hp-printer-essentials-UniPS-6_1_0_1.pkg', 'HelpURL': None, 'Title': 'Essential Software', 'Description': 'Installs genuine HP Drivers and HP Utility - essential software for using the features of your HP product.'}]
HPSoftwareInfoProvider: https://ftp.hp.com/pub/softlib/software12/HP_Quick_Start/osx/Installations/Essentials/macOS13/hp-printer-essentials-UniPS-6_1_0_1.pkg
{'Output': {'description': 'Installs genuine HP Drivers and HP Utility - '
'essential software for using the features of your '
'HP product.',
'url': 'https://ftp.hp.com/pub/softlib/software12/HP_Quick_Start/osx/Installations/Essentials/macOS13/hp-printer-essentials-UniPS-6_1_0_1.pkg',
'version': '6.1.0.1'}}
URLDownloader
{'Input': {'url': 'https://ftp.hp.com/pub/softlib/software12/HP_Quick_Start/osx/Installations/Essentials/macOS13/hp-printer-essentials-UniPS-6_1_0_1.pkg'}}
URLDownloader: No value supplied for prefetch_filename, setting default value of: False
URLDownloader: No value supplied for CHECK_FILESIZE_ONLY, setting default value of: False
URLDownloader: Storing new Last-Modified header: Wed, 14 Dec 2022 17:08:16 GMT
URLDownloader: Storing new ETag header: "19877c99ceb90212990d6730f0d23d77-92"
URLDownloader: Downloaded ~/Library/AutoPkg/Cache/local.HPPrinterDrivers/downloads/hp-printer-essentials-UniPS-6_1_0_1.pkg
{'Output': {'download_changed': True,
'etag': '"19877c99ceb90212990d6730f0d23d77-92"',
'last_modified': 'Wed, 14 Dec 2022 17:08:16 GMT',
'pathname': '~/Library/AutoPkg/Cache/local.HPPrinterDrivers/downloads/hp-printer-essentials-UniPS-6_1_0_1.pkg',
'url_downloader_summary_result': {'data': {'download_path': '~/Library/AutoPkg/Cache/local.HPPrinterDrivers/downloads/hp-printer-essentials-UniPS-6_1_0_1.pkg'},
'summary_text': 'The following '
'new items were '
'downloaded:'}}}
EndOfCheckPhase
{'Input': {}}
{'Output': {}}
CodeSignatureVerifier
{'Input': {'expected_authority_names': ['Developer ID Installer: HP Inc. '
'(6HB5Y2QTA3)',
'Developer ID Certification Authority',
'Apple Root CA'],
'input_path': '~/Library/AutoPkg/Cache/local.HPPrinterDrivers/downloads/hp-printer-essentials-UniPS-6_1_0_1.pkg'}}
CodeSignatureVerifier: Verifying installer package signature...
CodeSignatureVerifier: Package "hp-printer-essentials-UniPS-6_1_0_1.pkg":
CodeSignatureVerifier: Status: signed by a developer certificate issued by Apple for distribution
CodeSignatureVerifier: Notarization: trusted by the Apple notary service
CodeSignatureVerifier: Signed with a trusted timestamp on: 2022-10-13 07:42:40 +0000
CodeSignatureVerifier: Certificate Chain:
CodeSignatureVerifier: 1. Developer ID Installer: HP Inc. (6HB5Y2QTA3)
CodeSignatureVerifier: Expires: 2025-02-10 20:05:07 +0000
CodeSignatureVerifier: SHA256 Fingerprint:
CodeSignatureVerifier: 56 6A 5A 62 A7 30 B6 F7 33 F5 D4 DD 5F 57 0E A4 D2 B1 6F B1 F4 67
CodeSignatureVerifier: 24 3A 13 E3 3D E6 C9 AA 15 C6
CodeSignatureVerifier: ------------------------------------------------------------------------
CodeSignatureVerifier: 2. Developer ID Certification Authority
CodeSignatureVerifier: Expires: 2027-02-01 22:12:15 +0000
CodeSignatureVerifier: SHA256 Fingerprint:
CodeSignatureVerifier: 7A FC 9D 01 A6 2F 03 A2 DE 96 37 93 6D 4A FE 68 09 0D 2D E1 8D 03
CodeSignatureVerifier: F2 9C 88 CF B0 B1 BA 63 58 7F
CodeSignatureVerifier: ------------------------------------------------------------------------
CodeSignatureVerifier: 3. Apple Root CA
CodeSignatureVerifier: Expires: 2035-02-09 21:40:36 +0000
CodeSignatureVerifier: SHA256 Fingerprint:
CodeSignatureVerifier: B0 B1 73 0E CB C7 FF 45 05 14 2C 49 F1 29 5E 6E DA 6B CA ED 7E 2C
CodeSignatureVerifier: 68 C5 BE 91 B5 A1 10 01 F0 24
CodeSignatureVerifier:
CodeSignatureVerifier: Signature is valid
CodeSignatureVerifier: Authority name chain is valid
{'Output': {}}
[...]
The following new items were downloaded:
Download Path
-------------
~/Library/AutoPkg/Cache/local.HPPrinterDrivers/downloads/hp-printer-essentials-UniPS-6_1_0_1.pkg
Due to some changes on HP's side, the HPPrinterDrivers recipe is not functioning. I have made some changes in order to fix those errors and provide greater flexibility in the recipe.
HPSoftwareInfoProvider.py
operating_system
to prevent conflicts withos
built-in.ftp
and modify it to usehttps
since the HP FTP server rejects FTP requests now. Even the HP Easy Admin client tries HTTPS first.HPPrinterDrivers.download.recipe
Output of
autopkg run -vvvv