summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2014-07-26 17:08:41 +0200
committerGravatar Martin Szulecki2014-09-19 18:54:02 +0200
commit577538f213cd7132c7450db393fd6fef6bb46b5a (patch)
tree74a21364696e0e2f375613e1c45006d5e6779dc0
parentb7976d2a53b27ec9c42f81a22e91704dbcc5fb53 (diff)
downloadusbmuxd-577538f213cd7132c7450db393fd6fef6bb46b5a.tar.gz
usbmuxd-577538f213cd7132c7450db393fd6fef6bb46b5a.tar.bz2
Add systemd activation autofoo with fallback for udev and manual activation
-rw-r--r--.gitignore3
-rw-r--r--Makefile.am7
-rw-r--r--configure.ac82
-rw-r--r--systemd/Makefile.am21
-rw-r--r--systemd/usbmuxd.service.in7
-rw-r--r--udev/39-usbmuxd.rules.in8
-rw-r--r--udev/Makefile.am20
7 files changed, 136 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore
index 9a9e6e6..4e65390 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,4 +34,5 @@ py-compile
34stamp-h1 34stamp-h1
35src/.libs 35src/.libs
36src/usbmuxd 36src/usbmuxd
37udev/85-usbmuxd.rules 37udev/39-usbmuxd.rules
38systemd/usbmuxd.service
diff --git a/Makefile.am b/Makefile.am
index 4ee9db6..789b9b0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,7 @@
1AUTOMAKE_OPTIONS = foreign 1AUTOMAKE_OPTIONS = foreign
2ACLOCAL_AMFLAGS = -I m4 2ACLOCAL_AMFLAGS = -I m4
3SUBDIRS = src 3SUBDIRS = src $(UDEV_SUB) $(SYSTEMD_SUB)
4 4
5udevrulesdir = /lib/udev/rules.d 5DISTCHECK_CONFIGURE_FLAGS = \
6udevrules_DATA = udev/39-usbmuxd.rules 6 --with-udevrulesdir=$$dc_install_base/$(udevrulesdir) \
7 --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) \ No newline at end of file
diff --git a/configure.ac b/configure.ac
index 6737f6f..33f6151 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,6 +42,45 @@ else
42 fi 42 fi
43fi 43fi
44 44
45AC_ARG_WITH([udevrulesdir],
46 AS_HELP_STRING([--with-udevrulesdir=DIR],
47 [Directory for udev rules]),
48 [],
49 [with_udevrulesdir=auto])
50if test "x$with_udevrulesdir" = "xauto"; then
51 udevdir=$($PKG_CONFIG --variable=udevdir udev)
52 if test "x$udevdir" != "x"; then
53 with_udevrulesdir=$udevdir"/rules.d"
54 else
55 with_udevrulesdir=$prefix/lib/udev/rules.d
56 fi
57fi
58AC_SUBST([udevrulesdir], [$with_udevrulesdir])
59
60AC_ARG_WITH([systemd],
61 [AS_HELP_STRING([--without-systemd],
62 [do not build with systemd support @<:@default=yes@:>@])],
63 [with_systemd=no],
64 [with_systemd=yes])
65
66AC_ARG_WITH([systemdsystemunitdir],
67 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
68 [directory for systemd service files])],
69 [with_systemdsystemunitdir=$withval],
70 [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
71
72if test "x$with_systemdsystemunitdir" != xno; then
73 AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
74fi
75AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno -a "x$with_systemd" = "xyes" ])
76
77if test "x$with_systemd" = xyes; then
78 udev_activation_rule="TAG+=\"systemd\", ENV{SYSTEMD_WANTS}=\"usbmuxd.service\""
79else
80 udev_activation_rule="RUN+=\"@sbindir@/usbmuxd -u -U usbmux\""
81fi
82AC_SUBST(udev_activation_rule)
83
45# Checks for header files. 84# Checks for header files.
46AC_HEADER_STDC 85AC_HEADER_STDC
47AC_CHECK_HEADERS([stdint.h stdlib.h string.h]) 86AC_CHECK_HEADERS([stdint.h stdlib.h string.h])
@@ -61,20 +100,40 @@ AC_CHECK_FUNCS([strcasecmp strdup strerror strndup stpcpy])
61 100
62# Check for operating system 101# Check for operating system
63AC_MSG_CHECKING([whether to enable WIN32 build settings]) 102AC_MSG_CHECKING([whether to enable WIN32 build settings])
103UDEV_SUB=
104SYSTEMD_SUB=
64case ${host_os} in 105case ${host_os} in
65 *mingw32*|*cygwin*) 106 *mingw32*|*cygwin*)
66 win32=true 107 win32=true
67 AC_MSG_RESULT([yes]) 108 AC_MSG_RESULT([yes])
68 AC_CHECK_TOOL([WINDRES], [windres], AC_MSG_ERROR([windres not found])) 109 AC_CHECK_TOOL([WINDRES], [windres], AC_MSG_ERROR([windres not found]))
69 AC_SUBST(WINDRES) 110 AC_SUBST(WINDRES)
111 activation_method="manual"
112 ;;
113 darwin*)
114 win32=false
115 AC_MSG_RESULT([no])
116 activation_method="launchd"
70 ;; 117 ;;
71 *) 118 *)
72 win32=false 119 win32=false
73 AC_MSG_RESULT([no]) 120 AC_MSG_RESULT([no])
121 UDEV_SUB=udev
122 activation_method="systemd"
123 if test "x$with_systemd" != "xyes"; then
124 echo "*** Note: support for systemd activation has been disabled, using udev activation instead ***"
125 activation_method="udev"
126 else
127 AC_DEFINE(WITH_SYSTEMD, 1, [Define to enable systemd support])
128 SYSTEMD_SUB=systemd
129 fi
74 ;; 130 ;;
75esac 131esac
76AM_CONDITIONAL(WIN32, test x$win32 = xtrue) 132AM_CONDITIONAL(WIN32, test x$win32 = xtrue)
77 133
134AC_SUBST([UDEV_SUB])
135AC_SUBST([SYSTEMD_SUB])
136
78AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-g -Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter") 137AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-g -Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter")
79AC_SUBST(GLOBAL_CFLAGS) 138AC_SUBST(GLOBAL_CFLAGS)
80 139
@@ -83,15 +142,30 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
83AC_OUTPUT([ 142AC_OUTPUT([
84Makefile 143Makefile
85src/Makefile 144src/Makefile
86udev/39-usbmuxd.rules 145udev/Makefile
146systemd/Makefile
87]) 147])
88 148
89echo " 149echo -n "
90Configuration for $PACKAGE $VERSION: 150Configuration for $PACKAGE $VERSION:
91------------------------------------------- 151-------------------------------------------
92 152
93 Install prefix: ...........: $prefix 153 install prefix ............: $prefix
94 Preflight worker support ..: $have_limd 154 preflight worker support ..: $have_limd
155 activation method .........: $activation_method
156"
157
158if test "x$activation_method" = "xsystemd"; then
159 echo -n " systemd unit directory ....: ${systemdsystemunitdir}
160"
161fi
162
163if test -n "$udevrulesdir"; then
164 echo -n " udev rules directory ......: ${udevrulesdir}
165"
166fi
167
168echo " compiler ..................: ${CC}
95 169
96 Now type 'make' to build $PACKAGE $VERSION, 170 Now type 'make' to build $PACKAGE $VERSION,
97 and then 'make install' for installation. 171 and then 'make install' for installation.
diff --git a/systemd/Makefile.am b/systemd/Makefile.am
new file mode 100644
index 0000000..6626d60
--- /dev/null
+++ b/systemd/Makefile.am
@@ -0,0 +1,21 @@
1edit = \
2 $(SED) -r \
3 -e 's|@sbindir[@]|$(sbindir)|g' \
4 -e 's|@localstatedir[@]|$(localstatedir)|g' \
5 < $< > $@ || rm $@
6
7if HAVE_SYSTEMD
8
9systemdsystemunit_DATA = \
10 usbmuxd.service
11
12usbmuxd.service: usbmuxd.service.in
13 $(edit)
14
15EXTRA_DIST = \
16 usbmuxd.service.in
17
18CLEANFILES = \
19 usbmuxd.service
20
21endif
diff --git a/systemd/usbmuxd.service.in b/systemd/usbmuxd.service.in
new file mode 100644
index 0000000..761b39a
--- /dev/null
+++ b/systemd/usbmuxd.service.in
@@ -0,0 +1,7 @@
1[Unit]
2Description=Socket daemon for the usbmux protocol used by Apple devices
3
4[Service]
5Type=simple
6ExecStart=@sbindir@/usbmuxd -u -U usbmux -f
7PIDFile=@localstatedir@/run/usbmuxd.pid
diff --git a/udev/39-usbmuxd.rules.in b/udev/39-usbmuxd.rules.in
index f4eb66f..91b14db 100644
--- a/udev/39-usbmuxd.rules.in
+++ b/udev/39-usbmuxd.rules.in
@@ -1,7 +1,7 @@
1# usbmuxd ("Apple Mobile Device" muxer listening on /var/run/usbmuxd) 1# usbmuxd (Apple Mobile Device Muxer listening on /var/run/usbmuxd)
2 2
3# Initialize iOS devices into "deactivated" USB configuration state and run usbmuxd 3# Initialize iOS devices into "deactivated" USB configuration state and activate usbmuxd
4ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="05ac", ATTR{idProduct}=="12[9a][0-9a-f]", ENV{USBMUX_SUPPORTED}="1", ATTR{bConfigurationValue}="0", OWNER="usbmux", RUN+="@prefix@/sbin/usbmuxd -u -U usbmux" 4ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="05ac", ATTR{idProduct}=="12[9a][0-9a-f]", ENV{USBMUX_SUPPORTED}="1", ATTR{bConfigurationValue}="0", OWNER="usbmux", @udev_activation_rule@
5 5
6# Exit usbmuxd when the last device is removed 6# Exit usbmuxd when the last device is removed
7ACTION=="remove", SUBSYSTEM=="usb", ENV{PRODUCT}=="5ac/12[9a][0-9a-f]/*", ENV{INTERFACE}=="255/*", RUN+="@prefix@/sbin/usbmuxd -x" 7ACTION=="remove", SUBSYSTEM=="usb", ENV{PRODUCT}=="5ac/12[9a][0-9a-f]/*", ENV{INTERFACE}=="255/*", RUN+="@sbindir@/usbmuxd -x"
diff --git a/udev/Makefile.am b/udev/Makefile.am
new file mode 100644
index 0000000..95f565d
--- /dev/null
+++ b/udev/Makefile.am
@@ -0,0 +1,20 @@
1edit = \
2 $(SED) -r \
3 -e 's|@udev_activation_rule[@]|$(udev_activation_rule)|g' \
4 -e 's|@sbindir[@]|$(sbindir)|g' \
5 < $< > $@ || rm $@
6
7udevrules_DATA = \
8 39-usbmuxd.rules
9
1039-usbmuxd.rules: 39-usbmuxd.rules.in
11 $(edit)
12
13EXTRA_DIST = \
14 39-usbmuxd.rules.in
15
16MAINTAINERCLEANFILES = \
17 39-usbmuxd.rules
18
19CLEANFILES = \
20 39-usbmuxd.rules