forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request swiftlang#131 from apple/debian-docker-2
refactor debian packager
- Loading branch information
Showing
13 changed files
with
250 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# This source file is part of the Swift.org open source project | ||
# | ||
# Copyright (c) 2022 Apple Inc. and the Swift project authors | ||
# Licensed under Apache License v2.0 with Runtime Library Exception | ||
# | ||
# See http://swift.org/LICENSE.txt for license information | ||
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
|
||
#!/bin/bash | ||
|
||
set -eux | ||
|
||
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
# load version definitions | ||
. ${here}/versions.sh | ||
|
||
# working in /tmp since docker file sharing makes this very slow to do dirctly on the share | ||
staging_dir=/tmp/swift-deb-builder | ||
package_dir=${staging_dir}/swiftlang-${debversion} | ||
|
||
# clean | ||
rm -rf ${package_dir} && mkdir -p ${package_dir} | ||
|
||
# copy control files to pakcage build directory | ||
cp -r ${here}/debian ${package_dir}/ | ||
cp -r ${package_dir}/debian/control.in ${package_dir}/debian/control | ||
|
||
# build the source package | ||
${here}/build_source_package.sh ${staging_dir} | ||
|
||
# install the build dependencies | ||
cd ${staging_dir} | ||
mk-build-deps --install ${package_dir}/debian/control.in --tool 'apt-get -y -o Debug::pkgProblemResolver=yes --no-install-recommends' | ||
|
||
# build the installable package | ||
# TODO: add signing key information | ||
cd ${package_dir} | ||
DEB_BUILD_OPTIONS=parallel=64 debuild | ||
|
||
# copy the final packages to /output | ||
cd ${staging_dir} | ||
cp *.deb /output/ | ||
cp *.ddeb /output/ | ||
cp *.dsc /output/ | ||
cp *.tar.* /output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ | ||
Upstream-Name: Swift.org | ||
Upstream-Contact: Swift Maintainers <swift-infrastructure@forums.swift.org> | ||
Source: https://github.com/apple/swift-installer-scripts | ||
|
||
Files: * | ||
Copyright: Apple Inc. and the Swift project authors | ||
License: Apache-2.0 | ||
|
||
Files: debian/* | ||
Copyright: Apple Inc. and the Swift project authors | ||
License: Apache-2.0 | ||
|
||
License: Apache-2.0 | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
. | ||
https://www.apache.org/licenses/LICENSE-2.0 | ||
. | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
. | ||
On Debian systems, the complete text of the Apache version 2.0 license | ||
can be found in "/usr/share/common-licenses/Apache-2.0". | ||
|
||
# Please also look if there are files or directories which have a | ||
# different copyright/license attached and list them here. | ||
# Please avoid picking licenses with terms that are more restrictive than the | ||
# packaged work, as it may make Debian's contributions unacceptable upstream. | ||
# | ||
# If you need, there are some extra license texts available in two places: | ||
# /usr/share/debhelper/dh_make/licenses/ | ||
# /usr/share/common-licenses/ |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,71 @@ | ||
## Ubuntu | ||
|
||
Ubuntu uses the [Deb package format]() to install software packages. | ||
The Swift Deb package can be built either by creating a Linux container image or manually on a computer running Ubuntu. | ||
|
||
There are separate directories for each version of Ubuntu. | ||
The instructions below are applicable to all versions. | ||
|
||
## Important file and directories | ||
|
||
**build_deb.sh** | ||
Driver file to build the deb package | ||
|
||
**build_source.sh** | ||
Driver file to build the deb source package (which is a step in `build_deb`) | ||
|
||
**patches/*.patch** | ||
Any post-release patches that have not yet been merged upstream that are temporarily necessary to build Swift. | ||
|
||
**control.in** | ||
Debian package metadata, including the `BuildDepends` and `Depends` definitions. | ||
|
||
**changelog** | ||
Debian package changelog | ||
|
||
**rules** | ||
Debian package recipe | ||
|
||
**Dockerfile** | ||
Defines the base docker image to run the install scripts in. | ||
|
||
**docker-compose** | ||
Defines docker compose tasks to drive the pacakge build in Docker. | ||
|
||
## Importand file and directories | ||
|
||
**Shared/version.sh** | ||
Shell fragment versions.sh containing version information for all source components, and the Debian package upstream version (debversion). | ||
|
||
**Shared/copyright** | ||
Copyright information | ||
|
||
### Building with docker-compose | ||
|
||
* to run the build end-to-end | ||
|
||
``` | ||
docker-compose run build | ||
``` | ||
|
||
* to enter the docker env in shell mode | ||
|
||
``` | ||
docker-compose run shell | ||
``` | ||
|
||
then you can run `./build_deb.sh` to run the build manually inside the docker | ||
|
||
|
||
* to rebuild the base image | ||
|
||
``` | ||
docker-compose build --pull | ||
``` | ||
|
||
note this still uses the docker cache, so will rebuild only if the version of the underlying base image changed upstream | ||
|
||
### Building locally on an Ubuntu machine | ||
|
||
1. Install required development tools (see Dockerfile) | ||
2. Run `./build_deb.sh` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# This source file is part of the Swift.org open source project | ||
# | ||
# Copyright (c) 2022 Apple Inc. and the Swift project authors | ||
# Licensed under Apache License v2.0 with Runtime Library Exception | ||
# | ||
# See http://swift.org/LICENSE.txt for license information | ||
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
|
||
FROM ubuntu:focal | ||
LABEL PURPOSE="This image is configured to build Swift for the version of Ubuntu listed above" | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update | ||
|
||
# Required deb packaging tools | ||
RUN apt-get install -y curl devscripts equivs quilt tar | ||
|
||
# Optimization: Install Swift build requirements listed in the control file | ||
ADD debian/control.in /tmp/control.in | ||
RUN mk-build-deps --install /tmp/control.in --tool 'apt-get -y -o Debug::pkgProblemResolver=yes --no-install-recommends' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../Shared/build_deb.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../Shared/build_source_package.sh |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../Shared/copyright |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# This source file is part of the Swift.org open source project | ||
# | ||
# Copyright (c) 2022 Apple Inc. and the Swift project authors | ||
# Licensed under Apache License v2.0 with Runtime Library Exception | ||
# | ||
# See http://swift.org/LICENSE.txt for license information | ||
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
|
||
# this setup is designed to build the Deb with docker | ||
# usage: | ||
# docker-compose -f platforms/Linux/DEB/ubuntu/focal/docker-compose.yaml run build | ||
|
||
# to rebuild the base image | ||
# docker-compose -f platforms/Linux/DEB/ubuntu/focal/docker-compose.yaml build | ||
|
||
# to shell into the container for debugging purposes: | ||
# docker-compose -f platforms/Linux/DEB/ubuntu/focal/docker-compose.yaml run shell | ||
|
||
version: "2" | ||
|
||
services: | ||
|
||
docker-setup: | ||
image: ubuntu-focal-deb-builder | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
|
||
common: &common | ||
image: ubuntu-focal-deb-builder | ||
depends_on: [docker-setup] | ||
volumes: | ||
- ../../Ubuntu/focal:/code/Ubuntu/focal:z | ||
- ../../Shared:/code/Shared:z | ||
- ./.output:/output:z | ||
working_dir: /code/Ubuntu/focal | ||
cap_drop: | ||
- CAP_NET_RAW | ||
- CAP_NET_BIND_SERVICE | ||
|
||
build: | ||
<<: *common | ||
command: /bin/bash -cl "./build_deb.sh" | ||
|
||
shell: | ||
<<: *common | ||
entrypoint: /bin/bash -l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../Shared/versions.sh |