Skip to content

Instantly share code, notes, and snippets.

@JMSwag
Forked from ben-willmore/onedir.patch
Created May 16, 2017 22:23
Show Gist options
  • Select an option

  • Save JMSwag/12ac6057fd41c72e2e8b47fa65952b56 to your computer and use it in GitHub Desktop.

Select an option

Save JMSwag/12ac6057fd41c72e2e8b47fa65952b56 to your computer and use it in GitHub Desktop.

Revisions

  1. @ben-willmore ben-willmore created this gist May 14, 2017.
    52 changes: 52 additions & 0 deletions onedir.patch
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    diff --git a/pyupdater/client/updates.py b/pyupdater/client/updates.py
    index f610963..547e60e 100644
    --- a/pyupdater/client/updates.py
    +++ b/pyupdater/client/updates.py
    @@ -624,16 +624,29 @@ class AppUpdate(LibUpdate):
    temp_dir = get_mac_dot_app_dir(self._current_app_dir)
    self._current_app_dir = temp_dir

    - app_update = os.path.join(self.update_folder, self.name)
    + #app_update = os.path.join(self.update_folder, self.name)
    + # assume the .tar.gz contains exactly one file or directory in the
    + # top level
    + update_dir_or_file = os.listdir(self.update_folder)[0]
    + app_update = os.path.join(self.update_folder, update_dir_or_file)
    +
    + current_app_dir = self._current_app_dir

    # Must be dealing with Mac .app application
    if not os.path.exists(app_update):
    app_update += '.app'

    + elif os.path.isdir(app_update):
    + # then we'll assume that the binary is only one directory
    + # deep in the tar.gz. The general case is tricky (e.g. if
    + # the binary is one dir deep in the new version, but two
    + # dirs deep in the old version...)
    + current_app_dir = os.path.dirname(self._current_app_dir)
    +
    log.debug('Update Location:\n%s', os.path.dirname(app_update))
    log.debug('Update Name: %s', os.path.basename(app_update))

    - current_app = os.path.join(self._current_app_dir, self.name)
    + current_app = os.path.join(current_app_dir, update_dir_or_file)

    # Must be dealing with Mac .app application
    if not os.path.exists(current_app):
    @@ -646,12 +659,12 @@ class AppUpdate(LibUpdate):
    if os.path.exists(current_app):
    remove_any(current_app)

    - log.debug('Moving app to new location:\n\n%s', self._current_app_dir)
    - shutil.move(app_update, self._current_app_dir)
    + log.debug('Moving app to new location:\n\n%s', current_app_dir)
    + shutil.move(app_update, current_app_dir)

    def _restart(self):
    log.debug('Restarting')
    - current_app = os.path.join(self._current_app_dir, self.name)
    + current_app = os.path.join(self._current_app_dir, os.path.basename(sys.argv[0]))
    if get_system() == 'mac':
    # Must be dealing with Mac .app application
    if not os.path.exists(current_app):