jpm-run.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/sh
  2. # -*- mode: sh; tab-width: 4; coding: utf-8 -*-
  3. # vim: ts=4 noet ai ft=sh
  4. # Run an SDK-based Firefox add-on off the source code.
  5. # This file is part of JPM.sh.
  6. # Copyright (C) 2016 the Desktopd developers
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU Affero General Public License as
  10. # published by the Free Software Foundation, either version 3 of the
  11. # License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU Affero General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Affero General Public License
  19. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. # Global branding switch
  21. [ "$JPM_SH_BROWSER_NAME" ] && gBrowserName=$JPM_SH_BROWSER_NAME \
  22. || gBrowserName='Firefox'
  23. [ "$JPM_SH_BROWSER_BIN" ] && gBrowserBinName=$JPM_SH_BROWSER_BIN \
  24. || gBrowserBinName=firefox
  25. # Command line arguments
  26. # May be empty
  27. firefoxBinPath=$1
  28. [ -x "$firefoxBinPath" ] && [ -f "$firefoxBinPath" ] || {
  29. which "$gBrowserBinName" >/dev/null && firefoxBinPath=`which "$gBrowserBinName"` || {
  30. jpmConsoleError "$gBrowserName binary not found. Please specify a correct path."
  31. exit 1
  32. }
  33. }
  34. # JPM.sh directories
  35. gBinDir=`dirname "$0"`
  36. gBinDir=`cd "$gBinDir" ; pwd`
  37. gLibDir=${gBinDir}/../lib
  38. gDepsDir=${gBinDir}/../deps
  39. # Add-on files
  40. gManifestPath=./version_info
  41. # Include needed scripts
  42. . "$gLibDir/defaults.sh"
  43. . "$gLibDir/console.sh"
  44. . "$gLibDir/xpi.sh"
  45. . "$gLibDir/runner.sh"
  46. # Build a .xpi package
  47. # Load manifest data
  48. jpmConsoleNotice "Loading: $gManifestPath"
  49. [ -f "$gManifestPath" ] || {
  50. jpmConsoleError "No such file: $gManifestPath"
  51. exit 1
  52. }
  53. . "$gManifestPath"
  54. xpiId=`jpmXpiGetId`
  55. # Debug build
  56. isProdBuild=''
  57. jpmConsoleNotice "Building .xpi and launching ${gBrowserName}..."
  58. jpmXpiBuild "$isProdBuild" | jpmFirefoxStart "$firefoxBinPath" "$xpiId"
  59. jpmConsoleNotice "Done: jpm-run.sh"