@@ -34,127 +34,141 @@ def _pkg_deb_impl(ctx):
3434 package_file_name = package_file_name ,
3535 )
3636
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" )
3839 outputs .append (changes_file )
3940
4041 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 )
44+ args .add ("--changes" , changes_file )
45+ args .add ("--data" , ctx .file .data )
46+ args .add ("--package" , ctx .attr .package )
47+ args .add ("--maintainer" , ctx .attr .maintainer )
4848
49- # Version and description can be specified by a file or inlined
5049 if ctx .attr .architecture_file :
5150 if ctx .attr .architecture != "all" :
5251 fail ("Both architecture and architecture_file attributes were specified" )
53- args .append ("--architecture= @" + ctx .file .architecture_file .path )
52+ args .add ("--architecture" , " @" + ctx .file .architecture_file .path )
5453 files .append (ctx .file .architecture_file )
5554 else :
56- args .append ("--architecture=" + ctx .attr .architecture )
55+ args .add ("--architecture" , ctx .attr .architecture )
5756
5857 if ctx .attr .preinst :
59- args .append ("--preinst= @" + ctx .file .preinst .path )
58+ args .add ("--preinst" , " @" + ctx .file .preinst .path )
6059 files .append (ctx .file .preinst )
6160 if ctx .attr .postinst :
62- args .append ("--postinst= @" + ctx .file .postinst .path )
61+ args .add ("--postinst" , " @" + ctx .file .postinst .path )
6362 files .append (ctx .file .postinst )
6463 if ctx .attr .prerm :
65- args .append ("--prerm= @" + ctx .file .prerm .path )
64+ args .add ("--prerm" , " @" + ctx .file .prerm .path )
6665 files .append (ctx .file .prerm )
6766 if ctx .attr .postrm :
68- args .append ("--postrm= @" + ctx .file .postrm .path )
67+ args .add ("--postrm" , " @" + ctx .file .postrm .path )
6968 files .append (ctx .file .postrm )
7069 if ctx .attr .config :
71- args .append ("--config= @" + ctx .file .config .path )
70+ args .add ("--config" , " @" + ctx .file .config .path )
7271 files .append (ctx .file .config )
7372 if ctx .attr .templates :
74- args .append ("--templates= @" + ctx .file .templates .path )
73+ args .add ("--templates" , " @" + ctx .file .templates .path )
7574 files .append (ctx .file .templates )
7675 if ctx .attr .triggers :
77- args .append ("--triggers= @" + ctx .file .triggers .path )
76+ args .add ("--triggers" , " @" + ctx .file .triggers .path )
7877 files .append (ctx .file .triggers )
7978 if ctx .attr .md5sums :
80- args .append ("--md5sums= @" + ctx .file .md5sums .path )
79+ args .add ("--md5sums" , " @" + ctx .file .md5sums .path )
8180 files .append (ctx .file .md5sums )
8281
8382 # Conffiles can be specified by a file or a string list
8483 if ctx .attr .conffiles_file :
8584 if ctx .attr .conffiles :
8685 fail ("Both conffiles and conffiles_file attributes were specified" )
87- args .append ("--conffile= @" + ctx .file .conffiles_file .path )
86+ args .add ("--conffile" , " @" + ctx .file .conffiles_file .path )
8887 files .append (ctx .file .conffiles_file )
8988 elif ctx .attr .conffiles :
90- args += ["--conffile=%s" % cf for cf in ctx .attr .conffiles ]
89+ for cf in ctx .attr .conffiles :
90+ args .add ("--conffile" , cf )
9191
9292 # Version and description can be specified by a file or inlined
9393 if ctx .attr .version_file :
9494 if ctx .attr .version :
9595 fail ("Both version and version_file attributes were specified" )
96- args .append ("--version= @" + ctx .file .version_file .path )
96+ args .add ("--version" , " @" + ctx .file .version_file .path )
9797 files .append (ctx .file .version_file )
9898 elif ctx .attr .version :
99- args .append ("--version=" + ctx .attr .version )
99+ args .add ("--version" , ctx .attr .version )
100100 else :
101101 fail ("Neither version_file nor version attribute was specified" )
102102
103103 if ctx .attr .description_file :
104104 if ctx .attr .description :
105105 fail ("Both description and description_file attributes were specified" )
106- args .append ("--description= @" + ctx .file .description_file .path )
106+ args .add ("--description" , " @" + ctx .file .description_file .path )
107107 files .append (ctx .file .description_file )
108108 elif ctx .attr .description :
109- args .append ("--description=" + ctx .attr .description )
109+ desc_file = ctx .actions .declare_file (out_file_name_base + ".description" )
110+ ctx .actions .write (desc_file , ctx .attr .description )
111+ files .append (desc_file )
112+ args .add ("--description" , "@" + desc_file .path )
110113 else :
111114 fail ("Neither description_file nor description attribute was specified" )
112115
113116 if ctx .attr .changelog :
114- args .append ("--changelog= @" + ctx .file .changelog .path )
117+ args .append ("--changelog" + " @" + ctx .file .changelog .path )
115118 files .append (ctx .file .changelog )
116119
117120 # Built using can also be specified by a file or inlined (but is not mandatory)
118121 if ctx .attr .built_using_file :
119122 if ctx .attr .built_using :
120123 fail ("Both build_using and built_using_file attributes were specified" )
121- args .append ("--built_using= @" + ctx .file .built_using_file .path )
124+ args .add ("--built_using" , " @" + ctx .file .built_using_file .path )
122125 files .append (ctx .file .built_using_file )
123126 elif ctx .attr .built_using :
124- args .append ("--built_using=" + ctx .attr .built_using )
127+ args .add ("--built_using" , ctx .attr .built_using )
125128
126129 if ctx .attr .depends_file :
127130 if ctx .attr .depends :
128131 fail ("Both depends and depends_file attributes were specified" )
129- args .append ("--depends= @" + ctx .file .depends_file .path )
132+ args .add ("--depends" , " @" + ctx .file .depends_file .path )
130133 files .append (ctx .file .depends_file )
131134 elif ctx .attr .depends :
132- args += ["--depends=" + d for d in ctx .attr .depends ]
135+ for d in ctx .attr .depends :
136+ args .add ("--depends" , d )
133137
134138 if ctx .attr .priority :
135- args .append ("--priority=" + ctx .attr .priority )
139+ args .add ("--priority" , ctx .attr .priority )
136140 if ctx .attr .section :
137- args .append ("--section=" + ctx .attr .section )
141+ args .add ("--section" , ctx .attr .section )
138142 if ctx .attr .homepage :
139- args .append ("--homepage=" + ctx .attr .homepage )
143+ args .add ("--homepage" , ctx .attr .homepage )
140144 if ctx .attr .license :
141- args .append ("--license=" + ctx .attr .license )
145+ args .add ("--license" , ctx .attr .license )
142146
143- args .append ("--distribution=" + ctx .attr .distribution )
144- args .append ("--urgency=" + ctx .attr .urgency )
145- args += ["--suggests=" + d for d in ctx .attr .suggests ]
146- args += ["--enhances=" + d for d in ctx .attr .enhances ]
147- args += ["--conflicts=" + d for d in ctx .attr .conflicts ]
148- args += ["--breaks=" + d for d in ctx .attr .breaks ]
149- args += ["--pre_depends=" + d for d in ctx .attr .predepends ]
150- args += ["--recommends=" + d for d in ctx .attr .recommends ]
151- args += ["--replaces=" + d for d in ctx .attr .replaces ]
152- args += ["--provides=" + d for d in ctx .attr .provides ]
147+ args .add ("--distribution" , ctx .attr .distribution )
148+ args .add ("--urgency" , ctx .attr .urgency )
149+ for d in ctx .attr .suggests :
150+ args .add ("--suggests" , d )
151+ for d in ctx .attr .enhances :
152+ args .add ("--enhances" , d )
153+ for d in ctx .attr .conflicts :
154+ args .add ("--conflicts" , d )
155+ for d in ctx .attr .breaks :
156+ args .add ("--breaks" , d )
157+ for d in ctx .attr .predepends :
158+ args .add ("--pre_depends" , d )
159+ for d in ctx .attr .recommends :
160+ args .add ("--recommends" , d )
161+ for d in ctx .attr .replaces :
162+ args .add ("--replaces" , d )
163+ for d in ctx .attr .provides :
164+ args .add ("--provides" , d )
153165
166+ args .set_param_file_format ("flag_per_line" )
167+ args .use_param_file ("@%s" , use_always = True )
154168 ctx .actions .run (
155169 mnemonic = "MakeDeb" ,
156170 executable = ctx .executable ._make_deb ,
157- arguments = args ,
171+ arguments = [ args ] ,
158172 inputs = files ,
159173 outputs = [output_file , changes_file ],
160174 env = {
0 commit comments