Skip to content
Snippets Groups Projects
Forked from Glasgow Haskell Compiler / GHC
19344 commits behind the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
boot 7.32 KiB
#!/usr/bin/env perl

use warnings;
use strict;

use Cwd;
use File::Path 'rmtree';
use File::Basename;

my %required_tag;
my $validate;
my $curdir;

# See Trac #11530
$ENV{GREP_OPTIONS} = '';

$required_tag{"-"} = 1;
$validate = 0;

$curdir = &cwd()
    or die "Can't find current directory: $!";

while ($#ARGV ne -1) {
    my $arg = shift @ARGV;

    if ($arg =~ /^--required-tag=(.*)/) {
        $required_tag{$1} = 1;
    }
    elsif ($arg =~ /^--validate$/) {
        $validate = 1;
    }
    else {
        die "Bad arg: $arg";
    }
}

sub sanity_check_line_endings {
    local $/ = undef;
    open FILE, "packages" or die "Couldn't open file: $!";
    binmode FILE;
    my $string = <FILE>;
    close FILE;

    if ($string =~ /\r/) {
        print STDERR <<EOF;
Found ^M in packages.
Perhaps you need to run
    git config --global core.autocrlf false
and re-check out the tree?
EOF
        exit 1;
    }
}

sub sanity_check_tree {
    my $tag;
    my $dir;

    if (-d ".git"  &&
        system("git config remote.origin.url | grep github.com > /dev/null") == 0 &&
        system("git config --get-regexp '^url.*github.com/.*/packages-.insteadOf' > /dev/null") != 0) {
        # If we cloned from github, make sure the url rewrites are set.
        # Otherwise 'git submodule update --init' prints confusing errors.
        die <<EOF;
It seems you cloned this repository from GitHub. But your git config files
don't contain the url rewrites that are needed to make this work (GitHub
doesn't support '/' in repository names, so we use a different naming scheme
for the submodule repositories there).

Please run the following commands first: