grahampugh / macadmin-scripts

Scripts of possible interest to macOS admins
Other
366 stars 46 forks source link

installinstallmacos fails on 11.2.3 #39

Closed blacktop closed 3 years ago

blacktop commented 3 years ago
$ ./installinstallmacos.py

 8      071-14766     11.2.3    20D91  2021-03-08  macOS Big Sur

<selected >

Downloading files

<SNIP>

Making empty sparseimage...
installer: Package name is macOS Big Sur
installer: Installing at base path /private/tmp/dmg.sUSsE3
installer: The install failed. (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance. An error occurred while running scripts from the package “InstallAssistant.pkg”.)
Command '[u'/usr/sbin/installer', u'-pkg', u'./content/downloads/12/32/071-14766-A_Q2H6ELXGVG/zx8saim8tei7fezrmvu4vuab80m0e8a5ll/071-14766.English.dist', u'-target', '/private/tmp/dmg.sUSsE3']' returned non-zero exit status 1
Product installation failed.
blacktop commented 3 years ago

running on MBP 2019 (11.2.3)

grahampugh commented 3 years ago

Does it fail consistently with every run? Because I suspect a problem with the download.

blacktop commented 3 years ago
Choose a product to download (1-16): 8
Downloading http://swcdn.apple.com/content/downloads/12/32/071-14766-A_Q2H6ELXGVG/zx8saim8tei7fezrmvu4vuab80m0e8a5ll/BuildManifest.plist...
######################################################################################################################################################### 100.0%
curl: (22) The requested URL returned error: 416
Downloading http://swcdn.apple.com/content/downloads/12/32/071-14766-A_Q2H6ELXGVG/zx8saim8tei7fezrmvu4vuab80m0e8a5ll/MajorOSInfo.pkg...
######################################################################################################################################################### 100.0%
curl: (22) The requested URL returned error: 416
Downloading https://swdist.apple.com/content/downloads/12/32/071-14766-A_Q2H6ELXGVG/zx8saim8tei7fezrmvu4vuab80m0e8a5ll/MajorOSInfo.pkm...
Downloading http://swcdn.apple.com/content/downloads/12/32/071-14766-A_Q2H6ELXGVG/zx8saim8tei7fezrmvu4vuab80m0e8a5ll/InstallAssistant.pkg...
######################################################################################################################################################### 100.0%
curl: (22) The requested URL returned error: 416
Downloading https://swdist.apple.com/content/downloads/12/32/071-14766-A_Q2H6ELXGVG/zx8saim8tei7fezrmvu4vuab80m0e8a5ll/InstallAssistant.pkm...
Downloading http://swcdn.apple.com/content/downloads/12/32/071-14766-A_Q2H6ELXGVG/zx8saim8tei7fezrmvu4vuab80m0e8a5ll/InstallInfo.plist...
######################################################################################################################################################### 100.0%
curl: (22) The requested URL returned error: 416
Downloading http://swcdn.apple.com/content/downloads/12/32/071-14766-A_Q2H6ELXGVG/zx8saim8tei7fezrmvu4vuab80m0e8a5ll/Info.plist...
######################################################################################################################################################### 100.0%
curl: (22) The requested URL returned error: 416
Downloading http://swcdn.apple.com/content/downloads/12/32/071-14766-A_Q2H6ELXGVG/zx8saim8tei7fezrmvu4vuab80m0e8a5ll/UpdateBrain.zip...
######################################################################################################################################################### 100.0%
curl: (22) The requested URL returned error: 416
Making empty sparseimage...
installer: Package name is macOS Big Sur
installer: Installing at base path /private/tmp/dmg.Xf9D0V
installer: The install failed. (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance. An error occurred while running scripts from the package “InstallAssistant.pkg”.)
Command '[u'/usr/sbin/installer', u'-pkg', u'./content/downloads/12/32/071-14766-A_Q2H6ELXGVG/zx8saim8tei7fezrmvu4vuab80m0e8a5ll/071-14766.English.dist', u'-target', '/private/tmp/dmg.Xf9D0V']' returned non-zero exit status 1
Product installation failed.
blacktop commented 3 years ago

I have tried 6 times, the 416 error I believe is curl trying to "resume" completed downloads.

grahampugh commented 3 years ago

I'm curious as to what happens if you use the older version of installinstallmacos.py. I merged in some changes to the script that were made in the original script a few weeks ago. Try the version at https://github.com/grahampugh/macadmin-scripts/tree/f6df69e84717d96c134f96bbede6a9eef9705299.

Also, what happens if you clear the cache? Either remove the content folder or use the --ignore-cache flag.

