File: cli-policy.sgml

package info (click to toggle)
cli-common 0.10
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 284 kB
  • sloc: perl: 1,198; sh: 103; makefile: 44
file content (1088 lines) | stat: -rw-r--r-- 42,067 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
<!doctype debiandoc public "-//DebianDoc//DTD DebianDoc//EN"> <book>
  <title>
    Debian CLI Policy
  </title>
  
  <author>
    <name>Mirco Bauer</name>
    <email>meebey@debian.org</email>
  </author>
  <author>
    <name>Brandon Hale</name>
    <email>brandon@smarterits.com</email>
  </author>
  <author>
    <name>Sebastian Dr&ouml;ge</name>
    <email>slomo@debian.org</email>
  </author>
  <author>
    <name>Dylan R. E. Moonfire</name>
    <email>debian@mfgames.com</email>
  </author>
  
  <version>
    Version 0.7
  </version>

  <abstract>
    This document lays out basic policies regarding packaging Mono, other
    <qref id="CLR">CLRs</qref> and <qref id="CLI">CLI</qref> based applications/libraries on Debian GNU/Linux.
  </abstract>

  <copyright>
    <copyrightsummary>
      Copyright &copy; 2005-2009 Mirco Bauer
      Copyright &copy; 2005 Brandon Hale
      Copyright &copy; 2006 Sebastian Dr&ouml;ge
      Copyright &copy; 2006 Dylan R. E. Moonfire.
    </copyrightsummary>
    
    <p>This manual is free software; you may redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the Free
    Software Foundation; either version 2, or (at your option) any later
    version.</p>

    <p>This is distributed in the hope that it will be useful, but without
    any warranty; without even the implied warranty of merchantability or
    fitness for a particular purpose. See the GNU General Public License
    for more details.</p>

    <p>A copy of the GNU General Public License is available as
    /usr/share/common-licenses/GPL in the Debian GNU/Linux distribution or
    on the World Wide Web at the GNU General Public Licence. You can also
    obtain it by writing to the Free Software Foundation, Inc., 59 Temple
    Place - Suite 330, Boston, MA 02111-1307, USA.</p>
  </copyright>

  <toc sect1>

  <chapt id="history">
    <heading>Policy History</heading>
    
    <p>Here are the changes to the Debian CLI Policy document.</p>
    
    <p>
      Changes from 0.5.1 to 0.7:
      <list>
        <item><ref id="file-locations">: GAC libraries must now go in /usr/lib/cli/assembly_name-X.Y instead of /usr/lib/cli/upstream_package_name-X.Y, as one source package might ship many assemblies with different ABI versions.  This would produce very confusing directory names.</item>
        <item><ref id="gac-naming-versioning">: Late-GAC install is now mandatory.</item>
        <item><ref id="build-deps">: Added CLI SDKs as alternative to the compiler.</item>
        <item><ref id="signing">: Using the mono.snk key of cli-common-dev is now mandatory if upstream doesn't ship one.</item>
        <item><ref id="mono-disable-shm">: Replaced MONO_SHARED_DIR workaround with cli.make and MONO_DISABLE_SHM.</item>
        <item><ref id="debhelper7-example">: Added debhelper 7 example.</item>
        <item><ref id="gac-policy-files">: Added reference to the mono-api-check tool and made raising clilibs version mandatory.</item>
        <item><ref id=".NET">: Updated URL to Microsoft .NET Guidelines.</item>
        <item><ref id="package-names">: Made upstream tarball names clearer.</item>
        <item><ref id="file-perms">: Replaced find commands with dh + cli.make.</item>
        <item><ref id="gac-naming-versioning">: Removed ASP.NET as it's not a programming language and added IronPython and IronRuby.</item>
      </list>
    </p>
    <p>
      Changes from 0.5.0 to 0.5.1:
      <list>
        <item><ref id="package-names">: Added examples for the different meanings of package name.</item>
        <item><ref id="gac-naming-versioning">: Explicitly name the "lib" prefix requirement for library packages.</item>
      </list>
    </p>
    <p>
      Changes from 0.4.4 to 0.5.0:
      <list>
        <item>Removed DRAFT tag, the policy is now official.</item>
        <item><ref id="build-deps">: Added C# 3.0 to the compiler list.</item>
        <item><ref id="file-perms">: Added dh_clifixperms as alternative to the find command.</item>
      </list>
    </p>
    <p>
      Changes from 0.4.2 to 0.4.3:
      <list>
        <item><ref id="dh_installcligac">: Fixed order of dh_installcligac calls.</item>
        <item><ref id="debhelper-example">: Fixed debhelper example (order).</item>
        <item><ref id="cdbs-example">: Fixed cdbs example (order).</item>
      </list>
    </p>
    <p>
      Changes from 0.4.1 to 0.4.2:
      <list>
        <item><ref id="gac-policy-file-example">: Fixed naming of the policy
        files.</item>
      </list>
    </p>
    <p>
      Changes from 0.4.0 to 0.4.1:
      <list>
        <item><ref id="debhelper-example">: Fixed typo.</item>
      </list>
    </p>    

    <p>
      Changes from 0.3.0 to 0.4.0:
      <list>
        <item><ref id="build-deps">: Added nemerle to the compilers.</item>
        <item><ref id="packaging">: Added a packaging chapter that includes some of the old chapter and some new.</item>
        <item><ref id="gac-library-packaging">: Added informations about signing and policy files.</item>
        <item><ref id="dh_installcligac">: Added and consolidated the
        information on <file>dh_installcligac</file>.</item>
        <item><ref id="file-locations">: Require that files are installed into <file>/usr/lib/package</file> or <file>/usr/lib/cli/package-X.Y</file> now.</item>
      </list>
    </p>    
    <p>
      Changes from 0.2.1 to 0.3.0:
      <list>
        <item><ref id=".NET">: Added URL for the ".NET" term.</item>
        <item><ref id="GAC">: Added explanation of GAC.</item>
        <item><ref id="gac-library-packaging">: Added section for naming of GAC packages.</item>
      </list>
    </p>

    <p>
      Changes from 0.2.0 to 0.2.1:
      <list>
        <item><ref id="cli-common-dev">: Added examples for debhelper and CDBS.</item>
      </list>
    </p>

    <p>
      Changes from 0.1.1 to 0.2.0:
      <list>
        <item><ref id="history">: Added chapter "Policy History"</item>
        <item><ref id="build-deps">: Compiler dependency is no longer strict on
        mono-mcs</item>
        <item><ref id="cli-common-dev">: Note that dh_makeclilibs must be called before
        dh_clideps</item>
        <item><ref id="build-deps">: Moved dh_clideps and dh_makeclilibs into
        their own subsections</item>
        <item><ref id="file-perms">: Added chapter "File Permissions"</item>
        <item><ref id="migrating">: cli-wrapper is now deprecated</item>
        <item><ref id="dll-maps-intro">: Added an external link for
        DllNotFoundException</item>
      </list>
    </p>
  </chapt>
  
  <chapt id="terms">
    <heading>Used Terms</heading>
    
    <p>
      The ".NET" area uses its own set of abbreviations, which can
      look confusing to other people.
      This chapter lists some of the terms along with their explanations:
    </p>
    
    <sect id="CLI">
      <heading>CLI - Common Language Infrastructure</heading>
      
      <p>
        This is what most people mean when they say ".NET".
        The CLI defines mainly the virtual machine, the bytecode and how everything
        works together.  It is both an
    <url id="http://www.iso.org/iso/en/CatalogueDetailPage.CatalogueDetail?CSNUMBER=36769" name="ISO">
        and <url id="http://www.ecma-international.org/publications/standards/Ecma-335.htm" name="ECMA">
        standard.
      </p>
    </sect>
    
    <sect id="CLR">
      <heading>CLR - Common Language Runtime</heading>
     
      <p>
        The CLR is an implementation of the <qref id="CLI">CLI</qref> (often with a lot of add-ons or tools
        for developers). Mono and Microsoft .NET Framework are CLRs.
      </p>
    </sect>
    
    <sect id="CIL">
      <heading>CIL - Common Intermediate Language</heading>
      
      <p>
        The CIL is the format of the bytecode for binaries and libraries
        used by the <qref id="CLI">CLI</qref>.
      </p>
    </sect>
    
    <sect id=".NET">
      <heading>".NET" or long "Microsoft .NET Framework"</heading>
      
      <p>
        The ".NET" word is a Microsoft marketing phrase and mostly is a
        CLR with added Microsoft technologies like: ASP.NET, VB.NET,
        System.Windows.Forms, Passport plus a lot of other things.
      <p>

      <p>
        <strong>We highly discourage from using any form of the word ".NET", it is
        burdened by copyright and marketing.</strong>  We  advice to use the correct
        term instead, which is usually <qref id="CLI">CLI</qref>.
      </p>

      <p>
        If you really want to use the ".NET" term in a correct form please refer to the
        <url id="http://www.microsoft.com/about/legal/trademarks/usage/net.mspx" name="Microsoft .NET Guidelines">.
      </p>
    </sect>

    <sect id="GAC">
      <heading>GAC - Global Assembly Cache</heading>

      <p>
        The GAC contains and manages the libraries for the <qref id="CLR">CLR</qref>.
        It allows users to install multiple versions of the same library and enables loading of
        the right version when an application is executed.
      </p>
      <p>
        Mono stores the GAC at <file>/usr/lib/mono/gac</file>
      </p>
      <p>
        DotGNU Portable.NET stores the GAC at <file>/usr/lib/cscc/lib</file>
      </p>
    </sect>

    <sect id="package-names">
      <heading>Package Names</heading>

      <p>
        There are different set of package names we refer in this policy to.
        Here a list of examples for the different names:
        <list>
           <item>
             assembly (file) names:
             <example>gtk-sharp.dll</example>
             <example>log4net.dll</example>
             <example>FlickrNet.dll</example>
           </item>
           <item>
             (debian) source package names:
             <example>gtk-sharp2</example>
             <example>log4net</example>
             <example>libflickrnet</example>
           </item>
           <item>
             (debian) binary package names:
             <example>libgtk2.0-cil</example>
             <example>libgnome2.0-cil</example>
             <example>liblog4net1.2-cil</example>
             <example>libflickrnet2.1.5-cil</example>
           </item>
           <item>
             upstream package names (a good indicator is the pkg-config file name):
             <example>gtk-sharp-2.0</example>
             <example>log4net</example>
             <example>flickrnet</example>
           </item>
           <item>
             upstream tarball names (without version and file extension):
             <example>gtk-sharp-2.12.9.tar.gz -> gtk-sharp</example>
             <example>log4net-1.2.0-beta8.zip -> log4net</example>
             <example>FlickrNet-25207.zip -> FlickrNet</example>
           </item>
        </list>
      </p>
    </sect>
  </chapt>

  <chapt id="packaging">
    <heading>Packaging Policy</heading>

    <p>
      This section describes the additions to the
      <url id="http://www.debian.org/doc/debian-policy/" name="Debian Policy">
      that are required for <qref id="CLI">CLI</qref> packages.
    </p>

    <sect id="general-packaging">
      <heading>General Packaging</heading>

      <sect1 id="architecture">
        <heading>Architecture</heading>
        
        <p>
          For packages that consist of 100% managed code, "Architecture: all" <em>must</em> be chosen in debian/control.
        </p>
        <p>
          Packages containing a mix of managed and native code <em>must</em> be "Architecure: any" or
          depending on the specific package a more restricted set of architectures is valid.
        </p>
      </sect1>

      <sect1 id="file-locations">
        <heading>File Locations</heading>
        
        <p>
          The package's applications, libraries and meta-data <em>must</em> be installed into
          <file>
            /usr/lib/<qref id="package-names"><var>upstream_package_name</var></qref>
          </file>.
        <p>

        <p>
          Libraries that will be installed into the GAC <em>must</em> be installed into
          <file>
            /usr/lib/cli/<qref id="package-names"><var>assembly_name</var></qref>-X.Y
          </file> 
          (for more details about the X.Y version see <qref id="gac-naming-versioning">GAC versioning</qref>).
          <var>assembly_name</var> is the assembly name without the file extension (.dll).
          The commonly seen
          <file>
            /usr/lib/<strong>mono</strong>/<qref id="package-names"><var>upstream_package_name</var></qref>
          </file>
          path should <em>only</em> be used for Mono project packages.
        </p>

        <p>
          Example path for the <package>log4net</package> package:
          <example>
