Skip to content

Resolve FOSS license issues #19409

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -672,3 +672,5 @@ xales <[email protected]>
zofrex <[email protected]>
zslayton <[email protected]>
zzmp <[email protected]>

Run src/etc/copyright2rs.sh to embed this file to rustc.
62 changes: 61 additions & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ their own copyright notices and license terms:

* LLVM. Code for this package is found in src/llvm.

Copyright (c) 2003-2013 University of Illinois at
Copyright (c) 2003-2014 University of Illinois at
Urbana-Champaign. All rights reserved.

Developed by:
Expand Down Expand Up @@ -187,6 +187,64 @@ their own copyright notices and license terms:
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS WITH THE SOFTWARE.

* OpenBSD regex is built as a part of libLLVMSupport.
Code for this package is found as src/llvm/lib/Support/reg*.

$OpenBSD: COPYRIGHT,v 1.3 2003/06/02 20:18:36 millert Exp $

Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved.
This software is not subject to any license of the American Telephone
and Telegraph Company or of the Regents of the University of California.

Permission is granted to anyone to use this software for any purpose on
any computer system, and to alter it and redistribute it, subject
to the following restrictions:

1. The author is not responsible for the consequences of use of this
software, no matter how awful, even if they arise from flaws in it.

2. The origin of this software must not be misrepresented, either by
explicit claim or by omission. Since few users ever read sources,
credits must appear in the documentation.

3. Altered versions must be plainly marked as such, and must not be
misrepresented as being the original software. Since few users
ever read sources, credits must appear in the documentation.

4. This notice may not be removed or altered.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
/*-
* Copyright (c) 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)COPYRIGHT 8.1 (Berkeley) 3/16/94
*/

* Additional libraries included in LLVM carry separate
BSD-compatible licenses. See src/llvm/LICENSE.txt for
details.
Expand Down Expand Up @@ -420,3 +478,5 @@ their own copyright notices and license terms:
has chosen for the collective work, enumerated at the top
of this file. The only difference is the retention of
copyright itself, held by the contributor.

Run src/etc/copyright2rs.sh to embed this file to rustc.
2 changes: 1 addition & 1 deletion mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ DEPS_rustc := syntax flate arena serialize getopts rbml \
DEPS_rustc_llvm := native:rustllvm libc std
DEPS_rustc_back := std syntax rustc_llvm flate log libc
DEPS_rustdoc := rustc rustc_trans native:hoedown serialize getopts \
test time
test time flate
DEPS_flate := std native:miniz
DEPS_arena := std
DEPS_graphviz := std
Expand Down
10 changes: 7 additions & 3 deletions mk/dist.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
PKG_NAME := $(CFG_PACKAGE_NAME)

# License suitable for displaying in a popup
LICENSE.txt: $(S)COPYRIGHT $(S)LICENSE-APACHE $(S)LICENSE-MIT
cat $^ > $@
LICENSE.txt: $(S)COPYRIGHT $(S)LICENSE-APACHE $(S)LICENSE-MIT $(S)AUTHORS.txt
for f in $^ ; do echo "---- $${f##*/} ----" >> $@; cat "$$f" >> $@; echo >> $@; done


######################################################################
Expand Down Expand Up @@ -82,6 +82,7 @@ $(PKG_TAR): $(PKG_FILES)
--exclude=*/llvm/test/*/*/*.s \
-c $(UNROOTED_PKG_FILES) | tar -x -C tmp/dist/$(PKG_NAME)
@$(call E, making $@)
$(Q)mkdir -p dist
$(Q)tar -czf $(PKG_TAR) -C tmp/dist $(PKG_NAME)
$(Q)rm -Rf tmp/dist/$(PKG_NAME)

Expand Down Expand Up @@ -220,8 +221,11 @@ dist-install-dir-$(1): PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
dist-install-dir-$(1): PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
dist-install-dir-$(1): PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
dist-install-dir-$(1): PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
dist-install-dir-$(1): DOC_DIR=$$(PREPARE_DEST_DIR)/share/doc/$$(PKG_NAME)
dist-install-dir-$(1): PREPARE_CLEAN=true
dist-install-dir-$(1): prepare-base-dir-$(1) docs compiler-docs
dist-install-dir-$(1): prepare-base-dir-$(1) docs compiler-docs LICENSE.txt
$$(Q)mkdir -p $$(DOC_DIR) && \
$$(Q)mv LICENSE.txt $$(DOC_DIR) && \
$$(Q)(cd $$(PREPARE_DEST_DIR)/ && find . -type f | sed 's/^\.\///') \
> tmp/dist/manifest-$(1).in
$$(Q)mv tmp/dist/manifest-$(1).in $$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)/rustlib/manifest.in
Expand Down
121 changes: 121 additions & 0 deletions src/etc/copyright2rs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#! /bin/sh

# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option.

set -e

