diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/cargo.pl | 31 | ||||
-rwxr-xr-x | scripts/genmake | 93 | ||||
-rwxr-xr-x | scripts/healthchecks | 2 |
3 files changed, 115 insertions, 11 deletions
diff --git a/scripts/cargo.pl b/scripts/cargo.pl index 54d716e47..93e365620 100755 --- a/scripts/cargo.pl +++ b/scripts/cargo.pl @@ -2,7 +2,7 @@ use strict; use warnings; -use feature qw(:5.22); +use feature qw(:5.34); open my $cargo, '<', $ARGV[0] or die "can't open $ARGV[0]: $!\n"; my $data = ''; @@ -12,21 +12,32 @@ my $data = ''; $data = <$cargo>; } -my $name = ''; -my %cargo = (); -my @lines = split /\r?\n/, $data; +my @lines = split /(\r?\n){2,}/, $data; +my @cargo; # Parse the file; we just want the name and version. foreach my $line (@lines) { - if ($line =~ /^name = "(.*?)"$/) { - $name = $1; - } elsif ($line =~ /^version = "(.*?)"$/) { - $cargo{$name} = $1; + $line =~ /^name = "(.*?)"$/m; + my $name = $1; + next unless defined($name); + + $line =~ /^version = "(.*?)"$/m; + my $version = $1; + next unless defined($version); + + next unless $line =~ /^source /m; + $line =~ /^source = "(.*?)"$/m; + my $source = $1; + next unless defined($source); + + if ($source ne 'registry+https://github.com/rust-lang/crates.io-index') { + warn "Warning: $name lacks a supported registry.\n"; } + push @cargo, "$name $version"; } open my $file, '>', 'crates.txt' or die "can't open output file: $!\n"; # Print the data we pulled out above to a file. -foreach my $pkg (keys %cargo) { - say $file $pkg . ' ' . $cargo{$pkg}; +foreach my $pkg (sort @cargo) { + say $file $pkg; } diff --git a/scripts/genmake b/scripts/genmake new file mode 100755 index 000000000..79a89175a --- /dev/null +++ b/scripts/genmake @@ -0,0 +1,93 @@ +#!/bin/sh -e + +# ./scripts/deplist system | ./scripts/genmake [0|1] + +## +# This script reads from stdin and generates +# a Makefile in the repository's root. +# +# The first argument to this script is a value {0,1} +# indicating whether to generate real rules or fake +# (simulation) rules. Fake rules might be 'sleep 1' +# or can be user-defined. +# +# NOTE: out-of-tree builds are not supported. +# + +HERE="$(dirname $(readlink -f ${0}))"; +DEST="${HERE}"/../Makefile; +TEMP="$(mktemp)"; + +## +# Build recipes. +# +# FIXME: is $(@D) POSIX or $(%/built=%) required? +# +rule_real=$(cat <<"EOF" + @cd $(@D) && abuild -r +EOF +); +rule_fake=$(cat <<"EOF" + @echo $(@D) + @sleep 1 +EOF +); + +## +# Read deplist from stdin, synthesize Makefile targets. +# +awk '{ $(NF+1)=$1; print $0 }' `# duplicate first column to last` \ + | sed > "${TEMP}" -E `# use extended regex, write to temp file ` \ + -e 's/ /: /' `# append colon to first column` \ + -e '/: /s@( |$)@/built @2g' `# append '/built' to all dependencies` \ + -e 's/ $//g' `# trim trailing spaces` \ + ; + +## +# Internal; convenience only. +# +list=$(grep : "${TEMP}" \ + | cut -d: -f1 \ + | xargs \ +); + +## +# Create (or truncate) the output Makefile. +# +# Default target builds everything. +# +printf "all: %s\n" "${list}" > "${DEST}"; + +## +# Append generic target build recipe. +# +rule=; +case ${1} in + 0) rule="${rule_real}"; ;; + 1) rule="${rule_fake}"; ;; + *) printf "E: Invalid mode '%s'\n" "${1}"; exit 1; ;; +esac +cat >> "${DEST}" <<EOF +%/built: %/APKBUILD +${rule} + @touch \$@ +clean: + @find \$(CURDIR) -type f -name built -print -delete +distclean: + @rm -fv \ + \$(CURDIR)/Makefile \ + \$(CURDIR)/scripts/.index \ + \$(CURDIR)/scripts/sgrep \ + \$(CURDIR)/scripts/tsort \ + ; +EOF + +## +# Append target rules to output Makefile. +# +cat >> "${DEST}" "${TEMP}"; + +## +# Clean up. +# +rm "${TEMP}"; diff --git a/scripts/healthchecks b/scripts/healthchecks index ae313bb1e..ab3abee32 100755 --- a/scripts/healthchecks +++ b/scripts/healthchecks @@ -58,7 +58,7 @@ try_down () ## # Download the file and set global 'okay' to curl retval. # - curl --connect-timeout 10 -sLo "${TEMP}/${name}" "${down}" || okay=${?}; + curl --connect-timeout 120 -sLo "${TEMP}/${name}" "${down}" || okay=${?}; ## |