Merge lp:~dobey/libubuntuone/srcdir-signing into lp:libubuntuone

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 113
Merged at revision: 112
Proposed branch: lp:~dobey/libubuntuone/srcdir-signing
Merge into: lp:libubuntuone
Diff against target: 92 lines (+25/-13)
4 files modified
.bzrignore (+1/-1)
bindings/mono/AssemblyInfo.cs.in (+1/-1)
bindings/mono/Makefile.am (+19/-11)
configure.ac (+4/-0)
To merge this branch: bzr merge lp:~dobey/libubuntuone/srcdir-signing
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+43668@code.launchpad.net

Commit message

Generate the AssemblyInfo.cs file by replacing @ASSEMBLY_KEYFILE@
Require the sn program and use it to check the signature on the built dll

To post a comment you must log in.
Revision history for this message
Loïc Minier (lool) wrote :

That seems fine; some minor comments:
 * you might want to call sn under LC_ALL=C in case the output is localized at some point -- or test exit code if that's an option, not sure it reports this in the exit code though
 * you might want to send errors to stderr
 * instead of sn | sed + test, you could just grep? e.g.:
if LC_ALL=C $(MONO_SN) -T $< | grep -q '^Public Key Token: '; then \
   echo "Assembly was not properly signed." >&2; \
   exit 1; \
fi

 * I guess it's a personal taste question, but I think sed s/[@]FOO[@]/bar/ is slightly more common in Makefile.am than s/\@FOO\@/bar/

 * the Makefile dependency is weird:
+AssemblyInfo.cs: $(srcdir)/AssemblyInfo.cs.in $(srcdir)/mono.snk Makefile
 I don't think any other generated file depends on Makefile

 * I'm not actually sure why AssemblyInfo.cs depends on mono.snk; I think only the dll needs to do that

 * thanks to VPATH, I think you can actually just depend on the plain simple filenames:
AssemblyInfo.cs: AssemblyInfo.cs.in

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Code looks good, the branch builds correctly.

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

Voting does not meet specified criteria. Required: Approve >= 2, Disapprove == 0, Needs Fixing == 0, Needs Information == 0, Resubmit == 0. Got: 1 Approve.

Revision history for this message
dobey (dobey) wrote :

OK, not using $(srcdir)/ in the dependencies declarations seems to work, so I removed the instances where it was used. I also removed the |sed portion of the check rule, since we're not using it yet, but I figured it might be useful to perhaps use the key id in the future. It's easy to add back though and not calling sed saves us a microsecond of build time.

I made AssemblyInfo.cs depend on mono.snk because we're replacing a string with the path to it. If the source file doesn't exist, it should fail there, rather than wasting time generating the file and then trying to compile all the csharp files into the dll, only to have it fail later. Earlier failures are better.

As for depending on Makefile, anything which generates a file via automatic inclusion in another rule, like we do here, it should depend on Makefile so that the file gets rebuilt if Makefile changes. For instance, if any variables we're inserting into the file with sed like this, have changed, the file needs to be regenerated with the new values.

113. By dobey

Use sn -v to check the signature instead of parsing the -T output

Revision history for this message
dobey (dobey) wrote :

I've also discovered the -vf option now, and decided to use it instead of trying to parse the output. This keeps it language independent and relies on the return value instead.

