Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect platform identifier with init script #60

Merged
merged 13 commits into from
Dec 30, 2019
12 changes: 12 additions & 0 deletions .ci-dockerfiles/alpine-bootstrap-tester/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM alpine:3.11

RUN apk update \
&& apk upgrade \
&& apk add --update \
binutils-gold \
build-base \
curl \
git \
libexecinfo-static \
libressl-dev \
make
15 changes: 15 additions & 0 deletions .ci-dockerfiles/alpine-bootstrap-tester/build-and-push.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -o errexit
set -o nounset

#
# *** You should already be logged in to DockerHub when you run this ***
#

TODAY=$(date +%Y%m%d)
DOCKERFILE_DIR="$(dirname "$0")"

docker build --pull -t "ponylang/ponyup-ci-alpine-bootstrap-tester:${TODAY}" \
"${DOCKERFILE_DIR}"
docker push "ponylang/ponyup-ci-alpine-bootstrap-tester:${TODAY}"
10 changes: 10 additions & 0 deletions .ci-dockerfiles/ubuntu-bootstrap-tester/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM ubuntu:18.04

RUN apt-get update \
&& apt-get upgrade \
&& apt-get install -y \
gcc \
curl \
git \
libssl-dev \
make
15 changes: 15 additions & 0 deletions .ci-dockerfiles/ubuntu-bootstrap-tester/build-and-push.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -o errexit
set -o nounset

#
# *** You should already be logged in to DockerHub when you run this ***
#

TODAY=$(date +%Y%m%d)
DOCKERFILE_DIR="$(dirname "$0")"

docker build --pull -t "ponylang/ponyup-ci-ubuntu-bootstrap-tester:${TODAY}" \
"${DOCKERFILE_DIR}"
docker push "ponylang/ponyup-ci-ubuntu-bootstrap-tester:${TODAY}"
12 changes: 12 additions & 0 deletions .ci-scripts/test-bootstrap-musl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

cat ponyup-init.sh | sh -s

export PATH=$HOME/.local/share/ponyup/bin:$PATH
ponyup update ponyc nightly "--platform=musl"
ponyup update changelog-tool nightly
ponyup update corral nightly
ponyup update stable nightly

make clean
make
11 changes: 2 additions & 9 deletions .ci-scripts/test-bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
#!/bin/sh

rm -rf \
/usr/local/bin/ponyc \
/usr/local/bin/stable \
/usr/local/lib/x86-64/libpony* \
/usr/local/include/pony* \
/usr/local/packages

cat ponyup-init.sh | sh -s -- --prefix=/usr/local
cat ponyup-init.sh | sh -s

export PATH=$HOME/.local/share/ponyup/bin:$PATH
ponyup update ponyc nightly "--platform=$(cc -dumpmachine)"
ponyup update ponyc nightly
ponyup update changelog-tool nightly
ponyup update corral nightly
ponyup update stable nightly
Expand Down
32 changes: 30 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,29 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Test with the most recent ponyc release
run: PONYUP_PLATFORM=musl make test
run: make test

alpine-bootstrap:
name: Test bootstrapping on Alpine
runs-on: ubuntu-latest
container:
image: ponylang/ponyup-ci-alpine-bootstrap-tester:20191228
steps:
- uses: actions/checkout@v1
- name: Bootstrap test
run: .ci-scripts/test-bootstrap.sh
run: .ci-scripts/test-bootstrap-musl.sh

ubuntu-bootstrap:
name: Test bootstrapping on Ubuntu
runs-on: ubuntu-latest
container:
image: ponylang/ponyup-ci-ubuntu-bootstrap-tester:20191228
steps:
- uses: actions/checkout@v1
- name: Bootstrap test
run: |
export ssl=1.1.x
.ci-scripts/test-bootstrap.sh

macos:
name: Verify PR builds on macOS with most recent ponyc release
Expand All @@ -54,5 +74,13 @@ jobs:
run: brew install coreutils libressl
- name: Test with the most recent ponyc release
run: make test

