strip any trailing slash from hook Pattern entry

Bug #1253855 reported by Chris Wayne
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
click (Ubuntu)
Fix Released
Low
Colin Watson

Bug Description

In trying to make click-hooks for account-plugins, I've run into an issue where I need to pass an entire directory to the click hooks. When I try to apply this (by click registering the newly installed package), it fails with the following:

cwayne@athena:~/Projects/touch_apps$ sudo click register --user cwayne com.ubuntu.developer.cwayne18.ach 0.1
Traceback (most recent call last):
  File "/usr/bin/click", line 83, in <module>
    sys.exit(main())
  File "/usr/bin/click", line 79, in main
    return mod.run(args)
  File "/usr/lib/python3/dist-packages/click/commands/register.py", line 46, in run
    registry.set_version(package, version)
  File "/usr/lib/python3/dist-packages/click/user.py", line 279, in set_version
    self.db, package, old_version, version, user=self.user)
  File "/usr/lib/python3/dist-packages/click/hooks.py", line 383, in package_install_hooks
    package, new_version, app_name, relative_path, user=user)
  File "/usr/lib/python3/dist-packages/click/hooks.py", line 270, in install_package
    user=user, user_db=user_db)
  File "/usr/lib/python3/dist-packages/click/hooks.py", line 249, in _install_link
    osextras.symlink_force(target, link)
  File "/usr/lib/python3/dist-packages/click/osextras.py", line 76, in symlink_force
    unlink_force(link_name)
  File "/usr/lib/python3/dist-packages/click/osextras.py", line 68, in unlink_force
    os.unlink(path)
IsADirectoryError: [Errno 21] Is a directory: '/home/cwayne/.local/share/accounts/qml-plugins/com.ubuntu.developer.cwayne18.ach_ach_0.1/'

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: click 0.4.11
ProcVersionSignature: Ubuntu 3.12.0-3.9-generic 3.12.1
Uname: Linux 3.12.0-3-generic x86_64
ApportVersion: 2.12.7-0ubuntu1
Architecture: amd64
CurrentDesktop: Unity
Date: Thu Nov 21 20:35:06 2013
InstallationDate: Installed on 2013-07-26 (118 days ago)
InstallationMedia: Ubuntu 13.04 "Raring Ringtail" - Release amd64 (20130424)
SourcePackage: click
UpgradeStatus: Upgraded to trusty on 2013-11-21 (0 days ago)

Related branches

Revision history for this message
Chris Wayne (cwayne) wrote :
Revision history for this message
Chris Wayne (cwayne) wrote :

Looking at the trace, it's because it tries to force unlink, which won't work on a directory. Should we check if it's a directory and shutil.rmtree if so?

Chris Wayne (cwayne)
summary: - Click hooks should be able to apply to directories recursively
+ unlink_force fails on directories, making it impossible to pass dirs to
+ click hooks
Revision history for this message
Chris Wayne (cwayne) wrote : Re: unlink_force fails on directories, making it impossible to pass dirs to click hooks

Attaching the click hook that is being used

Revision history for this message
Colin Watson (cjwatson) wrote :

Chris reported on IRC that removing the trailing slash from the Pattern entry fixes this (as expected: the trailing slash means "path resolution is not complete if this is a symlink to a directory"). It might still make sense to be friendly and strip the trailing slash, since it can never have a useful effect here.

Changed in click (Ubuntu):
status: New → Triaged
importance: Undecided → Low
summary: - unlink_force fails on directories, making it impossible to pass dirs to
- click hooks
+ strip any trailing slash from hook Pattern entry
Colin Watson (cjwatson)
Changed in click (Ubuntu):
assignee: nobody → Colin Watson (cjwatson)
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package click - 0.4.14

---------------
click (0.4.14) trusty; urgency=low

  [ Colin Watson ]
  * chroot: Print help if no subcommand given (LP: #1260669).
  * chroot: Recommend debootstrap from click-dev, and explicitly check for
    it in "click chroot create" (LP: #1260487).
  * chroot: Check for root in "create" and "destroy" (LP: #1260671).
  * hooks: Add a ${short-id} expansion to hook patterns; this is valid only
    in user-level or single-version hooks, and expands to a new "short
    application ID" without the version (LP: #1251635).
  * hooks: Strip any trailing slashes from the end of patterns, as they
    cause confusion with symlink-to-directory semantics and can never be
    useful (LP: #1253855).
  * install: Extend the interpretation of "framework" a little bit to allow
    a Click package to declare that it requires multiple frameworks. This
    will allow splitting up the SDK framework declarations into more
    fine-grained elements.
  * Policy version 3.9.5: no changes required.
  * build: Enforce only a single framework declaration for now, by request.

  [ Zoltan Balogh ]
  * Add qtmultimedia5-dev to the SDK framework list.

  [ Dimitri John Ledkov ]
  * chroot: Add "cmake" to build_pkgs, as it is expected for cmake to be
    available on any (Ubuntu) framework.
 -- Colin Watson <email address hidden> Thu, 23 Jan 2014 17:30:54 +0000

Changed in click (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.