@@ -58,11 +58,6 @@ actor Ponyup
5858 return
5959 end
6060
61- if not Packages ().contains (pkg.name , {(a, b) => a == b }) then
62- _notify.log (Err , " unknown package: " + pkg.name )
63- return
64- end
65-
6661 if _lockfile.contains (pkg) then
6762 _notify.log (Info , pkg.string () + " is up to date" )
6863 return
@@ -175,15 +170,15 @@ actor Ponyup
175170 end
176171
177172 _notify.log (Info , " " .join (
178- [ " selecting" ; pkg; " as default for" ; pkg.name
173+ [ " selecting" ; pkg; " as default for" ; pkg.name ()
179174 ].values ()))
180175
181176 var pkg' =
182177 try
183178 var p = pkg
184179 if p.version == " latest" then
185180 var latest = " "
186- for installed in local_packages (p.name ).values () do
181+ for installed in local_packages (p.name () ).values () do
187182 if (installed.channel == p.channel ) and (installed.version > latest)
188183 then latest = installed.version
189184 end
@@ -211,48 +206,63 @@ actor Ponyup
211206 end
212207
213208 ifdef windows then
214- let link_rel: String = Path .sep ().join ([" bin" ; pkg'.name ].values ())
215- + " .exe"
216- let bin_rel: String = Path .sep ().join ([pkg'.string (); link_rel].values ())
209+ for binary in pkg'.application .binaries ().values () do
210+ let link_rel: String = Path .sep ().join ([" bin" ; binary.name ].values ())
211+ + " .exe"
212+ let bin_rel: String = Path .sep ().join ([pkg'.string (); link_rel].values ())
217213
218- try
219- let bin_path = _root.join (bin_rel)?
220- _notify.log (Info , " bin: " + bin_path.path )
214+ try
215+ let bin_path = _root.join (bin_rel)?
216+ _notify.log (Info , " bin: " + bin_path.path )
221217
222- let link_dir = _root.join (" bin" )?
223- if not link_dir.exists () then link_dir.mkdir () end
218+ let link_dir = _root.join (" bin" )?
219+ if not link_dir.exists () then link_dir.mkdir () end
224220
225- let link_path = link_dir.join (pkg' .name + " .bat" )?
226- _notify.log (Info , " link: " + link_path.path )
221+ let link_path = link_dir.join (binary .name + " .bat" )?
222+ _notify.log (Info , " link: " + link_path.path )
227223
228- if link_path.exists () then link_path.remove () end
229- with file = File .create (link_path) do
230- file.print (" @echo off" )
231- file.print (" \" " + bin_path.path + " \" %*" )
224+ if link_path.exists () then link_path.remove () end
225+ // It is ok for optional binaries to not exist. If they don't then
226+ // we just skip them.
227+ if (not binary.required ) and (not bin_path.exists ()) then
228+ _notify.log (Info , " optional binary isn't in package. skipping." )
229+ continue
230+ end
231+ with file = File .create (link_path) do
232+ file.print (" @echo off" )
233+ file.print (" \" " + bin_path.path + " \" %*" )
234+ end
235+ else
236+ _notify.log (Err , " failed to create link batch file(s)" )
232237 end
233- else
234- _notify.log (Err , " failed to create link batch file" )
235238 end
236-
237239 else
238- let link_rel: String = " /" .join ([" bin" ; pkg'.name ].values ())
239- let bin_rel: String = " /" .join ([pkg'.string (); link_rel].values ())
240+ for binary in pkg'.application .binaries ().values () do
241+ let link_rel: String = " /" .join ([" bin" ; binary.name ].values ())
242+ let bin_rel: String = " /" .join ([pkg'.string (); link_rel].values ())
240243
241- try
242- let bin_path = _root.join (bin_rel)?
243- _notify.log (Info , " bin: " + bin_path.path )
244+ try
245+ let bin_path = _root.join (bin_rel)?
246+ _notify.log (Info , " bin: " + bin_path.path )
244247
245- let link_dir = _root.join (" bin" )?
246- if not link_dir.exists () then link_dir.mkdir () end
248+ let link_dir = _root.join (" bin" )?
249+ if not link_dir.exists () then link_dir.mkdir () end
247250
248- let link_path = link_dir.join (pkg' .name )?
249- _notify.log (Info , " link: " + link_path.path )
251+ let link_path = link_dir.join (binary .name )?
252+ _notify.log (Info , " link: " + link_path.path )
250253
251- if link_path.exists () then link_path.remove () end
252- if not bin_path.symlink (link_path) then error end
253- else
254- _notify.log (Err , " failed to create symbolic link" )
255- return
254+ if link_path.exists () then link_path.remove () end
255+ // It is ok for optional binaries to not exist. If they don't then
256+ // we just skip them.
257+ if (not binary.required ) and (not bin_path.exists ()) then
258+ _notify.log (Info , " optional binary isn't in package. skipping." )
259+ continue
260+ end
261+ if not bin_path.symlink (link_path) then error end
262+ else
263+ _notify.log (Err , " failed to create symbolic link(s)" )
264+ return
265+ end
256266 end
257267 end
258268
@@ -432,17 +442,17 @@ class LockFile
432442 let pkg = Packages .from_string (fields (0 )?)?
433443 let selected = try fields (1 )? == " *" else false end
434444
435- let entry = _entries.get_or_else (pkg.name , LockFileEntry )
445+ let entry = _entries.get_or_else (pkg.name () , LockFileEntry )
436446 if selected then
437447 entry.selection = entry.packages .size ()
438448 end
439449 entry.packages .push (pkg)
440- _entries (pkg.name ) = entry
450+ _entries (pkg.name () ) = entry
441451 end
442452
443453 fun contains (pkg: Package ): Bool =>
444454 if pkg.version == " latest" then return false end
445- let entry = _entries.get_or_else (pkg.name , LockFileEntry )
455+ let entry = _entries.get_or_else (pkg.name () , LockFileEntry )
446456 entry.packages .contains (pkg, {(a, b) => a.string () == b.string () })
447457
448458 fun selection (pkg_name: String ): (Package | None ) =>
@@ -452,12 +462,12 @@ class LockFile
452462 end
453463
454464 fun ref add_package (pkg: Package ) =>
455- let entry = _entries.get_or_else (pkg.name , LockFileEntry )
465+ let entry = _entries.get_or_else (pkg.name () , LockFileEntry )
456466 entry.packages .push (pkg)
457- _entries (pkg.name ) = entry
467+ _entries (pkg.name () ) = entry
458468
459469 fun ref select (pkg: Package ) ? =>
460- let entry = _entries (pkg.name )?
470+ let entry = _entries (pkg.name () )?
461471 entry.selection = entry.packages .find (
462472 pkg where predicate = {(a, b) => a.string () == b.string () })?
463473
0 commit comments