aboutsummaryrefslogtreecommitdiff
path: root/mod/module.cli
blob: a107ffeca5525a0c2182f8707e60fd4cbc539f52 (plain)
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
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
// file      : mod/options.cli -*- C++ -*-
// license   : MIT; see accompanying LICENSE file

include <map>;
include <regex>;

include <libbpkg/manifest.hxx>; // repository_location
include <libbbot/manifest.hxx>; // interactive_mode

include <web/xhtml/fragment.hxx>;

include <libbrep/types.hxx>;

include <mod/options-types.hxx>;

namespace brep
{
  // Web handler configuration options.
  //
  namespace options
  {
    // Option groups.
    //
    class repository_email
    {
      string email
      {
        "<email>",
        "Repository email. This email is used for the \cb{From:} header in
         emails send by \cb{brep} (for example, build failure notifications)."
      }
    };

    class repository_url
    {
      string host
      {
        "<host>",
        "Repository host. It specifies the scheme and the host address (but
         not the root path; see \cb{root} below) that will be used whenever
         \cb{brep} needs to construct an absolute URL to one of its locations
         (for example, a link to a build log that is being send via email)."
      }

      dir_path root = "/"
      {
        "<path>",
        "Repository root. That is, this is the part of the URL between the
         host name and the start of the repository. For example, root value
         '\cb{/pkg}' means the repository URL is \cb{http://example.org/pkg/}.
         Specify '\cb{/}' to use the web server root
         (\cb{http://example.org/})."
      }
    };

    class build_email_notification: repository_email, repository_url
    {
      std::map<string, build_email> build-toolchain-email
      {
        "<name>=<mode>",
        "Enable or disable package build notification emails. The valid <mode>
         values are \cb{none}, \cb{latest}, and \cb{all}. If \cb{all} is
         specified for a toolchain name, then emails are sent according to the
         \cb{build-*email} package manifest values when all versions of a
         package are built with this toolchain. If \cb{latest} is specified,
         then for this toolchain name the emails are only sent for the latest
         version of a package. If \cb{none} is specified, then no emails are
         sent for this toolchain name. By default the \cb{latest} mode is
         assumed. Repeat this option to enable/disable emails for multiple
         toolchains. See \l{bpkg#manifest-package Package Manifest} for
         details on \cb{build-*email} values."
      }
    };

    class handler
    {
      string tenant-name = "tenant"
      {
        "<name>",
        "Name to call the tenant values on web pages. If not specified, then
         \cb{tenant} is used."
      }

      uint16_t verbosity = 0
      {
        "<level>",
        "Trace verbosity level. Level 0 disables tracing, which is also the
         default."
      }
    };

    class openssl_options
    {
      path openssl = "openssl"
      {
        "<path>",
        "The openssl program to be used for crypto operations. You can also
         specify additional options that should be passed to the openssl
         program with \cb{openssl-option}. If the openssl program is not
         explicitly specified, then \cb{brep} will use \cb{openssl} by
         default."
      }

      strings openssl-option
      {
        "<opt>",
        "Additional option to be passed to the openssl program (see
         \cb{openssl} for details). Repeat this option to specify multiple
         openssl options."
      }

      strings openssl-envvar
      {
        "<name>[=value]",
        "Environment variable to be set (<name>=<value>) or unset (just
         <name>) for the openssl program (see \cb{openssl} for details).
         Repeat this option to specify multiple openssl variables. Note
         that unspecified variables are inherited from the web server
         process.

         You need to at least set the \cb{RANDFILE} environment variable
         to change the default location of the openssl program seed file
         and maybe also the \cb{OPENSSL_CONF} variable if you would like
         to use a custom openssl configuration file."
      }
    };

    class package_db
    {
      string package-db-user
      {
        "<user>",
        "Package database login user name. If not specified, then operating
         system (login) name is used. See also \cb{package-db-role}."
      }

      string package-db-role = "brep"
      {
        "<user>",
        "Package database execution user name. If not empty then the login
         user will be switched (with \cb{SET ROLE}) to this user prior to
         executing any statements. If not specified, then \cb{brep} is used."
      }

      string package-db-password
      {
        "<pass>",
        "Package database password. If not specified, then login without
         password is expected to work."
      }

      string package-db-name = "brep_package"
      {
        "<name>",
        "Package database name. If not specified, then \cb{brep_package} is
         used by default."
      }

      string package-db-host
      {
        "<host>",
        "Package database host name, address, or socket. If not specified, then
         connect to \cb{localhost} using the operating system-default
         mechanism (Unix-domain socket, etc)."
      }

      uint16_t package-db-port = 0
      {
        "<port>",
        "Package database port number. If not specified, the default port is
         used."
      }

      size_t package-db-max-connections = 5
      {
        "<num>",
        "The maximum number of concurrent package database connections per web
         server process. If 0, then no limitation is applied. The default is
         5."
      }

      size_t package-db-retry = 10
      {
        "<num>",
        "The maximum number of times to retry package database transactions in
         the face of recoverable failures (deadlock, loss of connection, etc).
         The default is 10."
      }
    };

    class build: openssl_options
    {
      path build-config
      {
        "<buildtab>",
        "Build configuration file. If not specified, then the package building
         functionality will be disabled. If specified, then the build database
         must be configured (see \cb{build-db-*}). The \cb{brep} instance
         needs to be restarted after modifying <buildtab> for the changes to
         take effect."
      }

      dir_path build-bot-agent-keys
      {
        "<dir>",
        "Directory containing build bot agent public keys. If specified, then
         \cb{brep} will perform agent authentication and will reject build
         results from unauthenticated ones. If not specified, then build
         results are accepted from all agents (which will be a security
         risk if the \cb{brep} instance is publicly accessible).

         The directory is expected to contain one PEM-encoded public key
         per file with the \cb{.pem} extension. All other files and
         subdirectories are ignored. The \cb{brep} instance needs to be
         restarted after adding new key files for the changes to take effect."
      }

      size_t build-forced-rebuild-timeout = 600
      {
        "<seconds>",
        "Time to wait before considering a package for a forced rebuild. Must
         be specified in seconds. Default is 10 minutes."
      }

      size_t build-soft-rebuild-timeout = 86400
      {
        "<seconds>",
        "Time to wait before considering a package for a soft rebuild (only to
         be performed if the build environment or any of the package
         dependencies have changed). Must be specified in seconds. The special
         zero value disables soft rebuilds. Default is 24 hours"
      }

      size_t build-alt-soft-rebuild-timeout
      {
        "<seconds>",
        "Alternative package soft rebuild timeout to use instead of the soft
         rebuild timeout (see \cb{build-soft-rebuild-timeout} for details)
         during the time interval specified with the
         \cb{build-alt-soft-rebuild-start} and
         \cb{build-alt-soft-rebuild-stop} options. Must be specified in
         seconds. Default is the time interval length plus
         \c{(\b{build-soft-rebuild-timeout} - 24h)} if soft rebuild timeout
         is greater than 24 hours (thus the rebuild is only triggered within
         the last 24 hours of the \cb{build-soft-rebuild-timeout} expiration)."
      }

      duration build-alt-soft-rebuild-start
      {
        "<hours>:<minutes>",
        "The start time of the alternative package soft rebuild timeout (see
         \cb{build-alt-soft-rebuild-timeout} for details). Must be specified
         as a time of day in the local timezone. The
         \cb{build-alt-soft-rebuild-start} and
         \cb{build-alt-soft-rebuild-stop} options must be either both
         specified or absent. If unspecified, then no alternative rebuild
         timeout will be used."
      }

