@@ -34,120 +34,135 @@ def _pkg_deb_impl(ctx):
34
34
package_file_name = package_file_name ,
35
35
)
36
36
37
- changes_file = ctx .actions .declare_file (output_name .rsplit ("." , 1 )[0 ] + ".changes" )
37
+ out_file_name_base = output_name .rsplit ("." , 1 )[0 ]
38
+ changes_file = ctx .actions .declare_file (out_file_name_base + ".changes" )
38
39
outputs .append (changes_file )
39
40
40
41
files = [ctx .file .data ]
41
- args = [
42
- "--output=" + output_file .path ,
43
- "--changes=" + changes_file .path ,
44
- "--data=" + ctx .file .data .path ,
45
- "--package=" + ctx .attr .package ,
46
- "--maintainer=" + ctx .attr .maintainer ,
47
- ]
42
+ args = ctx .actions .args ()
43
+ args .add ("--output" , output_file .path )
44
+ args .add ("--changes" , changes_file .path )
45
+ args .add ("--data" , ctx .file .data .path )
46
+ args .add ("--package" , ctx .attr .package )
47
+ args .add ("--maintainer" , ctx .attr .maintainer )
48
48
49
- # Version and description can be specified by a file or inlined
50
49
if ctx .attr .architecture_file :
51
50
if ctx .attr .architecture != "all" :
52
51
fail ("Both architecture and architecture_file attributes were specified" )
53
- args += [ "--architecture= @" + ctx .file .architecture_file .path ]
52
+ args . add ( "--architecture" , " @" + ctx .file .architecture_file .path )
54
53
files += [ctx .file .architecture_file ]
55
54
else :
56
- args += [ "--architecture=" + ctx .attr .architecture ]
55
+ args . add ( "--architecture" , ctx .attr .architecture )
57
56
58
57
if ctx .attr .preinst :
59
- args += [ "--preinst= @" + ctx .file .preinst .path ]
58
+ args . add ( "--preinst" , " @" + ctx .file .preinst .path )
60
59
files += [ctx .file .preinst ]
61
60
if ctx .attr .postinst :
62
- args += [ "--postinst= @" + ctx .file .postinst .path ]
61
+ args . add ( "--postinst" , " @" + ctx .file .postinst .path )
63
62
files += [ctx .file .postinst ]
64
63
if ctx .attr .prerm :
65
- args += [ "--prerm= @" + ctx .file .prerm .path ]
64
+ args . add ( "--prerm" , " @" + ctx .file .prerm .path )
66
65
files += [ctx .file .prerm ]
67
66
if ctx .attr .postrm :
68
- args += [ "--postrm= @" + ctx .file .postrm .path ]
67
+ args . add ( "--postrm" , " @" + ctx .file .postrm .path )
69
68
files += [ctx .file .postrm ]
70
69
if ctx .attr .config :
71
- args += [ "--config= @" + ctx .file .config .path ]
70
+ args . add ( "--config" , " @" + ctx .file .config .path )
72
71
files += [ctx .file .config ]
73
72
if ctx .attr .templates :
74
- args += [ "--templates= @" + ctx .file .templates .path ]
73
+ args . add ( "--templates" , " @" + ctx .file .templates .path )
75
74
files += [ctx .file .templates ]
76
75
if ctx .attr .triggers :
77
- args += [ "--triggers= @" + ctx .file .triggers .path ]
76
+ args . add ( "--triggers" , " @" + ctx .file .triggers .path )
78
77
files += [ctx .file .triggers ]
79
78
80
79
# Conffiles can be specified by a file or a string list
81
80
if ctx .attr .conffiles_file :
82
81
if ctx .attr .conffiles :
83
82
fail ("Both conffiles and conffiles_file attributes were specified" )
84
- args += [ "--conffile= @" + ctx .file .conffiles_file .path ]
83
+ args . add ( "--conffile" , " @" + ctx .file .conffiles_file .path )
85
84
files += [ctx .file .conffiles_file ]
86
85
elif ctx .attr .conffiles :
87
- args += ["--conffile=%s" % cf for cf in ctx .attr .conffiles ]
86
+ for cf in ctx .attr .conffiles :
87
+ args .add ("--conffile" , cf )
88
88
89
89
# Version and description can be specified by a file or inlined
90
90
if ctx .attr .version_file :
91
91
if ctx .attr .version :
92
92
fail ("Both version and version_file attributes were specified" )
93
- args += [ "--version= @" + ctx .file .version_file .path ]
93
+ args . add ( "--version" , " @" + ctx .file .version_file .path )
94
94
files += [ctx .file .version_file ]
95
95
elif ctx .attr .version :
96
- args += [ "--version=" + ctx .attr .version ]
96
+ args . add ( "--version" , ctx .attr .version )
97
97
else :
98
98
fail ("Neither version_file nor version attribute was specified" )
99
99
100
100
if ctx .attr .description_file :
101
101
if ctx .attr .description :
102
102
fail ("Both description and description_file attributes were specified" )
103
- args += [ "--description= @" + ctx .file .description_file .path ]
103
+ args . add ( "--description" , " @" + ctx .file .description_file .path )
104
104
files += [ctx .file .description_file ]
105
105
elif ctx .attr .description :
106
- args += ["--description=" + ctx .attr .description ]
106
+ desc_file = ctx .actions .declare_file (out_file_name_base + ".description" )
107
+ ctx .actions .write (desc_file , ctx .attr .description )
108
+ files .append (desc_file )
109
+ args .add ("--description" , "@" + desc_file .path )
107
110
else :
108
111
fail ("Neither description_file nor description attribute was specified" )
109
112
110
113
# Built using can also be specified by a file or inlined (but is not mandatory)
111
114
if ctx .attr .built_using_file :
112
115
if ctx .attr .built_using :
113
116
fail ("Both build_using and built_using_file attributes were specified" )
114
- args += [ "--built_using= @" + ctx .file .built_using_file .path ]
117
+ args . add ( "--built_using" , " @" + ctx .file .built_using_file .path )
115
118
files += [ctx .file .built_using_file ]
116
119
elif ctx .attr .built_using :
117
- args += [ "--built_using=" + ctx .attr .built_using ]
120
+ args . add ( "--built_using" , ctx .attr .built_using )
118
121
119
122
if ctx .attr .depends_file :
120
123
if ctx .attr .depends :
121
124
fail ("Both depends and depends_file attributes were specified" )
122
- args += [ "--depends= @" + ctx .file .depends_file .path ]
125
+ args . add ( "--depends" , " @" + ctx .file .depends_file .path )
123
126
files += [ctx .file .depends_file ]
124
127
elif ctx .attr .depends :
125
- args += ["--depends=" + d for d in ctx .attr .depends ]
128
+ for d in ctx .attr .depends :
129
+ args .add ("--depends" , d )
126
130
127
131
if ctx .attr .priority :
128
- args += [ "--priority=" + ctx .attr .priority ]
132
+ args . add ( "--priority" , ctx .attr .priority )
129
133
if ctx .attr .section :
130
- args += [ "--section=" + ctx .attr .section ]
134
+ args . add ( "--section" , ctx .attr .section )
131
135
if ctx .attr .homepage :
132
- args += [ "--homepage=" + ctx .attr .homepage ]
136
+ args . add ( "--homepage" , ctx .attr .homepage )
133
137
if ctx .attr .license :
134
- args += [ "--license=" + ctx .attr .license ]
138
+ args . add ( "--license" , ctx .attr .license )
135
139
136
- args += ["--distribution=" + ctx .attr .distribution ]
137
- args += ["--urgency=" + ctx .attr .urgency ]
138
- args += ["--suggests=" + d for d in ctx .attr .suggests ]
139
- args += ["--enhances=" + d for d in ctx .attr .enhances ]
140
- args += ["--conflicts=" + d for d in ctx .attr .conflicts ]
141
- args += ["--breaks=" + d for d in ctx .attr .breaks ]
142
- args += ["--pre_depends=" + d for d in ctx .attr .predepends ]
143
- args += ["--recommends=" + d for d in ctx .attr .recommends ]
144
- args += ["--replaces=" + d for d in ctx .attr .replaces ]
145
- args += ["--provides=" + d for d in ctx .attr .provides ]
140
+ args .add ("--distribution" , ctx .attr .distribution )
141
+ args .add ("--urgency" , ctx .attr .urgency )
142
+ for d in ctx .attr .suggests :
143
+ args .add ("--suggests" , d )
144
+ for d in ctx .attr .enhances :
145
+ args .add ("--enhances" , d )
146
+ for d in ctx .attr .conflicts :
147
+ args .add ("--conflicts" , d )
148
+ for d in ctx .attr .breaks :
149
+ args .add ("--breaks" , d )
150
+ for d in ctx .attr .predepends :
151
+ args .add ("--pre_depends" , d )
152
+ for d in ctx .attr .recommends :
153
+ args .add ("--recommends" , d )
154
+ for d in ctx .attr .replaces :
155
+ args .add ("--replaces" , d )
156
+ for d in ctx .attr .provides :
157
+ args .add ("--provides" , d )
146
158
159
+ args .set_param_file_format ("flag_per_line" )
160
+ args .use_param_file ("@%s" , use_always = True )
161
+ print (args )
147
162
ctx .actions .run (
148
163
mnemonic = "MakeDeb" ,
149
164
executable = ctx .executable ._make_deb ,
150
- arguments = args ,
165
+ arguments = [ args ] ,
151
166
inputs = files ,
152
167
outputs = [output_file , changes_file ],
153
168
env = {
0 commit comments