/usr/lib/cli/log4net-1.2
          </example>
        </p>
        
        <p>
          Never install native "glue" libraries into <file>/usr/lib</file>, instead install them at
          <file>
            /usr/lib/cli/<qref id="package-names"><var>assembly_name</var></qref>-X.Y
          </file>. When moving libraries
          update the references to the new location using a DLL Map.  See the
          <qref id="dll-maps-intro">Mono DLL maps</qref> section for an example.
        </p>

        <p>
          The only exception here is for native libraries that are of wider use;
          can be used other packages. Native libraries should be packaged according to the
          <url id="http://www.netfort.gr.jp/~dancer/column/libpkg-guide/libpkg-guide.html"
          name="Library Packaging Guide"> in a Debian Policy conformant way.
        </p>

        <p>
          You <em>must not</em> install application files (<file>.exe</file>) directly into <file>/usr/bin</file>.
          Instead create a <qref id="wrapper-script-example">wrapper script</qref>
          into <file>/usr/bin</file> to allow them to be run without path and the <file>.exe</file> suffix.
        </p>
      </sect1>

      <sect1 id="file-perms">
        <heading>File Permissions</heading>
     
        <p>
          Source code files (<file>*.cs</file>, <file>*.vb</file>, <file>*.boo</file>, etc.) should be non-executable.
        </p>
        <p>
          Library files (<file>*.dll</file>) should be non-executable.
        </p>
        <p>
          Debug symbol files (<file>*.mdb</file>) should be non-executable.
        </p>
        <p>
          Assembly config files (<file>*.config</file>) should be non-executable.
        </p>
        
        <p>
          Application files (<file>*.exe</file>) <em>must</em> have the executable flag (+x) set to enable
          compatiblity with direct invokation as <file>./foo.exe</file> using Linux's BINFMT support.
        </p>
        
        <p>
          To ensure that all files have correct permissions, you <em>should</em> use Debhelper's
          <file>/usr/bin/dh</file> combined with <file>cli.make</file>.  Otherwise you <em>should</em> add
          <file>dh_clifixperms</file> after <file>dh_fixperms</file> in the binary-* targets of
          <file>debian/rules</file>.
        </p>
      </sect1>

      <sect1 id="build-deps">
        <heading>Build Dependencies</heading>
        
        <p>
          At a minimum, CLI packages <em>should</em> Build-Depends on
          <package>cli-common-dev</package> (&gt;= 0.7) and the
          appropriate CLI compiler or CLI SDK package.
        </p>
        
        <p>
          Current CLI compilers in Debian:
          <list>
            <item>
              C#: <package>mono-mcs</package> (&gt;= 1.0) | c-sharp-compiler
            </item>
            <item>
              C# 2.0: <package>mono-gmcs</package> (&gt;= 1.1.8) | c-sharp-2.0-compiler
            </item>
            <item>
              C# 3.0: <package>mono-gmcs</package> (&gt;= 1.2.5) | c-sharp-3.0-compiler
            </item>
            <item>
              Nemerle: <package>nemerle</package> (&gt;= 0.9)
            </item>
            <item>
              Boo: <package>boo</package> (&gt;= 0.5.6)
            </item>
          </list>

          Current CLI SDKs in Debian:
          <list>
            <item>
              Mono: <package>mono-devel</package> (&gt;= 2.4.2.3)
            </item>
          </list>
        </p>
        
        <p>
          Software that uses Mono via the C interface library
          (<file>libmono.so</file>) or requires the
          <file>/usr/lib/pkgconfig/mono.pc</file> file <em>must</em>
          Build-Depends on libmono-dev (&gt;= 1.0)
        </p>
        
        <p>
          Note that there are architectures for which no <qref id="CLR">CLR</qref> is
          available and thus you may have to restrict the Build-Depends for your
          package to the architectures available.
        </p>

        <p>
          If your package is <file>Architecture: all</file>, you should specify this as Build-Depends-Indep.
          Never put <package>debhelper</package>, <package>cdbs</package>, <package>dpatch</package> and
          <package>quilt</package> into Build-Depends-Indep. See the <url
          id="http://www.debian.org/doc/debian-policy/ch-relationships.html#s-sourcebinarydeps"
          name="Debian Policy Manual"> for more information on this.
        </p>
      </sect1>  
    </sect>

    <sect id="gac-library-packaging">
      <heading>GAC Library Packaging</heading>

      <p>
        Libraries that are installed into the <qref id="GAC">GAC</qref>
        should provide decent ABI stability and be useful for other
        packages.  Otherwise, they should remain private to the package.
      </p>

      <sect1 id="gac-naming-versioning">
        <heading>Naming &amp; Versioning</heading>
        
        <p>
          Libraries that are installed into the <qref id="GAC">GAC</qref> <em>must</em> be
          strong-named, i.e. <qref id="signing">signed</qref>.
        </p>
        
        <p>
          Libraries <em>must</em> to be installed into the GAC at package install
          time (postinst) which is provided by the <qref id="dh_installcligac">dh_installcligac</qref>
          tool of the <package>cli-common-dev</package> package.
        </p>

        <p>
          Each of the libraries in the <qref id="GAC">GAC</qref> has
          an assembly version number that consists of 4 parts (major, minor, build
          and revision number). When loading libraries from the
          <qref id="GAC">GAC</qref> all 4 parts and the public
          signing key fingerprint must match.
        </p>
        
        <p>
          It is general practice and <url
          id="http://msdn.microsoft.com/netframework/programming/deployment/default.aspx?pull=/library/en-us/dndotnet/html/dplywithnet.asp#dplywithnet_version"
          name="recommended by Microsoft">
          that a library is ABI compatible when only the build and
          revision number change and the major and minor number stay
          the same.
        </p>
        
        <p>
          The library package name <em>must</em> be prefixed with <file>lib</file>.
        </p>

        <p>
          To reflect the ABI stability and prevent breakages when a
          ABI-incompatible version is released, a similar solution for
          <url id="http://www.netfort.gr.jp/~dancer/column/libpkg-guide/libpkg-guide.html#naminglibpkg"
          name="native library packages">
          is used. The major and minor number <em>must</em> mirror
          the SONAME version and the resulting package name should be
          <package>libfooX.Y-cil</package>, where X is the major and
          Y the minor number of the assembly version.
        </p>

        <p>
          One notable exception for this naming are assemblies that
          end on a number (Mono.C5 for example).  In this case the
          package should be named <package>libfoo123-X.Y-cil</package>
          (i.e. <package>libmono-c5-0.5-cil</package>) to improve the
          readability.
        </p>
        
        <p>
          The <file>-cil</file> suffix is chosen to prevent confusion
          with native library package names. Never use "sharp" in the package
          name as it does not represent the language, and a <qref id="CLI">CLI</qref>
          library can be used with all <qref id="CLI">CLI</qref> implemented / enabled
          languages such as C#, IronPython, IronRuby, Boo, Nemerle, J#, VB.NET
          (<url id="http://www.mono-project.com/Languages" name="full list">).
        </p>

        <p>
          Unnecessary package renames should be avoided.  Existing
          package names that do not follow this policy should not be
          renamed until the next incompatible ABI change, at which point the
          new naming scheme should be used.
        </p>
        
        <p>
          If the upstream software does not use major and minor
          number to reflect ABI stability or breaks ABI with a change
          in build or revision, the package <em>must</em> be renamed to either
          <package>libfooA.B.C-cil</package> or
          <package>libfooA.B.C.D-cil</package>
          (where A, B, C, D are the complete assembly version numbers),
          depending at which point (major or minor) the breakage occurred.
          All <qref id="gac-policy-files">Policy Files </qref>
          <em>must</em> be dropped at this stage until a new major or minor
          version is released.
        </p>
        
        <p>
          The upstream software may use wildcards in the assembly versions (1.2.* for example) which
          are filled by the compiler with a random value. You <em>must</em> replace these wildcards
          with 0 (1.2.0.0 in the example) to make it possible to use
          <qref id="gac-policy-files">Policy Files</qref> and make predictable version numbers.
        </p>
        
        <p>
          More than one library can be installed in one package but
          it is required that they <em>must</em> all have the same
          assembly version and belong together.
        </p>
      </sect1>

      
      <sect1 id="gac-policy-files">
        <heading>Policy Files</heading>

        <p>
          As explained above a exact match of the version number is required
          to load a library from the <qref id="GAC">GAC</qref>. To override this behaviour
          and make different versions of ABI-compatible library packages really
          ABI-compatible you have to use <url
          id="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcreatingpublisherpolicyfile.asp"
          name="Policy Files">. These files have to be named <file>policy.X.Y.foo.dll</file> (where X and Y
          are the major and minor number of the assembly it should be compatible with),
          it <em>must</em> be signed with the same signing key as the original assembly and it must be installed
          into the <qref id="GAC">GAC</qref>. For information on how to create policy files
          look at the previous Policy Files link or at the <qref id="gac-policy-file-example">example</qref>
          below.
        </p>
        
        <p>
          Overriding the <qref id="GAC">GAC</qref> policy should only
          be done when the different library versions are really
          ABI-compatible. This can be checked using <qref id="api-compat-example">mono-api-check</qref>
          of the <package>mono-devel</package> package.  You <em>must</em> also raise
          the version in the <qref id="clilibs-control-file">clilibs control file</qref>
          to the minimum version when new interfaces/classes/methods were added.
        </p>
      </sect1>

      <sect1 id="clilibs-control-file">
        <heading>clilibs Control File</heading>

        <p>
          The <file>clilibs</file> control file <em>MUST</em> be present in all <qref id="GAC">GAC</qref> library
          packages. It can be created with the <qref id="dh_makeclilibs">dh_makeclilibs</qref>
          helper script and has a format similar to the <file>shlibs</file> file created by <manref name="dh_makeshlibs" section="1">
          and also has a similar use: it is used by
          <qref id="dh_clideps">dh_clideps</qref>
          helper script to find the correct dependencies.
        </p>
        
        <p>
          You <em>should</em> always set the minimum required version of the library in the <file>clilibs</file> file.
        </p>
      </sect1>

      <sect1 id="pkg-config-file">
        <heading>pkg-config File</heading>
        
        <p>
          Many libraries deliver a <file>.pc</file> file for use by
          the <file>pkg-config</file> helper utility, which aids
          other libraries and applications to link against libraries.
        </p>

        <p>
          All GAC library packages should have a pkg-config <file>.pc</file> file located in <file>/usr/lib/pkgconfig</file>.
          The filename <em>must</em> be identical to that shipped by upstream.
        </p>
      </sect1>

      <sect1 id="signing">
        <heading>Signing</heading>

        <p>
          When installing libraries into the <qref id="GAC">GAC</qref> signing
          is required. The signing key should be supplied by upstream.
          If upstream is not supplying the key then you <em>must</em> use the
          <file>mono.snk</file> key from the <package>cli-common-dev</package>
          package. This key <em>must</em> be used for all following versions of
          the library to maintain ABI compatbility.
        </p>

        <p>
          Unnecessary ABI breakages should be avoided.  Existing
          keys shipped by the source package should not be replaced
          (with mono.snk) until the next incompatible ABI change.
        </p>
      </sect1>
    </sect>
    
    <sect id="non-gac-library-packaging">
      <heading>non-GAC Library Packaging</heading>

      <p>
        This includes libraries that are not ABI-stable, may be not
        strong-named and are usually in an early stage of
        development. They <em>must</em> not include a clilibs control file.
      </p>

      <sect1 id="non-gac-naming">
        <heading>Naming</heading>

        <p>
          The package should be named <file>libfoo-cil</file> (without a version in the package name)
          and libraries should not be installed into the <qref id="GAC">GAC</qref> but only
          into <file>/usr/lib/upstream_package_name</file>.
        </p>

        <p>
          Applications using non-GAC libraries <em>must</em> copy the libraries they need into their own
          application directory. You can compare this with static linking of native libraries.
        </p>
      </sect1>      
    </sect>
  </chapt>
  

  <chapt id="mono">
    <heading>Mono Specific Packaging help</heading>
    
    <p>
      This section offers help with common problems encountered when
      packaging Mono-specific applications for Debian.
    </p>
    <sect>
      <heading>Naming</heading>
      
      <p>
        The official name of the Mono Project is: Mono, mono:: or mono.
        To keep this consistent for users, it should
        <em>always</em> be called "Mono" (not MONO, mono, mono:: or mixed
        with the .NET name). The explanation of what Mono is, should be in
        the package <em>long</em> description.
      </p>
    </sect>

    <sect>
      <heading>DLL Maps</heading>
      
      <p>
        Often times, upstream software developers are not
        packagers, and vice versa. Developers do not necessarily test their
        software with packaging issues in mind. The most common problem we
        see from this are missing DLL exceptions.
      </p>

      <sect1 id="dll-maps-intro">
        <heading>Introduction</heading>
        
        <p>
          When Mono code invokes an external library, it usually calls
          something like [DllImport("foo")] which expands "foo" to
          a shared library name such as "libfoo.so" which is then
          searched for in the library search path.
        </p>

        <p>
          In Debian and some other binary Linux distributions,
          packages are split into runtime and developer (-dev)
          packages. Since the versioned library libfoo.so.X is
          usually used at runtime, and libfoo.so is a symlink only
          used when building against the library, the libfoo.so
          symlink is in the libfoo-dev package.
        </p>

        <p>
          When packaging an application which uses libfoo.so normal
          users should not need the -dev packages installed just to
          run the application.  However, Mono defaults to looking for
          the unversioned libfoo.so, which is unavailable in the
          runtime package.
        </p>

        <p>
          When the DLL map is missing or upstream forgets to install
          the DLL map, it will result in a
          <url id="http://www.mono-project.com/DllNotFoundException" name="DllNotFoundException">
          which will stop the execution of the program.
        </p>
      </sect1>
      
      <sect1>
        <heading>Solution: DLL map config file</heading>
          
        <p>
          This can be fixed by creating a DLL map for the application exe or
          for the library DLL that is trying to invoke libfoo.so.
          If libfoo.so is invoked by the DLL bar.dll, create an xml file,
          bar.dll.config to tell Mono which .so should be loaded at runtime.
          bar.dll.config should be installed to the same directory as bar.dll.
        </p>

        <p>
          <example>
          &lt;configuration&gt;
          &lt;dllmap dll="foo" target="libfoo.so.0"/&gt;
          &lt;/configuration&gt;
          </example>
        </p>

        <p>
          A config file can contain as many dllmap directives as are needed.
          If the upstream developer already ships a config file, but it is
          incomplete, you should create a patch against it in your package.
        </p>

        <p>
          Most Mono software developers are very helpful people, and will
          readily accept patches to solve this type of bug if you bring it to
          their attention. Please be sure to inform them of all these changes.
        </p>
      </sect1>
    </sect>
    
    <sect id="mono-disable-shm">
      <heading>MONO_DISABLE_SHM</heading>
      
      <p>
        The Mono runtime uses a shared directory, by default
        <file>~/.wapi</file>. This directory will be created/used when any CLI
        application is executed (like the C# compiler mcs).
      </p>
      
      <p>
        There are 2 problems with this:
        <list>
          <item>In an autobuilder environment often the running user has no home directory.</item>
          <item>Mono uses the wrong home directory when running within fakeroot
          (it tries <file>/root/.wapi</file> instead of <file>$HOME/.wapi
          </file>).</item>
        </list>
      </p>
      
      <p>
        In these cases, the package building will fail, applications
        will hang, die with strange Mono runtime errors or segfault.
        This includes dh_clideps or dh_makeclilibs, since they run
        monodis.
     </p>

     <p>
        The solution is to include <file>cli.make</file> from
        <package>cli-common-dev</package> in <file>debian/rules</file> or
        to manually set the MONO_DISABLE_SHM environment variable.
        <example>
        export MONO_DISABLE_SHM = 1
        </example>
      </p>
    </sect>
  </chapt>

  <chapt id="pnet">
    <heading>DotGNU Portable.NET Packaging help</heading>
    
    <p>
      This section offers help to common problems encountered when
      packaging DotGNU Portable.NET-specific applications for Debian.
    </p>
    <sect>
      <heading>Naming</heading>
      
      <p>
        The official name of the DotGNU Portable.NET project is exactly that.
        To keep this consistent for users, it should be <em>always
        </em> called "DotGNU Portable.NET" (not pnet or Portable.NET).
        The explanation of what DotGNU Portable.NET is, should be in
        the package <em>long</em> description.
      </p>
    </sect>
  </chapt>

  <chapt id="appendix">
    <heading>Appendix</heading>

    <sect id="cli-common-dev">
      <heading>Helper Scripts: cli-common-dev</heading>

      <p>
        When using cli-common-dev and the included dh_* scripts packages <em>must</em>
        Build-Depends on <package>cli-common-dev</package> (&gt;= 0.7)
        (this version may change later, when cli-common-dev has changes which
        are required to be used by all CLI packages, the CLI Policy version will
        represent such changes).
      </p>

      <sect1 id="dh_makeclilibs">
        <heading>dh_makeclilibs</heading>

        <p>
          dh_makeclilibs is used to create the <qref id="clilibs-control-file">clilibs
          control files</qref> which are used later by <file>dh_clideps</file> for this or other
          packages. It <em>must</em> only be used when your package contains libraries
          that other packages may link against.
        </p>
        <p>
          It has the same use (and very similar parameters) to
          <file>dh_makeshlibs</file>. You should always use the
          most minimal version necessary.
        </p>
        <p>
          <em>This program <em>must</em> be called before <file>dh_clideps</file>.</em>
        </p>
        
        <p>
          See <manref name="dh_makeclilibs" section="1"> for details.
        </p>
      </sect1>

      <sect1 id="dh_clideps">
        <heading>dh_clideps</heading>

        <p>
          <file>dh_clideps</file> is used to discover the native and managed dependencies
          of the packages. It uses the <qref id="clilibs-control-file">clilibs
          control files</qref>, the <file>.config</file> of assemblies and the <file>shlibs</file>
          files created by <file>dh_makeshlibs</file>. The discovered dependencies are written into the ${cli:Depends} variable.
        </p>

        <p>
          <em><file>dh_shlibdeps</file> must be run before
          <file>dh_clideps</file>.  <file>dh_makeshlibs</file> and
          <file>dh_makeclilibs</file> must be run before
          <file>dh_clideps</file></em>. If not, when two binary
          packages from the same source package depend on one
          another, <file>dh_clideps</file> will not be able to
          determine the dependencies.
        </p>
        
        <p>
          <file>dh_clideps</file> can remove duplicate dependencies
          created by running <file>dh_clideps</file> and
          <file>dh_shlibsdeps</file> when run given the -d parameter.
        </p>
        
        <p>
          See <manref name="dh_clideps" section="1"> for details.
        </p>
      </sect1>

      <sect1 id="dh_installcligac">
        <heading>dh_installcligac</heading>

        <p>
          <file>dh_installcligac</file> is used to facilitate the
          installation of strong-named assemblies into the various
          caches installed on the user's machine. Its primary purpose is
          to install the assemblies at the point of installation instead
          of pre-packing them inside the Debian package; this is also
          known as late-GAC install.
        </p>

        <p>
          To identify which assemblies need to be installed into the
          GAC, <file>dh_installcligac</file> uses the
          <file>debian/installcligac</file> or the
          <file>debian/packagename.installcligac</file> to list the
          assemblies to install or uninstall at installation or removal
          respectivly.
        </p>

        <p>
          The file format of the <file>installcligac</file> is
          simple: the full installed path of every assembly to install
          into the <qref id="GAC">GAC</qref>. For example, the
          liblog4net1.2-cil package would have this in the
          <file>debian/installcligac</file> file:

          <example>/usr/lib/cli/log4net-1.2/log4net.dll</example>
        </p>

        <p>
          <file>dh_installcligac</file> needs to be called after
          <file>dh_install</file> and before <file>dh_clideps</file>.
          See <manref name="dh_installcligac" section="1"> for details.
        </p>
      </sect1>
    </sect>

    <sect id="examples">
      <heading>Examples</heading>

      <sect1 id="debhelper-example">
        <heading>debhelper 5/6 Example</heading>

        <p>
          For binary-arch packages:
          <example>
binary-arch: build install
	...
	dh_shlibdeps -a
	dh_makeclilibs -a -V
	dh_installcligac -a
	dh_clideps -a
	...
          </example>

          For binary-indep packages:
          <example>
binary-indep: build install
	...
	dh_makeclilibs -i -V
	dh_installcligac -i
	dh_clideps -i
	...
          </example>
        </p>
      </sect1>

      <sect1 id="debhelper7-example">
        <heading>debhelper 7 Example</heading>

        <p>
          With debhelper's 7 <file>/usr/bin/dh</file> you don't need to add any
          extra commands to <file>debian/rules</file> yourself as debhelper has
          an API that allows to extend it.
          <package>cli-common-dev</package> as of version 0.5.7 can extend
          debhelper 7 with all commands that are needed. You can enable this by
          passing "cli" to dh in <file>debian/rules</file> like this:
          <example>
%:
    dh $@ --with cli
          </example>

          That's it, you are done! :-)
        </p>
      </sect1>

      <sect1 id="cdbs-example">
        <heading>cdbs Example</heading>

        <p>
          <example>
common-binary-predeb-arch common-binary-predeb-indep::
	dh_shlibdeps
	dh_makeclilibs -V
	dh_installcligac
	dh_clideps
          </example>
        </p>
      </sect1>

      <sect1 id="wrapper-script-example">
        <heading>Executable Wrapper Script Example</heading>

        <p>
          <example>
#!/bin/sh
exec /usr/bin/cli /usr/lib/package/package.exe "$@"
          </example>
        </p>
      </sect1>

      <sect1 id="api-compat-example">
        <heading>API Compatibility Check Example</heading>
        <p>
          You need to install following packages for this example: mono-devel libmono-sharpzip0.6-cil libmono-sharpzip0.84-cil
          <example>
mono-api-check /usr/lib/mono/gac/ICSharpCode.SharpZipLib/0.6.0.0__1b03e6acf1164f73/ICSharpCode.SharpZipLib.dll \
   /usr/lib/mono/gac/ICSharpCode.SharpZipLib/0.84.0.0__1b03e6acf1164f73/ICSharpCode.SharpZipLib.dll
CLI API Check
Assembly Name:          ICSharpCode.SharpZipLib
Missing Interfaces:     44
Additional Interfaces:  79

The two assemblies you compared are not API compatible!
You must use a new package name!

The new assembly has additional interfaces. You must raise
the minimal version in clilibs!
          </example>
          The mono-api-check wrapper script checks whether there are new public/protected interfaces (where interface
          in this context means namespace, class, method, interface, delegate, etc) or any missing ones. When an interface
          is changed it will show up as missing and additional. You should follow the instructions, in this case you must
          create a new versioned package for the library and raise the minimal version number for the
          <qref id="dh_makeclilibs">dh_makeclilibs</qref> call.
        </p>
      </sect1>

      <sect1 id="gac-policy-file-example">
        <heading>GAC Policy File Example</heading>
        <p>
          <example>
&lt;configuration&gt;
   &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
       &lt;dependentAssembly&gt;
         &lt;assemblyIdentity name="foo" publicKeyToken="35e10195dab3c99f" /&gt;
         &lt;bindingRedirect oldVersion="1.2.0.0-1.2.10.0" newVersion="1.3.0.0"/&gt;
       &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
   &lt;/runtime&gt;
&lt;/configuration&gt;
          </example>
          The above example would be used for a policy file for the "foo" assembly and would tell
          the <qref id="GAC">GAC</qref> that version 1.3.0.0 is compatible with versions 1.2.0.0 to 1.2.10.0.
          You have to compile and install it with
          <example>
al -link:policy.1.2.foo.config -out:policy.1.2.foo.dll -keyfile:path/to/keyfile
gacutil /i policy.1.2.foo.dll
          </example>
        </p>
        <p>
          Keep in mind that the filenames <em>must</em> be
          policy.X.Y.foo.config and policy.X.Y.foo.dll where
          foo is the assembly name and X.Y is the major and minor version
          number you want to be compatible with.
        </p>
      </sect1>
    </sect>

    <sect id="migrating">
      <heading>Migrating Existing Packages</heading>
      
      <p>
        Many CLI packages already exist in Debian, or are in ITP, and conform to
        the deprecated <url id="http://wiki.debian.org/?MonoConventions"
        name="Mono Conventions">.
      </p>

      <p>
        Any <file>debian/rules</file> hacks or patches that exist to redirect
        files to <file>/usr/share/dotnet</file> should be removed, and adjusted
        according to upstream file locations (<file>/usr/lib</file>). See
        <url id="http://wiki.debian.org/?MonoDebianPlan" name="Mono Debian Plan">
        for the rationale behind this change.
      </p>

      <p>
        Also, be sure to replace references to dh_netdepends, dh_makenetlibs, and
        ${net:Depends} with the newer names described in the policy above.
      </p>

      <p>
        Please remove any build-deps on <package>mono-jit</package>,
        <package>mono-mint</package>, <package>mono-utils</package> (this one had
        the dh_* helper scripts which are now in <package>cli-common-dev</package>)
        and <package>libmono-dev</package> (use this one only if the package
        really links against <package>mono</package> or requires the mono.pc
        file).
      </p>
    </sect>
  </chapt>
</book>