      duration build-alt-soft-rebuild-stop
      {
        "<hours>:<minutes>",
        "The end time of the alternative package soft rebuild timeout (see
         \cb{build-alt-soft-rebuild-timeout} for details). Must be specified
         as a time of day in the local timezone. If it is less than the
         \cb{build-alt-soft-rebuild-start} option value, then the time
         interval extends through midnight. The
         \cb{build-alt-soft-rebuild-start} and
         \cb{build-alt-soft-rebuild-stop} options must be either both
         specified or absent. If unspecified, then no alternative rebuild
         timeout will be used."
      }

      size_t build-hard-rebuild-timeout = 604800
      {
        "<seconds>",
        "Time to wait before considering a package for a hard rebuild (to be
         performed unconditionally). Must be specified in seconds. The special
         zero value disables hard rebuilds. Default is 7 days."
      }

      size_t build-alt-hard-rebuild-timeout
      {
        "<seconds>",
        "Alternative package hard rebuild timeout. The semantics is the
         same as for the \cb{build-alt-soft-rebuild-timeout} option but
         for the \cb{build-hard-rebuild-timeout} option."
      }

      duration build-alt-hard-rebuild-start
      {
        "<hours>:<minutes>",
        "The start time of the alternative package hard rebuild timeout (see
         \cb{build-alt-hard-rebuild-timeout} for details). The semantics is
         the same as for the \cb{build-alt-soft-rebuild-start} option but
         for the \cb{build-hard-rebuild-timeout} option."
      }

      duration build-alt-hard-rebuild-stop
      {
        "<hours>:<minutes>",
        "The end time of the alternative package hard rebuild timeout (see
         \cb{build-alt-hard-rebuild-timeout} for details). The semantics is
         the same as for the \cb{build-alt-soft-rebuild-stop} option but
         for the \cb{build-hard-rebuild-timeout} option."
      }

      size_t build-queued-timeout = 30
      {
        "<seconds>",
        "Time to wait before assuming the \cb{queued} notifications are
         delivered for package CI requests submitted via third-party services
         (GitHub, etc). During this time a package is not considered for a
         build. Must be specified in seconds. Default is 30 seconds."
      }
    };

    class build_db
    {
      string build-db-user
      {
        "<user>",
        "Build database login user name. If not specified, then operating
         system (login) name is used. See also \cb{build-db-role}."
      }

      string build-db-role = "brep"
      {
        "<user>",
        "Build database execution user name. If not empty then the login
         user will be switched (with \cb{SET ROLE}) to this user prior to
         executing any statements. If not specified, then \cb{brep} is used."
      }

      string build-db-password
      {
        "<pass>",
        "Build database password. If not specified, then login without
         password is expected to work."
      }

      string build-db-name = "brep_build"
      {
        "<name>",
        "Build database name. If not specified, then \cb{brep_build} is used
         by default."
      }

      string build-db-host
      {
        "<host>",
        "Build database host name, address, or socket. If not specified, then
         connect to \cb{localhost} using the operating system-default
         mechanism (Unix-domain socket, etc)."
      }

      uint16_t build-db-port = 0
      {
        "<port>",
        "Build database port number. If not specified, the default port is
         used."
      }

      size_t build-db-max-connections = 5
      {
        "<num>",
        "The maximum number of concurrent build database connections per web
         server process. If 0, then no limitation is applied. The default is
         5."
      }

      size_t build-db-retry = 10
      {
        "<num>",
        "The maximum number of times to retry build database transactions in
         the face of recoverable failures (deadlock, loss of connection, etc).
         The default is 10."
      }
    };

    class build_upload
    {
      std::map<string, dir_path> upload-data
      {
        "<type>=<dir>",
        "The directory to save upload data to for the specified upload type.
         If unspecified, the build artifacts upload functionality will be
         disabled for this type. See \l{brep The \cb{build2} Repository
         Interface Manual} for more information on build artifacts upload.

         Note that the directory path must be absolute and the directory
         itself must exist and have read, write, and execute permissions
         granted to the user that runs the web server."
      }

      std::map<string, size_t> upload-max-size
      {
        "<type>=<bytes>",
        "The maximum size of the upload data accepted for the specified upload
         type. Note that currently the entire upload request is read into
         memory. The default is 10M."
      }

      std::map<string, string> upload-email
      {
        "<type>=<email>",
        "The build artifacts upload email. If specified, the upload request
         and result manifests will be sent to this address. See \l{brep The
         \cb{build2} Repository Interface Manual} for more information."
      }

      std::map<string, path> upload-handler
      {
        "<type>=<path>",
        "The handler program to be executed on build artifacts upload of the
         specified type. The handler is executed as part of the HTTP request
         and is passed additional arguments that can be specified with
         \cb{upload-handler-argument} followed by the absolute path to the
         upload directory (\cb{upload-data}). See \l{brep The \cb{build2}
         Repository Interface Manual} for more information. Note that the
         program path must be absolute."
      }

      std::multimap<string, string> upload-handler-argument
      {
        "<type>=<arg>",
        "Additional arguments to be passed to the upload handler program for
         the specified upload type (see \cb{upload-handler} for details).
         Repeat this option to specify multiple arguments."
      }

      std::map<string, size_t> upload-handler-timeout
      {
        "<type>=<seconds>",
        "The upload handler program timeout in seconds for the specified
         upload type. If specified and the handler does not exit in the
         allotted time, then it is killed and its termination is treated as
         abnormal."
      }

      std::multimap<string, string> upload-toolchain-exclude
      {
        "<type>=<name>",
        "Disable upload of the specified type for the specified toolchain
         name. Repeat this option to disable uploads for multiple toolchains."
      }

      std::multimap<string, string> upload-repository-exclude
      {
        "<type>=<name>",
        "Disable upload of the specified type for packages from the repository
         with the specified canonical name. Repeat this option to disable
         uploads for multiple repositories."
      }
    };

    class page
    {
      web::xhtml::fragment logo
      {
        "<xhtml>",
        "Web page logo. It is displayed in the page header aligned to the left
         edge. The value is treated as an XHTML5 fragment."
      }

      vector<page_menu> menu
      {
        "<label=link>",
        "Web page menu. Each entry is displayed in the page header in the
         order specified and aligned to the right edge. A link target that
         starts with '\cb{/}' or contains '\cb{:}' is used as is. Otherwise,
         it is prefixed with the repository web interface root."
      }
    };

    class search
    {
      uint16_t search-page-entries = 20
      {
        "<num>",
        "Number of packages per page. The default is 20."
      }

      uint16_t search-pages = 5
      {
        "<num>",
        "Number of pages in navigation (pager). The default is 5."
      }
    };

    class package
    {
      uint16_t package-description = 500
      {
        "<len>",
        "Number of package description characters to display in brief pages.
         The default is 500 (~ 80 characters * 6 lines)."
      }

      uint16_t package-changes = 5000
      {
        "<len>",
        "Number of package changes characters to display in brief pages. The
         default is 5000 (~ 80 chars x 60 lines)."
      }
    };

    // Handler options.
    //

    class packages: search, package_db, page, repository_url, handler
    {
      string search-title = "Packages"
      {
        "<text>",
        "Package search page title. It is placed inside XHTML5 <title>
         element."
      }

      web::xhtml::fragment search-description
      {
        "<xhtml>",
        "Package search page description. If specified, it is displayed
         before the search form on the first page only. The value is
         treated as an XHTML5 fragment."
      }
    };

    class package_details: package, package_db,
                           search,
                           page,
                           repository_url,
                           handler
    {
    };

    class package_version_details: package, package_db,
                                   build, build_db,
                                   page,
                                   repository_url,
                                   handler
    {
      dir_path bindist-root
      {
        "<dir>",
        "The root directory where the uploaded binary distribution packages
         are saved to under the following directory hierarchy:

         \
         [<tenant>/]<distribution>/<os-release>/<project>/<package>/<version>/<package-config>
         \

         The package configuration directory symlinks that match these paths
         are mapped to web URLs based on the \cb{bindist-url} value and
         displayed on the package version details page. If this option is
         specified, then \cb{bindist-url} must be specified as well."
      }

      string bindist-url
      {
        "<url>",
        "The root URL of the directory specified with the \cb{bindist-root}
         option. This option must be specified if \cb{bindist-root} is
         specified."
      }
    };

    class repository_details: package_db, page, repository_url, handler
    {
    };

    class build_task: build, build_db,
                      build_upload,
                      build_email_notification,
                      handler
    {
      size_t build-task-request-max-size = 102400
      {
        "<bytes>",
        "The maximum size of the build task request manifest accepted. Note
         that the HTTP POST request body is cached to retry database
         transactions in the face of recoverable failures (deadlock, loss of
         connection, etc). The default is 100K."
      }

      size_t build-result-timeout = 10800
      {
        "<seconds>",
        "Time to wait before considering the expected task result lost. Must be
         specified in seconds. The default is 3 hours."
      }

      vector<pair<std::regex, string>> build-interactive-login
      {
        "</regex/replacement/>",
        "Regular expressions for transforming the interactive build login
         information, for example, into the actual command that can be used
         by the user. The regular expressions are matched against the
         \"<agent>\ <interactive-login>\" string containing the respective
         task request manifest values. The first matching expression is used
         for the transformation. If no expression matches, then the task
         request is considered invalid, unless no expressions are specified.
         Repeat this option to specify multiple expressions."
      }

      build_order build-package-order = build_order::stable
      {
        "<order>",
        "Order in which packages are considered for build. The valid <order>
         values are \cb{stable} and \cb{random}. If not specified, then
         \cb{stable} is assumed. Note that interactive builds are always
         preferred."
      }
    };

    class build_result: build, build_db,
                        build_email_notification,
                        handler
    {
      size_t build-result-request-max-size = 10485760
      {
        "<bytes>",
        "The maximum size of the build result manifest accepted. Note that the
         HTTP POST request body is cached to retry database transactions in the
         face of recoverable failures (deadlock, loss of connection, etc). The
         default is 10M."
      }
    };

    class build_log: build, build_db, repository_url, handler
    {
    };

    class build_force: build, build_db, handler
    {
    };

    class builds: build, build_db, page, repository_url, handler
    {
      uint16_t build-page-entries = 20
      {
        "<num>",
        "Number of builds per page. The default is 20."
      }

      uint16_t build-pages = 5
      {
        "<num>",
        "Number of pages in navigation (pager). The default is 5."
      }
    };

    class build_configs: build, page, repository_url, handler
    {
      uint16_t build-config-page-entries = 20
      {
        "<num>",
        "Number of build configurations per page. The default is 20."
      }

      uint16_t build-config-pages = 5
      {
        "<num>",
        "Number of pages in navigation (pager). The default is 5."
      }
    };

    class submit: page, repository_email, repository_url, handler
    {
      dir_path submit-data
      {
        "<dir>",
        "The directory to save final submission data to. If unspecified, the
         package submission functionality will be disabled. If specified,
         then \cb{submit-temp} must be specified as well. See \l{brep The
         \cb{build2} Repository Interface Manual} for more information on
         package submission.

         Note that the directory path must be absolute and the directory
         itself must exist and have read, write, and execute permissions
         granted to the user that runs the web server."
      }

      dir_path submit-temp
      {
        "<dir>",
        "The directory to save temporary submission data to. Must be specified
         if the package submission functionality is enabled.

         Note that this directory must be on the same filesystem and satisfy
         the same requirements as \cb{submit-data}. It is also the user's
         responsibility to clean it up after an unclean web server shutdown."
      }

      size_t submit-max-size = 10485760
      {
        "<bytes>",
        "The maximum size of the submission data accepted. Note that currently
         the entire submission request is read into memory. The default is
         10M."
      }

      path submit-form
      {
        "<file>",
        "The package submission form fragment. If specified, then its contents
         are treated as an XHTML5 fragment that is inserted into the <body>
         element of the submission page. If unspecified, then no submission
         page will be displayed. Note that the file path must be absolute."
      }

      string submit-email
      {
        "<email>",
        "The package submission email. If specified, the submission request
         and result manifests will be sent to this address. See \l{brep The
         \cb{build2} Repository Interface Manual} for more information."
      }

      path submit-handler
      {
        "<path>",
        "The handler program to be executed on package submission. The handler
         is executed as part of the HTTP request and is passed additional
         arguments that can be specified with \cb{submit-handler-argument}
         followed by the absolute path to the submission directory. See
         \l{brep The \cb{build2} Repository Interface Manual} for more
         information. Note that the program path must be absolute."
      }

      strings submit-handler-argument
      {
        "<arg>",
        "Additional arguments to be passed to the submission handler program
         (see \cb{submit-handler} for details). Repeat this option to specify
         multiple arguments."
      }

      size_t submit-handler-timeout
      {
        "<seconds>",
        "The submission handler program timeout in seconds. If specified and
         the handler does not exit in the allotted time, then it is killed and
         its termination is treated as abnormal."
      }
    };

    class ci_start: repository_email
    {
      dir_path ci-data
      {
        "<dir>",
        "The directory to save CI request data to. If unspecified, the
         package CI functionality will be disabled. See \l{brep The
         \cb{build2} Repository Interface Manual} for more information on
         package CI.

         Note that the directory path must be absolute and the directory
         itself must exist and have read, write, and execute permissions
         granted to the user that runs the web server."
      }

      string ci-email
      {
        "<email>",
        "The package CI email. If specified, the CI request and result
         manifests will be sent to this address. See \l{brep The \cb{build2}
         Repository Interface Manual} for more information."
      }

      path ci-handler
      {
        "<path>",
        "The handler program to be executed on CI request. The handler is
         executed as part of the HTTP request and is passed additional
         arguments that can be specified with \cb{ci-handler-argument}
         followed by the absolute path to the CI request directory. See
         \l{brep The \cb{build2} Repository Interface Manual} for more
         information. Note that the program path must be absolute."
      }

      strings ci-handler-argument
      {
        "<arg>",
        "Additional arguments to be passed to the CI handler program (see
         \cb{ci-handler} for details). Repeat this option to specify multiple
         arguments."
      }

      size_t ci-handler-timeout
      {
        "<seconds>",
        "The CI handler program timeout in seconds. If specified and the
         handler does not exit in the allotted time, then it is killed and
         its termination is treated as abnormal."
      }
    };

    class ci_cancel
    {
    };

    class ci: ci_start, page, repository_url, handler
    {
      // Classic CI-specific options.
      //

      path ci-form
      {
        "<file>",
        "The package CI form fragment. If specified, then its contents are
         treated as an XHTML5 fragment that is inserted into the <body>
         element of the CI page. If unspecified, then no CI page will be
         displayed. Note that the file path must be absolute."
      }
    };

    class ci_github: ci_start, ci_cancel, build_db, handler
    {
      // GitHub CI-specific options (e.g., request timeout when invoking
      // GitHub APIs).
      //
    };

    class upload: build, build_db, build_upload, repository_email, handler
    {
    };

    class repository_root: repository_url, handler
    {
      string root-global-view = "packages"
      {
        "<service>",
        "The default view to display for the global repository root. The
         <service> argument is one of the supported services (\cb{packages},
         \cb{builds}, \cb{submit}, \cb{ci}, etc). The default service is
         packages."
      }

      string root-tenant-view = "packages"
      {
        "<service>",
        "The default view to display for the tenant repository root. The
         <service> argument is one of the supported services (\cb{packages},
         \cb{builds}, \cb{submit}, \cb{ci}, etc). The default service is
         packages."
      }
    };
  }

  // Web handler HTTP request parameters.
  //
  namespace params
  {
    // Use parameters long names in the C++ code, short aliases (if present)
    // in HTTP URL.
    //
    class packages
    {
      // Display package search result list starting from this page.
      //
      uint16_t page | p;

      // Package search criteria.
      //
      // Note that the packages parameter is renamed to '_' by the root
      // handler (see the request_proxy class for details).
      //
      string q | _;
    };

    class package_details
    {
      // Display package version search result list starting from this page.
      //
      uint16_t page | p;

      // Package version search criteria.
      //
      string query | q;

      // Page form.
      //
      page_form form | f = page_form::brief;
    };

    class package_version_details
    {
      // Page form.
      //
      page_form form | f = page_form::brief;
    };

    class repository_details
    {
      // No parameters so far.
      //
    };

    class build_task
    {
      // Only consider packages from repositories with these canonical names
      // (note: including pkg: type).
      //
      vector<string> repository | r;

      // Only consider tenants with this interactive build mode.
      //
      bbot::interactive_mode interactive = bbot::interactive_mode::both;
    };

    class build_result
    {
      // No parameters so far.
      //
    };

    class build_log
    {
      // No parameters so far.
      //
    };

    // All parameters are non-optional.
    //
    class build_force
    {
      // Package name.
      //
      string package | pn;

      // Package version. May not be url-encoded, in which case the plus
      // character is considered literally (rather than as the encoded space
      // character). In other words, after url-decoding the space character is
      // treated the same way as the plus character.
      //
      // @@ Make it of the version type? Maybe after it get moved to
      //    libbpkg/types.hxx or at least the second use case appear.
      //
      string version | pv;

      // Package build target.
      //
      string target | tg;

      // Target build configuration.
      //
      string target_config | tc;

      // Package build configuration.
      //
      string package_config | pc;

      // Toolchain name.
      //
      string toolchain_name | tn;

      // Toolchain version. May not be url-encoded (see above).
      //
      string toolchain_version | tv;

      // Package rebuild reason. Must not be empty.
      //
      string reason;
    };

    class builds
    {
      // Display packages build configurations list starting from this page.
      //
      uint16_t page | p;

      // Package builds query filter options.
      //

      // Package name wildcard. An empty value is treated the same way as *.
      //
      // We used to generate URLs like:
      //
      // https://cppget.org/?builds&pn=bbot
      //
      // This looked a bit verbose, so now we produce URLs like:
      //
      // https://cppget.org/?builds=bbot
      //
      // Note that the builds parameter is renamed to '_' by the root handler
      // (see the request_proxy class for details).
      //
      string name | _;

      // Package version. If empty or *, then no version constraint is applied.
      // Otherwise the build package version must match the value exactly.
      //
      string version | pv;

      // Package build toolchain in the <name>-<version> form. If *, then no
      // toolchain constraint is applied. Otherwise the build toolchain name
      // and version must match the value exactly.
      //
      string toolchain | th = "*";

      // Package build target wildcard. An empty value is treated the same way
      // as *.
      //
      string target | tg;

      // Package build target configuration name wildcard. An empty value is
      // treated the same way as *.
      //
      string target_config | tc;

      // Package build package configuration name wildcard. An empty value is
      // treated the same way as *.
      //
      string package_config | pc;

      // Package build result. If *, then no build result constraint is
      // applied. Otherwise the value is supposed to be the one of the
      // following (ordered) statuses: pending, building, success, warning,
      // error, abort, abnormal. The first 3 statuses are checked for equality,
      // the rest - for being greater or equal.
      //
      string result | rs = "*";
    };

    class build_configs
    {
      // By default, display all build configurations except those which
      // belong to the 'hidden' class.
      //
      // Note that the build-configs parameter is renamed to '_' by the root
      // handler (see the request_proxy class for details).
      //
      string class_name | _;

      // Display build configurations list starting from this page.
      //
      uint16_t page | p;
    };

    // Parameters, except simulate, must either be all present (actual
    // submission) or absent (submission form request).
    //
    // Note also that besides these parameters there can be others. We don't
    // recognize their semantics and just save them to the submission request
    // manifest.
    //
    class submit
    {
      // Package archive file name. Must be <input type="file"/>.
      //
      // Note that it can potentially be not just a name but a file path and
      // in the client's form (e.g., Windows).
      //
      string archive;

      // Package archive file SHA256 checksum.
      //
      string sha256sum;

      // Submission simulation outcome.
      //
      string simulate;
    };

    // Parameters, except simulate, must either be all present (actual CI
    // request) or absent (CI form request).
    //
    // Note also that besides these parameters there can be others. We don't
    // recognize their semantics and just save them to the CI request
    // manifest.
    //
    class ci
    {
      // Package repository location.
      //
      // Note that the ci parameter is renamed to '_' by the root handler (see
      // the request_proxy class for details).
      //
      bpkg::repository_location repository | _;

      // Package names/versions.
      //
      strings package;

      // Overrides file name. Must be <input type="file"/>.
      //
      // Note that we don't really need this name and only check if this
      // parameter is specified to detect presence of the upload.
      //
      string overrides;

      // Interactive build execution breakpoint.
      //
      string interactive;

      // Submission simulation outcome.
      //
      string simulate;
    };

    // Parameters other than challenge must be all present.
    //
    // Note also that besides these parameters there can be others. We don't
    // recognize their semantics and just save them to the upload request
    // manifest.
    //
    class upload
    {
      // Upload type.
      //
      // Note that the upload parameter is renamed to '_' by the root handler
      // (see the request_proxy class for details).
      //
      string type | _;

      // Session id as returned by brep in the task response.
      //
      string session;

      // Answer to the private key challenge as posed by brep in the task
      // response. It must be present only if the challenge value was present
      // in the task response.
      //
      string challenge;

      // Upload instance name.
      //
      string instance;

      // Package archive file name. Must be <input type="file"/>.
      //
      // Note that it can potentially be not just a name but a file path.
      //
      string archive;

      // Package archive file SHA256 checksum.
      //
      string sha256sum;
    };
  }
}