Revision history for this message
Alejandro J. Cura (alecu) wrote :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2010-08-25 18:35:07 +0000
3+++ .bzrignore 2010-12-14 19:13:48 +0000
4@@ -36,7 +36,7 @@
5
6 libubuntuone-*.tar.*
7
8-bindings/mono/[B-Za-z]*.cs
9+bindings/mono/*.cs
10 bindings/mono/ubuntuone.sources
11 bindings/mono/ubuntuone-api.xml
12 bindings/python/ubuntuone.c
13
14=== renamed file 'bindings/mono/AssemblyInfo.cs' => 'bindings/mono/AssemblyInfo.cs.in'
15--- bindings/mono/AssemblyInfo.cs 2010-03-08 15:30:21 +0000
16+++ bindings/mono/AssemblyInfo.cs.in 2010-12-14 19:13:48 +0000
17@@ -8,4 +8,4 @@
18 [assembly: AssemblyCopyright("Copyright 2010, Jo Shields")]
19 [assembly: AssemblyDescription("Ubuntu One binding for Mono and .NET")]
20 [assembly: AssemblyVersion("1.0.0.0")]
21-[assembly: AssemblyKeyFile("mono.snk")]
22+[assembly: AssemblyKeyFile("@ASSEMBLY_KEYFILE@")]
23
24=== modified file 'bindings/mono/Makefile.am'
25--- bindings/mono/Makefile.am 2010-08-25 18:35:07 +0000
26+++ bindings/mono/Makefile.am 2010-12-14 19:13:48 +0000
27@@ -1,31 +1,39 @@
28 CLEANFILES = \
29- U1MusicStore.cs \
30- OAuthMethod.cs \
31- ObjectManager.cs \
32- PlayLibraryHandler.cs \
33- PreviewMp3Handler.cs \
34- DownloadFinishedHandler.cs \
35- UrlLoadedHandler.cs \
36+ *.cs \
37 ubuntuone.sources \
38 ubuntuone-sharp.dll \
39 ubuntuone-api.xml \
40 ubuntuone-sharp.dll.config
41
42-EXTRA_DIST = ubuntuone.sources.in ubuntuone-api.metadata mono.snk AssemblyInfo.cs
43+EXTRA_DIST = \
44+ AssemblyInfo.cs.in \
45+ mono.snk \
46+ ubuntuone.sources.in \
47+ ubuntuone-api.metadata
48
49 ubuntuonesharpdir = $(libdir)/mono/ubuntuone-sharp-1.0
50 ubuntuonesharp_DATA = ubuntuone-sharp.dll ubuntuone-sharp.dll.config
51
52-ubuntuone-sharp.dll: U1MusicStore.cs
53+check: ubuntuone-sharp.dll
54+ @echo "Checking for valid signature."
55+ if ! $(MONO_SN) -vf $<; then \
56+ echo "Assembly was not properly signed."; \
57+ exit 1; \
58+ fi
59+
60+ubuntuone-sharp.dll: AssemblyInfo.cs U1MusicStore.cs
61 $(MONO_CSC) -target:library -pkg:gtk-sharp-2.0 -out:ubuntuone-sharp.dll *.cs
62
63+AssemblyInfo.cs: AssemblyInfo.cs.in mono.snk Makefile
64+ sed -e "s|\@ASSEMBLY_KEYFILE\@|$(srcdir)/mono.snk|g" < $< > $@
65+
66 U1MusicStore.cs: ubuntuone-api.xml
67 $(MONO_GAPI_CODEGEN) --outdir=. $(GTKSHARP_CFLAGS) --generate $<
68
69-ubuntuone.sources: $(srcdir)/ubuntuone.sources.in
70+ubuntuone.sources: ubuntuone.sources.in Makefile
71 sed -e "s|\@TOP_SRCDIR\@|$(top_srcdir)|g" < $< > $@
72
73-ubuntuone-api.xml: ubuntuone.sources
74+ubuntuone-api.xml: ubuntuone.sources ubuntuone-api.metadata
75 $(MONO_GAPI_PARSER) $<
76 $(MONO_GAPI_FIXUP) --api=$@ --metadata=$(srcdir)/ubuntuone-api.metadata
77
78
79=== modified file 'configure.ac'
80--- configure.ac 2010-11-24 18:05:49 +0000
81+++ configure.ac 2010-12-14 19:13:48 +0000
82@@ -111,6 +111,10 @@
83 AC_MSG_ERROR(could not find gmcs compiler)
84 fi
85
86+AC_PATH_PROG([MONO_SN], [sn], [no])
87+if test "x$MONO_SN" = "xno"; then
88+ AC_MSG_ERROR([could not find sn])
89+fi
90
91 dnl Checks for Python bindings
92 AM_PATH_PYTHON(2.5)

Subscribers

People subscribed via source and target branches