blacktop commented 3 years ago

Thank you for the quick response! I'll try that older version.

Looks like this person is having the same issue

https://github.com/munki/macadmin-scripts/issues/86

craig65535 commented 3 years ago

I wrote the recent HTTP resume patch and I'm happy to answer any questions about it.

HTTP error 416 is informational in this case. It means that your download is already complete and is the latest version available on the server. Removing the content folder would just cause a re-download.

I am seeing an install error as well in https://github.com/munki/macadmin-scripts/issues/86 , but I don't think it has anything to do with the downloads themselves.

blacktop commented 3 years ago
 #  ProductID       Version    Build    Post Date   Title                          
 1  001-15219       10.15.5    19F2200  2020-06-15  macOS Catalina                 
 2  001-68446       10.15.7    19H15    2020-11-11  macOS Catalina                 
 3  001-04366       10.15.4    19E2269  2020-05-04  macOS Catalina                 
 4  071-08935       11.2.2     20D80    2021-03-01  macOS Big Sur                  
 5  061-86291       10.15.3    19D2064  2020-03-23  macOS Catalina                 
 6  041-91758       10.13.6    17G66    2019-10-19  macOS High Sierra              
 7  041-88800       10.14.4    18E2034  2019-10-23  macOS Mojave                   
 8  071-14766       11.2.3     20D91    2021-03-08  macOS Big Sur                  
 9  061-26589       10.14.6    18G103   2019-10-14  macOS Mojave                   
10  071-05432       11.2.1     20D75    2021-02-15  macOS Big Sur                  
11  001-51042       10.15.7    19H2     2020-09-24  macOS Catalina                 
12  001-36735       10.15.6    19G2006  2020-08-06  macOS Catalina                 
13  001-57224       10.15.7    19H4     2020-10-27  macOS Catalina                 
14  041-90855       10.13.5    17F66a   2019-10-23  Install macOS High Sierra Beta 
15  061-26578       10.14.5    18F2059  2019-10-14  macOS Mojave                   
16  001-36801       10.15.6    19G2021  2020-08-12  macOS Catalina                 

Choose a product to download (1-16): 8
########################################################################################################################################### 100.0%
########################################################################################################################################### 100.0%
########################################################################################################################################### 100.0%
########################################################################################################################################### 100.0%
########################################################################################################################################### 100.0%
########################################################################################################################################### 100.0%
Making empty sparseimage...
installer: Package name is macOS Big Sur
installer: Installing at base path /private/tmp/dmg.7A0VWx
installer: The install failed. (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance. An error occurred while running scripts from the package “InstallAssistant.pkg”.)
Command '[u'/usr/sbin/installer', u'-pkg', u'./content/downloads/12/32/071-14766-A_Q2H6ELXGVG/zx8saim8tei7fezrmvu4vuab80m0e8a5ll/071-14766.English.dist', u'-target', '/private/tmp/dmg.7A0VWx']' returned non-zero exit status 1
Product installation failed.

same behavior with https://github.com/grahampugh/macadmin-scripts/tree/f6df69e84717d96c134f96bbede6a9eef9705299.

blacktop commented 3 years ago

@craig65535 understood about the 416s, and I am downloading the files, however, it's the installer cmd that failing, not sure why?

I assume the .dist file would have clues?

grahampugh commented 3 years ago

@blacktop can you reproduce this on more than one machine, more than one version of macOS?

craig65535 commented 3 years ago

@grahampugh This seems to only happen when building an installer for Big Sur, but it is reproducible every time. I can still build a Catalina installer.

@blacktop The .dist file contains a reference to InstallAssistant.pkg. That pkg file contains Scripts/postinstall.zsh which calls Scripts/postinstall_actions/link_shared_support.zsh. When run, the latter tries to find SharedSupport.dmg in the nonsense path /private/tmp/dmg.y9IuqGApplications/Install macOS Big Sur.app/Contents/SharedSupport/SharedSupport.dmg. Note the lack of / before Applications.

Maybe the script in InstallAssistant.pkg is broken and will only work when the target is / and not something like /private/tmp/dmg.XXXXXX?

From my /var/log/install.log:

2021-03-26 17:47:16-06 rtp-crdaviso-nitro4 system_installd[580]: PackageKit (package_script_service): Preparing to execute script "./postinstall.zsh" in /private/tmp/PKInstallSandbox.Evrpmv/Scripts/com.apple.pkg.InstallAssistant.macOSBigSur.jQNxL0
2021-03-26 17:47:16-06 rtp-crdaviso-nitro4 package_script_service[20253]: PackageKit: Executing script "postinstall.zsh" in /tmp/PKInstallSandbox.Evrpmv/Scripts/com.apple.pkg.InstallAssistant.macOSBigSur.jQNxL0
2021-03-26 17:47:16-06 rtp-crdaviso-nitro4 package_script_service[20253]: Set responsibility to pid: 580, responsible_path: /System/Library/PrivateFrameworks/PackageKit.framework/Versions/A/Resources/system_installd
2021-03-26 17:47:17-06 rtp-crdaviso-nitro4 package_script_service[20253]: ./postinstall.zsh: Linking /Users/crdaviso/Downloads/macadmin-scripts-main/content/downloads/00/60/071-05432-A_QOY2QE0UMR/puuz6c0epc7o0ozyovvi6tjxhzpf6uf04s/InstallAssistant.pkg into /private/tmp/dmg.y9IuqGApplications/Install macOS Big Sur.app/Contents/SharedSupport
2021-03-26 17:47:17-06 rtp-crdaviso-nitro4 package_script_service[20253]: ./postinstall.zsh: ln: /private/tmp/dmg.y9IuqGApplications/Install macOS Big Sur.app/Contents/SharedSupport/SharedSupport.dmg: Operation not permitted
2021-03-26 17:47:17-06 rtp-crdaviso-nitro4 package_script_service[20253]: ./postinstall.zsh: chmod: /private/tmp/dmg.y9IuqGApplications/Install macOS Big Sur.app/Contents/SharedSupport/SharedSupport.dmg: No such file or directory
2021-03-26 17:47:17-06 rtp-crdaviso-nitro4 package_script_service[20253]: ./postinstall.zsh: chown: /private/tmp/dmg.y9IuqGApplications/Install macOS Big Sur.app/Contents/SharedSupport/SharedSupport.dmg: No such file or directory
2021-03-26 17:47:17-06 rtp-crdaviso-nitro4 package_script_service[20253]: ./postinstall.zsh: chflags: /private/tmp/dmg.y9IuqGApplications/Install macOS Big Sur.app/Contents/SharedSupport/SharedSupport.dmg: No such file or directory
2021-03-26 17:47:17-06 rtp-crdaviso-nitro4 package_script_service[20253]: Responsibility set back to self.
2021-03-26 17:47:17-06 rtp-crdaviso-nitro4 system_installd[580]: PackageKit: releasing backupd
2021-03-26 17:47:17-06 rtp-crdaviso-nitro4 system_installd[580]: PackageKit: allow user idle system sleep
2021-03-26 17:47:17-06 rtp-crdaviso-nitro4 system_installd[580]: PackageKit: Install Failed: Error Domain=PKInstallErrorDomain Code=112 "An error occurred while running scripts from the package “InstallAssistant.pkg”." UserInfo={NSFilePath=./postinstall.zsh, NSURL=file://localhost/Users/crdaviso/Downloads/macadmin-scripts-main/content/downloads/00/60/071-05432-A_QOY2QE0UMR/puuz6c0epc7o0ozyovvi6tjxhzpf6uf04s/InstallAssistant.pkg, PKInstallPackageIdentifier=com.apple.pkg.InstallAssistant.macOSBigSur, NSLocalizedDescription=An error occurred while running scripts from the package “InstallAssistant.pkg”.} {
            NSFilePath = "./postinstall.zsh";
            NSLocalizedDescription = "An error occurred while running scripts from the package \U201cInstallAssistant.pkg\U201d.";
            NSURL = "file://localhost/Users/crdaviso/Downloads/macadmin-scripts-main/content/downloads/00/60/071-05432-A_QOY2QE0UMR/puuz6c0epc7o0ozyovvi6tjxhzpf6uf04s/InstallAssistant.pkg";
            PKInstallPackageIdentifier = "com.apple.pkg.InstallAssistant.macOSBigSur";
        }
craig65535 commented 3 years ago

Could also be different behaviour with /usr/sbin/installer on 11.2.3.

craig65535 commented 3 years ago

I found something interesting: running the script from a different directory, e.g. ~/devel/macadmin-scripts, works. It fails when running from ~/Downloads, e.g. ~/Downloads/macadmin-scripts-main.

I noticed the same for ~/Documents. I think this is a SIP thing?

It looks like the script will need to be be updated to refuse to run from certain protected folders.

@blacktop can you confirm that this works on your side?

grahampugh commented 3 years ago

Ah i hadn't seen that you missed the Readme and were running from the Downloads folder. You can't do that. I run it from /Library/Management/erase-install.