Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre and Post Install Script in electron-fordge pkg maker Not working #3605

Closed
3 tasks done
arjunByldd01 opened this issue May 22, 2024 · 7 comments · Fixed by #3651
Closed
3 tasks done

Pre and Post Install Script in electron-fordge pkg maker Not working #3605

arjunByldd01 opened this issue May 22, 2024 · 7 comments · Fixed by #3651
Assignees

Comments

@arjunByldd01
Copy link

arjunByldd01 commented May 22, 2024

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

6.4

Electron version

26.6.10

Operating system

macOS 14 sonoma

Last known working Electron Forge version

6.4

Expected behavior

I've created an electron app and I'm packaging it using electron forge for Mac. I started creating .pkg files and I also created a shell script and added it to my packager config inside forge.config.js as follows


const config: ForgeConfig = {
  packagerConfig: {
 
    asar: true,
    
    executableName: productName,

    appCopyright: '.......',
 
    icon: path.resolve(rootDir, 'assets/icons/romeano'),
    osxSign: {},
    osxNotarize: {
      tool: 'notarytool',
      appleId: envConfig.APPLE_ID,
      appleIdPassword: envConfig.APPLE_PASSWORD,
      teamId: envConfig.APPLE_TEAM_ID,
    },
  },
  rebuildConfig: {},
  makers: [
   .....
    new MakerPKG({
      scripts: path.resolve(__dirname, 'Scripts'),
    }),
  ],
  plugins: [
    new VitePlugin({
     
      build: .....
      renderer: ....
    }),
  ],
};

export default config;

Inside my scripts folder I have my shell script as postinstall.sh The script works as expected when I run the file through terminal. But the script is not running after installation on the user's devices as expected of it.

Is there something I'm missing or doing wrong? Please help. I updated forge.config.js as mentioned on the electron-forge documentation but the scripts are still not running.

Actual behavior

The script shoould work when installing pkg

Additional information

My script is executable as well I run the chmod command to make it executable as mentioned here

No response

@duchunter
Copy link

Faced the same issue. I have to manually build the pkg file using pkgbuild command to have my postinstall script working

@arjunByldd01 arjunByldd01 changed the title Pre and Post Install Script Not working Pre and Post Install Script in electron-fordge pkg maker Not working Jun 4, 2024
@arjunByldd01
Copy link
Author

@duchunter Can you share your approach. How I can solve this issue ?

@duchunter
Copy link

Sure, after running electron-forge make with MakerPKG (or dmg), you'll get a folder containing the .app file, for example desktop-example-darwin-arm64/DesktopExample.app. Running sudo pkgbuild --root desktop-example-darwin-arm64 --install-location /Applications --scripts /path/to/your/Scripts testapp.pkg will create a new .pkg file. I guess it only solve the preinstall/postinstall problem, if you want to sign or notarize, maybe you have to do them manually as well.

@arjunByldd01
Copy link
Author

arjunByldd01 commented Jun 5, 2024

@duchunter Thanks your approach works for me,
But it it creating issue when I notarize this new .pkg

while notarize pkg it shows invalid status
Waiting for processing to complete.
Current status: Invalid...............

Here what I found in notary log

{
NSLocalizedDescription = "Failed to get notarization info.";
NSLocalizedFailureReason = "You must specify authentication credentials (username/password or apiKey/apiIssuer).";
}

when I notarize initial pkg I specify all credentials. And if I notarize the initial pkg it successfully notarize but since we are creating new pkg it show status invalid

@duchunter
Copy link

@arjunByldd01 Which notary tool did you use? Try this one:
xcrun notarytool submit <your-app.pkg> --apple-id <APPLE_ID> --password <APPLE_PASSWORD> --team-id <APPLE_TEAM_ID> --wait
Can't really help you beyond this point, since everytime I submit my app for notarization, they always response with:

"status": "Rejected",
"statusSummary": "Team is not yet configured for notarization. Please contact Developer Programs Support at developer.apple.com under the topic Development and Technical / Other Development or Technical Questions.",
"statusCode": 7000,

And after 12 months of contacting Developer Programs Support, their answer is still "We are still pending a response from our teams".

@arjunByldd01
Copy link
Author

arjunByldd01 commented Jun 6, 2024

@duchunter Yes, I was using the same tool - xcrun notarytool submit.... and getting status as invalid only for the new pkg that we are creating. If I submit the initial pkg it shows status accepted.

Thanks for the support.

@erickzhao
Copy link
Member

I think this will fix it upstream electron/osx-sign#282

@erickzhao erickzhao added bug blocked/upstream Issues blocked by upstream bugs labels Jul 2, 2024
@erickzhao erickzhao self-assigned this Jul 4, 2024
@erickzhao erickzhao added maker/pkg and removed blocked/upstream Issues blocked by upstream bugs labels Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants