@@ -269,6 +269,40 @@ const bundleLinuxLibatomic = Effect.fn("bundleLinuxLibatomic")(function* (input:
269269 }
270270 yield * fs . makeDirectory ( path . join ( input . contentDir , "lib" ) ) ;
271271 yield * fs . copyFile ( source , path . join ( input . contentDir , "lib/libatomic.so.1" ) ) ;
272+
273+ // libatomic is GPL-3.0-or-later WITH GCC-exception-3.1, so its terms and source travel with it.
274+ const owner = yield * spawner . string (
275+ ChildProcess . make ( "dpkg-query" , [ "-S" , yield * fs . realPath ( source ) ] ) ,
276+ ) ;
277+ const pkg = / ^ ( [ ^ : \s ] + ) (?: : [ ^ : \s ] + ) ? : / . exec ( owner ) ?. [ 1 ] ;
278+ const versions = pkg
279+ ? yield * spawner . string (
280+ ChildProcess . make ( "dpkg-query" , [
281+ "-W" ,
282+ "-f=${Version} ${source:Package} ${source:Version}" ,
283+ pkg ,
284+ ] ) ,
285+ )
286+ : "" ;
287+ const [ version , sourcePackage , sourceVersion ] = versions . trim ( ) . split ( " " ) ;
288+ if ( ! pkg || ! version || ! sourcePackage || ! sourceVersion ) {
289+ return yield * new CliArchiveInputMissingError ( {
290+ inputPath : `dpkg package for ${ source } ` ,
291+ hint : "The archive copies libatomic's license and source reference from its Ubuntu package." ,
292+ } ) ;
293+ }
294+ const header = [
295+ `libatomic.so.1 is copied from the Ubuntu package ${ pkg } ${ version } .` ,
296+ `Source: https://launchpad.net/ubuntu/+source/${ sourcePackage } /${ sourceVersion } ` ,
297+ "License: GPL-3.0-or-later WITH GCC-exception-3.1. The package copyright file and GPL-3 follow." ,
298+ ] . join ( "\n" ) ;
299+ const copyright = yield * fs . readFileString ( `/usr/share/doc/${ pkg } /copyright` ) ;
300+ const gpl3 = yield * fs . readFileString ( "/usr/share/common-licenses/GPL-3" ) ;
301+ yield * fs . writeFileString (
302+ path . join ( input . contentDir , "lib/libatomic.so.1.LICENSE" ) ,
303+ `${ header } \n\n${ copyright } \n${ gpl3 } ` ,
304+ ) ;
305+
272306 // RUNPATH resolves through symlinks and is not inherited by child processes, unlike LD_LIBRARY_PATH.
273307 yield * runCommand (
274308 ChildProcess . make ( "patchelf" , [ "--set-rpath" , "$ORIGIN/lib" , input . executablePath ] ) ,
0 commit comments