clean_tmp() {
if [ -n "$g_outf" ]; then
echo "ERROR: failed to create \"$g_outf\""
fi
if [ -d "$g_tmpdir" -a -O "$g_tmpdir" ]; then
echo "Cleanup: rm -rf \"$g_tmpdir\""
rm -rf "$g_tmpdir" && exit 0
fi
echo "WARNING: could not remove \"$g_tmpdir\""
}

trap clean_tmp EXIT;

check_file() {
infile=$1
if [ ! -r "$infile" ]; then
echo "ERROR: could not find file \"$infile\" which should be in the top directory."
echo "Did you run this script in the top directory?"
exit 10
fi
}

git_final_commit() {
infile=$1
echo "// git log -n1 '$infile'"
# don't use "--" so that git returns an error
git log -n1 "$infile" > /dev/null || { echo "ERROR: failed to run git" >&2 ; exit 30; }
git log -n1 "$infile" | while read line; do
if [ -n "$line" ]; then
echo "// $line"
else
echo //
fi
done
echo
}

generate() {
g_outf=$1

tmpoutf=$g_tmpdir/$g_outf
tmpcomb=$g_tmpdir/combined.txt
tmpdeflate=$g_tmpdir/deflate.dat
tmpod=$g_tmpdir/deflate.od.txt
tmparr=$g_tmpdir/deflate.od.sed.txt

mkdir -p ${tmpoutf%/*}

check_file COPYRIGHT
check_file LICENSE-MIT
check_file LICENSE-APACHE
check_file AUTHORS.txt

# Open a temporary output file.
# It will be (atomically) renamed to the final output file.
exec 3>"$tmpoutf"
cat >&3 <<EOS
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option.

EOS
echo "// This file (text.rs) was generated by src/etc/copyright2rs.sh at" >&3
echo "// $(date -R)" >&3
echo >&3

git_final_commit COPYRIGHT >&3
git_final_commit AUTHORS.txt >&3

echo "pub const COPYRIGHT: &'static [u8] = &[" >&3

# Process each step w/o pipe so that "-e" can catch an error in intermediate step.s
cat > "$tmpcomb" <<EOS
Four license documents COPYRIGHT, LICENSE-MIT, LICENSE-APACHE, and
AUTHORS.txt combined as one:

EOS
for f in COPYRIGHT LICENSE-MIT LICENSE-APACHE AUTHORS.txt; do
echo "---- $f ----" >> "$tmpcomb"
cat "$f" >> "$tmpcomb"
echo >> "$tmpcomb"
done
python -c 'import sys,zlib; sys.stdout.write(zlib.compress(sys.stdin.read(), 9))' \
< "$tmpcomb" > "$tmpdeflate"
od -t x1 -A n < "$tmpdeflate" > "$tmpod"
sed -re 's/ (\w+)/0x\1,/g' < "$tmpod" >&3
echo "];" >&3
exec 3<&-

mv "$tmpoutf" "$g_outf"
echo "Successfully generated \"$g_outf\""
g_outf=''
}

main() {
g_tmpdir=$(mktemp -d) || { echo "ERROR: mktemp(1) failed to create a temp directory"; exit 5; }
echo "Created a temp dir \"$g_tmpdir\""

generate src/librustc_trans/driver/license/text.rs
generate src/librustdoc/license/text.rs
}

main
1 change: 0 additions & 1 deletion src/etc/local_stage0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ fi

cp ${PREFIX}/bin/rustc${BIN_SUF} ${TARG_DIR}/stage0/bin/
cp ${PREFIX}/${LIB_DIR}/${RUSTLIBDIR}/${TARG_DIR}/${LIB_DIR}/* ${TARG_DIR}/stage0/${LIB_DIR}/
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}extra*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}rust*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}std*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}syntax*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
pub fn optgroups() -> Vec<getopts::OptGroup> {
vec!(
optflag("h", "help", "Display this message"),
optflag("", "license", "Display license documents"),
optmulti("", "cfg", "Configure the compilation environment", "SPEC"),
optmulti("L", "", "Add a directory to the library search path", "PATH"),
optmulti("l", "", "Link the generated crate(s) to the specified native
Expand Down Expand Up @@ -631,7 +632,7 @@ pub fn optgroups() -> Vec<getopts::OptGroup> {
always = always colorize output;
never = never colorize output", "auto|always|never"),
optmulti("", "extern", "Specify where an external rust library is located",
"NAME=PATH"),
"NAME=PATH")
)
}

Expand Down
13 changes: 13 additions & 0 deletions src/librustc_trans/driver/license/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use std::io::{Writer, IoResult, IoError};
use std::io::IoErrorKind::InvalidInput;
use flate;

mod text;

pub fn print(out: &mut Writer) -> IoResult<()> {
match flate::inflate_bytes_zlib(text::COPYRIGHT) {
Some(dat) => out.write(dat.as_slice()),
None => Err(IoError { kind: InvalidInput, desc: "decompression error of the COPYRIGHT file",
detail: None })
}
}
Loading