macos-bootstrap:
name: Test bootstrapping on macOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: brew install dependencies
run: brew install coreutils libressl
- name: Bootstrap test
run: .ci-scripts/test-bootstrap.sh
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ You can install any prior release or nightly build available on [Cloudsmith](htt
ponyup update changelog-tool release-0.4.0
```

### Platform options

Ponyup is able to detect the CPU architecture and operating system of the platform on which it is running. The `--platform` option is used to override any field in the platform identifier (e.g. `x86_64-linux-gnu`).

It is currently necessary to pass `--platform=musl` on musl-based Linux systems to install the correct build of ponyc.

### Show installed package versions

The `ponyup show` command will display the installed package versions with the selected packages marked as green with an asterisk. If a more recent version is not installed, then the more recent version will be shown in yellow following the selected version.
Expand Down Expand Up @@ -89,3 +83,7 @@ nightly-20191116 [release]
compiled with: llvm 7.1.0 -- cc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Defaults: pic=true
```

### Platform options

Ponyup is able to detect the CPU architecture and operating system of the platform on which it is running. The `--platform` option is used to override any field in the platform identifier (e.g. `x86_64-linux-gnu`).
27 changes: 20 additions & 7 deletions cmd/main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,34 @@ actor Main is PonyupNotify
return
end

var platform = command.arg("platform").string()
if platform == "" then
try
with f = OpenFile(ponyup_dir.join(".platform")?) as File do
platform = f.lines().next()? .> lstrip() .> rstrip()
end
end
end
log(Extra, "platform: " + platform)

let ponyup = Ponyup(_env, auth, ponyup_dir, consume lockfile, this)

match command.fullname()
| "ponyup/version" => _env.out .> write("ponyup ") .> print(Version())
| "ponyup/show" => show(ponyup, command)
| "ponyup/update" => sync(ponyup, command)
| "ponyup/select" => select(ponyup, command)
| "ponyup/show" => show(ponyup, command, platform)
| "ponyup/update" => sync(ponyup, command, platform)
| "ponyup/select" => select(ponyup, command, platform)
else
log(InternalErr, "Unknown command: " + command.fullname())
end

be show(ponyup: Ponyup, command: Command val) =>
be show(ponyup: Ponyup, command: Command val, platform: String) =>
ponyup.show(
command.arg("package").string(),
command.option("local").bool())
command.option("local").bool(),
platform)

be sync(ponyup: Ponyup, command: Command val) =>
be sync(ponyup: Ponyup, command: Command val, platform: String) =>
let chan = command.arg("version/channel").string().split("-")
let pkg =
try
Expand All @@ -110,12 +121,13 @@ actor Main is PonyupNotify
[ "unexpected selection: "
command.arg("package").string()
"-"; command.arg("version/channel").string()
"-"; platform
].values()))
return
end
ponyup.sync(pkg)

be select(ponyup: Ponyup, command: Command val) =>
be select(ponyup: Ponyup, command: Command val, platform: String) =>
let chan = command.arg("version").string().split("-")
let pkg =
try
Expand All @@ -129,6 +141,7 @@ actor Main is PonyupNotify
[ "unexpected selection: "
command.arg("package").string()
"-"; command.arg("version").string()
"-"; platform
].values()))
return
end
Expand Down
32 changes: 22 additions & 10 deletions cmd/packages.pony
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ primitive Packages
platform: Array[String] box)
: Package ?
=>
let platform' = (consume platform).clone()
// ignore vendor identifier in full target triple
if platform'.size() > 3 then
platform'.trim_in_place(0, 4)
try platform'.delete(1)? end
end
var cpu: CPU = AMD64
var os: OS =
if Platform.linux() then Linux
elseif Platform.osx() then Darwin
else error
end
var libc: Libc =
if (name == "ponyc") and (os is Linux) then Glibc
else None
end
for field in platform.values() do
var libc: Libc = if os is Linux then Glibc end
for field in platform'.values() do
match field
| "x86_64" | "x64" | "amd64" => cpu = AMD64
| "linux" => os = Linux
Expand All @@ -31,7 +34,7 @@ primitive Packages
else error
end
end
if (os is Darwin) then libc = None end
if (name != "ponyc") or (os is Darwin) then libc = None end
Package._create(name, channel, version, (cpu, os, libc))

fun from_string(str: String): Package ? =>
Expand All @@ -47,27 +50,30 @@ primitive Packages
fragments(2)?,
(consume fragments).slice(3))?

class val Package
class val Package is Comparable[Package box]
let name: String
let channel: String
let version: String
let cpu: CPU
let os: OS
let libc: Libc
let selected: Bool

new val _create(
name': String,
channel': String,
version': String,
platform': (CPU, OS, Libc))
platform': (CPU, OS, Libc),
selected': Bool = false)
=>
name = name'
channel = channel'
version = version'
(cpu, os, libc) = platform'
selected = selected'

fun update_version(version': String): Package =>
_create(name, channel, version', (cpu, os, libc))
fun update_version(version': String, selected': Bool = false): Package =>
_create(name, channel, version', (cpu, os, libc), selected')

fun platform(): String iso^ =>
let fragments = Array[String]
Expand All @@ -86,6 +92,12 @@ class val Package
end
"-".join(fragments.values())

fun eq(other: Package box): Bool =>
string() == other.string()

fun lt(other: Package box): Bool =>
string() <= other.string()

fun string(): String iso^ =>
"-".join([name; channel; version; platform()].values())

Expand Down
Loading