IBM-Swift / swift-buildpack

IBM Cloud buildpack for Swift
BSD 3-Clause "New" or "Revised" License
32 stars 31 forks source link

Parse Package.swift files to obtain apt-get dependencies. #16

Closed rolivieri closed 7 years ago

rolivieri commented 8 years ago

As usual, let's create a separate branch off develop to work on this task.

See this url for more details: https://github.com/apple/swift-evolution/blob/7fcba970b88a5de3d302d291dc7bc9dfba0f9399/proposals/0063-swiftpm-system-module-search-paths.md

This implies writing code that parses all Package.swift files (the main one and the ones provided by each Swift package that the main app is dependent on).

Robert shared with us the following logic which should help with the implementation of this task:

egrep -R "Apt *\(" Packages/*/Package.swift | sed -e 's/^.*\.Apt *( *" *//' -e 's/".*$//' | xargs -n 1 sudo apt-get install -y
BDHernand commented 7 years ago

Was looking at this. To do this in package builder we would need to alter the build-package.sh file and before we invoke the makefile we would need to do the following:

swift package fetch

This will get all the dependencies and put them in the Packages directory. Next based upon OS we would need to issue the following commands:

Linux:

egrep -R "Apt *\(" Packages/*/Package.swift | sed -e 's/^.*\.Apt *( *" *//' -e 's/".*$//' | sort | uniq

Mac:

egrep -R "Brew *\(" Packages/*/Package.swift | sed -e 's/^.*\.Brew *( *" *//' -e 's/".*$//' | sort | uniq

the sort and uniq portions of the commands were to make sure we don't have duplicates in the list and to order it.

We would probable also want to run those commands on the main Package.swift file of the repo to make sure that it is taken care of as well and add that to the existing list if any.

That new list would need to be sorted and uniqued and passed into either apt-get or brew install commands to get those dependencies installed. Then once that is done we can run the make file portion of package-builder.... that should about cover it.