Skip to content

Instantly share code, notes, and snippets.

@passcod
Last active August 6, 2023 00:24
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save passcod/2e1983ce415b32bdf3a0 to your computer and use it in GitHub Desktop.
Save passcod/2e1983ce415b32bdf3a0 to your computer and use it in GitHub Desktop.
License stats for crates on crates.io
/metacrate-*
2015-02-17 2016-04-28 2020-02-04 2020-05-11
    984 MIT
    115 Apache-2.0 OR MIT
     63 Apache-2.0
     43 null
     27 BSD-3-Clause
     25 Unlicense
     20 Zlib
     17 BSD-2-Clause
     11 WTFPL
     11 MPL-2.0
     11 CC0-1.0
      8 non-standard
      8 GPL-3.0+
      7 ISC
      7 GPL-2.0
      6 LGPL-3.0
      5 GPL-3.0
      3 LGPL-2.1+
      2 MIT/BSD-2-Clause
      2 LGPL-3.0+
      2 AGPL-3.0
      1 Libpng OR Zlib
      1 Zed
      1 MIT OR MPL-1.1 OR Unlicense
      1 Apache-2.0 OR Unlicense
      1 Python-2.0
      1 MPL-2.0-no-copyleft-exception
      1 Apache-1.0 OR MIT
      1 LGPL-2.1
      1 LGPL-2.0+
      1 IJG
      1 BSL-1.0
   2614 MIT
    910 Apache-2.0 OR MIT
    266 Apache-2.0
    103 GPL-3.0
    100 BSD-3-Clause
     86 non-standard
     79 MPL-2.0
     69 CC0-1.0
     61 BSD-2-Clause
     40 WTFPL
     38 ISC
     37 Unlicense
     37 null
     37 LGPL-3.0
     30 Zlib
     27 MIT OR Unlicense
     27 GPL-2.0
     20 LGPL-3.0+
     20 AGPL-3.0
     18 LGPL-2.1
     16 GPL-3.0+
     11 GPL-2.0+
     10 LGPL-2.1+
     10 BSL-1.0
      7 zlib-acknowledgement
      5 AML
      3 ISC OR MIT
      2 Python-2.0
      2 MITNFA
      2 AGPL-3.0+ AND GPL-2.0+
      2 Apache-2.0 OR BSL-1.0
      2 BSD-4-Clause
      2 Apache-2.0 OR BSD-3-Clause-Clear OR MIT
      2 AML OR Apache-2.0
      1 Libpng OR Zlib
      1 Zed
      1 MIT OR MPL-1.1 OR Unlicense
      1 Apache-2.0 OR Unlicense
      1 NCSA
      1 MPL-2.0-no-copyleft-exception
      1 BSL-1.0 OR MIT OR WTFPL
      1 BSD-3-Clause OR MIT
      1 BSD-2-Clause OR MIT
      1 Apache-2.0 OR BSD-3-Clause OR MIT
      1 Apache-1.0 OR MIT
      1 AGPL-1.0 OR MIT
      1 MirOS
      1 LGPL-2.0+
      1 LGPL-2.0
      1 IJG
      1 GPL-3.0 OR LGPL-3.0
      1 BSD-3-Clause OR GPL-3.0+
      1 Apache-2.0 OR GPL-2.0 OR GPL-3.0 OR MIT
      1 FTL OR GPL-2.0
      1 CC-BY-SA-4.0 OR MIT
      1 CC-BY-NC-4.0
      1 Apache-2.0 OR GPL-2.0
      1 AGPL-3.0 WITH eCos-exception-2.0
      1 AGPL-3.0+
  15782 MIT
   9451 Apache-2.0 OR MIT
   3044 Apache-2.0
    988 non-standard
    890 GPL-3.0
    720 MPL-2.0
    666 BSD-3-Clause
    360 CC0-1.0
    356 ISC
    345 GPL-3.0-or-later
    306 BSD-2-Clause
    239 AGPL-3.0
    210 Unlicense
    188 WTFPL
    168 LGPL-3.0
    130 GPL-3.0-only
    129 GPL-3.0+
    118 LGPL-2.1
    117 MIT OR Unlicense
    117 0BSD
    101 Zlib
     92 Apache-2.0 WITH LLVM-exception
     89 GPL-2.0
     68 AGPL-3.0-or-later
     55 LGPL-3.0+
     52 LGPL-3.0-or-later
     51 AGPL-3.0+
     40 null
     36 MIT OR BSL-1.0
     36 Apache-2.0 OR MIT OR MPL-2.0
     36 AGPL-3.0-only
     35 GPL-2.0+
     34 BSD-3-Clause OR MIT
     29 MITNFA
     27 GPL-2.0-or-later
     23 GPL-2.0-only
     23 BSL-1.0
     23 BSD-2-Clause OR MIT
     21 LGPL-2.1+
     20 MPL-2.0+
     20 Fair
     18 LGPL-2.1-or-later
     16 Apache-2.0 AND MIT
     15 Apache-2.0 OR MIT OR BSD-3-Clause
     14 LGPL-3.0-only
     14 BSD-4-Clause
     12 zlib-acknowledgement
     11 MIT-0
     10 MIT OR X11 OR Apache-2.0
      9 AML
      8 WTFPL OR Apache-2.0 OR MIT
      8 EPL-1.0
      8 Apache-2.0 OR ISC OR MIT
      7 LGPL-2.1-only
      7 LGPL-2.0-only
      7 BlueOak-1.0.0
      7 Apache-2.0 OR BSD-3-Clause
      6 AFL-3.0
      5 MirOS
      5 MIT OR X11
      5 Apache-2.0 OR BSL-1.0
      4 UPL-1.0
      4 NCSA
      4 MIT-0 OR 0BSD
      4 EPL-2.0
      4 CC-BY-NC-SA-4.0
      4 BSD-2-Clause-FreeBSD
      4 Apache-2.0 OR MIT OR Unlicense
      4 Apache-2.0 OR LGPL-2.1-or-later
      4 AML OR Apache-2.0
      3 Python-2.0
      3 MPL-2.0-no-copyleft-exception
      3 MIT OR Zlib
      3 MIT OR NCSA
      3 MIT OR ISC
      3 LGPL-3.0 OR GPL-2.0 OR GPL-3.0
      3 LGPL-2.0
      3 ISC OR Apache-2.0
      3 GPL-3.0+ OR BSD-3-Clause
      3 GPL-1.0-or-later OR Artistic-1.0-Perl
      3 FTL OR GPL-2.0
      3 CECILL-2.1
      3 CDDL-1.1
      3 CC0-1.0 OR MIT
      3 CC-BY-SA-4.0
      3 CC-BY-NC-4.0
      3 BSD-3-Clause-Attribution
      3 Apache-2.0 OR MIT OR Zlib
      3 Apache-2.0 OR MIT OR BSL-1.0 OR CC0-1.0
      3 Apache-2.0 OR CC0-1.0 OR MIT
      2 X11
      2 UPL-1.0 OR Apache-2.0
      2 PostgreSQL OR MIT
      2 NCSA AND BSD-3-Clause
      2 MIT OR GPL-3.0-or-later
      2 MIT AND Zlib OR Apache-2.0 AND Zlib
      2 MIT AND ODbL-1.0
      2 LGPL-2.1-or-later OR MIT
      2 LGPL-2.1 OR MPL-1.1
      2 LGPL-2.1 OR LGPL-3.0
      2 LGPL-2.1 OR BSD-2-Clause
      2 IJG
      2 GPL-1.0
      2 EPL-2.0 OR Apache-2.0
      2 D-FSL-1.0
      2 CECILL-C
      2 CC0-1.0 OR Apache-2.0
      2 CC-BY-4.0
      2 Beerware
      2 BSD-3-Clause-Clear
      2 BSD-2-Clause-Patent
      2 BSD-2-Clause AND ISC AND MIT
      2 Artistic-2.0
      2 Artistic-1.0 OR GPL-2.0-or-later
      2 Apache-2.0 OR MIT OR Unlicense OR WTFPL
      2 Apache-2.0 OR MIT OR BSL-1.0
      2 Apache-2.0 OR MIT AND BSD-2-Clause
      2 Apache-2.0 OR GPL-2.0+
      2 Apache-2.0 OR BSD-3-Clause-Clear OR MIT
      2 Apache-2.0 AND BSD-3-Clause
      2 Apache-1.0
      2 APSL-2.0 OR MIT
      2 AFL-1.1
      1 Zlib OR MIT OR BSL-1.0
      1 Zed
      1 SimPL-2.0
      1 QPL-1.0 OR LGPL-2.0
      1 Parity-6.0.0 AND Apache-2.0
      1 PDDL-1.0
      1 OSL-3.0 OR AGPL-3.0-or-later
      1 OSL-3.0
      1 OLDAP-2.8
      1 NPOSL-3.0
      1 NLPL
      1 MPL-2.0+ OR LGPL-3.0+
      1 MPL-1.1 OR MIT OR Unlicense
      1 MPL-1.1 OR GPL-2.0 OR LGPL-2.1
      1 MPL-1.1
      1 MIT OR LGPL-3.0
      1 MIT OR LGPL-2.1
      1 MIT OR GPL-3.0+
      1 MIT OR GPL-3.0
      1 MIT OR Apache-1.0
      1 MIT OR AGPL-1.0
      1 MIT AND Zlib
      1 MIT AND LGPL-2.1-or-later
      1 MIT AND LGPL-2.0-or-later
      1 Libpng
      1 LPPL-1.3c
      1 LGPL-3.0 OR MPL-2.0
      1 LGPL-2.1 OR MPL-2.0
      1 LGPL-2.0-or-later
      1 LGPL-2.0+
      1 ISC OR GPL-3.0-or-later
      1 GPL-3.0-or-later OR LGPL-3.0-or-later
      1 GPL-3.0-or-later AND BSD-3-Clause
      1 GPL-3.0-only OR MIT
      1 GPL-3.0+ AND BSD-3-Clause
      1 GPL-3.0 OR MPL-2.0 OR LGPL-3.0
      1 GPL-3.0 OR MPL-2.0
      1 GPL-3.0 OR LGPL-3.0
      1 GPL-3.0 OR GFDL-1.3
      1 GPL-2.0+ AND LGPL-2.1+ AND MPL-1.1
      1 GPL-2.0 OR GPL-3.0 OR Apache-2.0 OR MIT
      1 CECILL-C OR CECILL-2.1
      1 CECILL-B
      1 CDDL-1.0
      1 CC-BY-SA-4.0 OR MIT
      1 CC-BY-NC-SA-2.5
      1 BSD-3-Clause-Clear OR Apache-2.0
      1 BSD-2-Clause AND MIT
      1 Artistic-1.0-Perl
      1 Apache-2.0 WITH LLVM-exception OR MIT
      1 Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
      1 Apache-2.0 OR Unlicense
      1 Apache-2.0 OR PostgreSQL
      1 Apache-2.0 OR MIT+
      1 Apache-2.0 OR MIT OR NCSA
      1 Apache-2.0 OR MIT OR LGPL-2.1
      1 Apache-2.0 OR MIT OR GPL-3.0-or-later
      1 Apache-2.0 OR MIT OR Beerware
      1 Apache-2.0 OR MIT OR BSD-2-Clause
      1 Apache-2.0 OR GPL-3.0
      1 APL-1.0
      1 AGPL-3.0 WITH eCos-exception-2.0
      1 AGPL-3.0 OR GPL-3.0 OR Apache-2.0 OR MIT
      1 AGPL-1.0
      1 AFL-2.0
      1 0BSD OR Zlib
  17692 MIT
  10678 Apache-2.0 OR MIT
   3466 Apache-2.0
   1205 non-standard
   1105 GPL-3.0
    821 MPL-2.0
    748 BSD-3-Clause
    548 GPL-3.0-or-later
    398 ISC
    391 CC0-1.0
    331 BSD-2-Clause
    257 AGPL-3.0
    239 Unlicense
    199 WTFPL
    177 LGPL-3.0
    167 GPL-3.0-only
    140 AGPL-3.0-or-later
    135 0BSD
    130 MIT OR Unlicense
    129 Zlib
    122 LGPL-2.1
    112 LGPL-3.0-or-later
    112 Apache-2.0 WITH LLVM-exception
    100 GPL-2.0
     66 GPL-2.0-or-later
     43 LGPL-2.1-or-later
     43 AGPL-3.0-only
     40 null
     39 Apache-2.0 OR MIT OR MPL-2.0
     34 GPL-2.0-only
     34 BSL-1.0
     34 BSD-3-Clause OR MIT
     32 BSL-1.0 OR MIT
     29 MITNFA
     27 MPL-2.0-or-later
     23 BSD-2-Clause OR MIT
     22 Apache-2.0 AND MIT
     21 Fair
     18 LGPL-3.0-only
     17 Apache-2.0 OR BSD-3-Clause OR MIT
     16 BSD-4-Clause
     12 zlib-acknowledgement
     11 MIT-0
     11 Apache-2.0 OR MIT OR X11
     10 Apache-2.0 OR BSD-3-Clause
      9 AML
      8 MPL-2.0-no-copyleft-exception
      8 EPL-1.0
      8 BlueOak-1.0.0
      8 Apache-2.0 OR MIT OR WTFPL
      8 Apache-2.0 OR ISC OR MIT
      7 LGPL-2.0-only
      6 EPL-2.0
      6 CC-BY-NC-SA-4.0
      6 BSD-2-Clause-Patent
      6 Apache-2.0 OR Zlib
      6 AFL-3.0
      5 NCSA
      5 MIT OR X11
      5 MIT OR PostgreSQL
      5 MirOS
      5 LGPL-2.1-only
      5 CC-BY-NC-4.0
      5 Apache-2.0 OR MIT OR Zlib
      5 Apache-2.0 OR BSL-1.0
      4 UPL-1.0
      4 MIT OR Zlib
      4 MIT-0 OR 0BSD
      4 EUPL-1.2
      4 CC-BY-SA-4.0
      4 Beerware
      4 Apache-2.0 OR MIT OR Unlicense
      4 Apache-2.0 OR LGPL-2.1-or-later
      4 Apache-2.0 OR BSL-1.0 OR CC0-1.0 OR MIT
      4 AML OR Apache-2.0
      3 WTFPL OR 0BSD
      3 Python-2.0
      3 MIT OR NCSA
      3 LGPL-2.0
      3 ISC OR MIT
      3 GPL-3.0-or-later OR MIT
      3 GPL-2.0 OR GPL-3.0 OR LGPL-3.0
      3 FTL OR GPL-2.0
      3 CECILL-C
      3 CECILL-B
      3 CECILL-2.1
      3 CDDL-1.1
      3 CC-BY-4.0
      3 CC0-1.0 OR MIT
      3 BSD-3-Clause OR GPL-3.0-or-later
      3 BSD-3-Clause-Attribution
      3 BSD-2-Clause-FreeBSD
      3 Artistic-1.0-Perl OR GPL-1.0-or-later
      3 Apache-2.0 OR CC0-1.0 OR MIT
      3 Apache-2.0 AND BSD-2-Clause OR MIT
      2 X11
      2 Sleepycat
      2 RPL-1.5
      2 BSD-3-Clause AND NCSA
      2 MIT AND Zlib
      2 MIT AND ODbL-1.0
      2 LGPL-2.1 OR MPL-1.1
      2 LGPL-2.1 OR LGPL-3.0
      2 LGPL-2.1-or-later OR MIT
      2 LGPL-2.0-or-later
      2 IJG
      2 GPL-3.0 OR MIT
      2 GPL-2.0-or-later WITH Bison-exception-2.2
      2 GPL-1.0
      2 D-FSL-1.0
      2 BSD-3-Clause-Clear
      2 BSD-3-Clause AND GPL-3.0-or-later
      2 BSD-2-Clause OR LGPL-2.1
      2 BSD-2-Clause AND ISC AND MIT
      2 Artistic-2.0
      2 Artistic-1.0 OR GPL-2.0-or-later
      2 APSL-2.0 OR MIT
      2 Apache-2.0 OR UPL-1.0
      2 Apache-2.0 OR MIT OR Unlicense OR WTFPL
      2 Apache-2.0 OR ISC
      2 Apache-2.0 OR GPL-2.0-or-later
      2 Apache-2.0 OR EPL-2.0
      2 Apache-2.0 OR CC0-1.0
      2 Apache-2.0 OR BSL-1.0 OR MIT
      2 Apache-2.0 OR BSD-3-Clause-Clear OR MIT
      2 Apache-2.0 AND Zlib OR MIT AND Zlib
      2 Apache-2.0 AND BSD-3-Clause
      2 Apache-1.0
      2 AFL-1.1
      1 Zlib AND ISC
      1 Zed
      1 SimPL-2.0
      1 PDDL-1.0
      1 Parity-6.0.0
      1 OSL-3.0
      1 OLDAP-2.8
      1 NPOSL-3.0
      1 NLPL
      1 MS-PL
      1 MPL-2.0 AND Python-2.0
      1 MIT OR MPL-1.1 OR Unlicense
      1 MPL-1.1
      1 MIT OR WTFPL
      1 MIT AND WTFPL
      1 MIT AND OFL-1.1
      1 LPPL-1.3c
      1 Libpng
      1 LGPL-3.0 OR MPL-2.0
      1 LGPL-3.0 OR MIT
      1 LGPL-3.0-or-later OR MPL-2.0-or-later
      1 LGPL-2.1 OR MPL-2.0
      1 LGPL-2.1 OR MIT
      1 LGPL-2.1-or-later AND MIT
      1 LGPL-2.0 OR QPL-1.0
      1 LGPL-2.0-or-later AND MIT
      1 GPL-3.0 OR MPL-2.0
      1 GPL-3.0 OR LGPL-3.0 OR MPL-2.0
      1 GPL-3.0 OR LGPL-3.0
      1 GPL-3.0-or-later OR LGPL-3.0-or-later
      1 GPL-3.0-or-later OR ISC
      1 GFDL-1.3 OR GPL-3.0
      1 GPL-3.0-only OR MIT
      1 GPL-2.0 OR LGPL-2.1 OR MPL-1.1
      1 GPL-2.0-or-later AND LGPL-2.1-or-later AND MPL-1.1
      1 CECILL-C OR CECILL-2.1
      1 CDDL-1.0
      1 CC-BY-SA-4.0 OR MIT
      1 CC-BY-NC-SA-2.5
      1 BSD-2-Clause AND MIT
      1 Artistic-1.0-Perl
      1 APL-1.0
      1 Apache-2.0 WITH LLVM-exception OR MIT
      1 Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
      1 Apache-2.0 OR Unlicense
      1 Apache-2.0 OR PostgreSQL
      1 Apache-2.0 OR MIT OR NCSA
      1 Apache-2.0 OR MIT OR 0BSD
      1 Apache-2.0 OR LGPL-2.1 OR MIT
      1 Apache-2.0-or-later OR MIT
      1 Apache-2.0 OR GPL-3.0-or-later OR MIT
      1 Apache-2.0 OR GPL-3.0
      1 Apache-2.0 OR GPL-2.0 OR GPL-3.0 OR MIT
      1 Apache-2.0 OR GPL-2.0
      1 Apache-2.0 OR BSD-3-Clause-Clear
      1 Apache-2.0 OR BSD-2-Clause OR MIT
      1 Apache-2.0 OR Beerware OR MIT
      1 Apache-2.0 AND Parity-6.0.0
      1 Apache-2.0 AND CC0-1.0
      1 Apache-1.0 OR MIT
      1 AGPL-3.0 WITH eCos-exception-2.0
      1 AGPL-3.0-or-later OR OSL-3.0
      1 AGPL-3.0 OR Apache-2.0 OR GPL-3.0 OR MIT
      1 AGPL-1.0 OR MIT
      1 AGPL-1.0
      1 AFL-2.0
      1 0BSD OR Zlib
#!/usr/bin/bash
# Generator script for the raw summary
# Obviously DO NOT run all the time, don't want to overload Crates.io
# Félix Saparelli, Public Domain (CC0)
# Dependencies: bash, ls, sort, sed, uniq, grep, wc, xargs, aria2c
# And jq which is available at: https://stedolan.github.io/jq/
# The entire script takes about 20 minutes to run (lots of crates!)
folder="metacrate-$(date +"%Y.%m.%d-%H-%M-%S")"
echo "---> Create unique folder $folder"
mkdir $folder
cd $folder
echo "---> Fetch the current state of the registry"
git clone --depth=1 git://github.com/rust-lang/crates.io-index.git index
echo "---> Compile a list of every crate indexed"
cd index
ls -1F ** | grep -E '[^/:*@=>|]$' > ../index.tmp
ls -1F **/** | grep -E '[^/:*@=>|]$' >> ../index.tmp
cd ..
grep -oP '(?<=/)?[^/]+$' index.tmp | sort | uniq > index.list
rm index.tmp
echo "---> Got a total of $(wc -l index.list | cut -d\ -f1) crates"
echo "---> Fetch JSON description of every crate (takes a long time)"
xargs -a index.list -n1 -I% echo https://crates.io/api/v1/crates/% > index.urls
mkdir crates
aria2c -j 50 -d crates -i index.urls
echo "---> Extract license information of every crate"
find crates/* -exec cat {} \; | jq -r '.versions[0].license' > licenses.list
echo "---> Compile summary of license usage"
cat <<'SORTER' > sorter
#!/bin/sh
sed -E \
-e 's#^# #' \
-e 's#$# #' \
-e 's#\s+# #g' \
-e 's#\s*/\s*# OR #g' \
-e 's#\s+WITH\s+#-WITH-#g' \
-e 's#\s+AND\s+#-AND-#g' \
-e 's#^\s*$#null#' \
-e 's#\+\s?#-or-later #g' \
\
-e 's# ([B-Z][A-Z0-9.-]+) OR (A[A-Z0-9.-]+) # \2 OR \1 #ig' \
-e 's# ([B-Z][A-Z0-9.-]+) OR (A[A-Z0-9.-]+) # \2 OR \1 #ig' \
-e 's# ([B-Z][A-Z0-9.-]+)-AND-(A[A-Z0-9.-]+) # \2-AND-\1 #ig' \
\
-e 's# (G[A-Z0-9.-]+) OR ([A-F][A-Z0-9.-]+) # \2 OR \1 #ig' \
-e 's# (G[A-Z0-9.-]+)-AND-([A-F][A-Z0-9.-]+) # \2-AND-\1 #ig' \
-e 's# ([H-Z][A-Z0-9.-]+) OR (G[A-Z0-9.-]+) # \2 OR \1 #ig' \
-e 's# ([H-Z][A-Z0-9.-]+)-AND-(G[A-Z0-9.-]+) # \2-AND-\1 #ig' \
\
-e 's# (L[A-Z0-9.-]+) OR ([A-K][A-Z0-9.-]+) # \2 OR \1 #ig' \
-e 's# (L[A-Z0-9.-]+)-AND-([A-K][A-Z0-9.-]+) # \2-AND-\1 #ig' \
-e 's# ([M-Z][A-Z0-9.-]+) OR (L[A-Z0-9.-]+) # \2 OR \1 #ig' \
-e 's# ([M-Z][A-Z0-9.-]+)-AND-(L[A-Z0-9.-]+) # \2-AND-\1 #ig' \
\
-e 's# (M[A-Z0-9.-]+) OR ([A-L][A-Z0-9.-]+) # \2 OR \1 #ig' \
-e 's# (M[A-Z0-9.-]+)-AND-([A-L][A-Z0-9.-]+) # \2-AND-\1 #ig' \
-e 's# ([N-Z][A-Z0-9.-]+) OR (M[A-Z0-9.-]+) # \2 OR \1 #ig' \
-e 's# ([N-Z][A-Z0-9.-]+)-AND-(M[A-Z0-9.-]+) # \2-AND-\1 #ig' \
\
-e 's# (M[J-Z][A-Z0-9.-]*) OR MIT # MIT OR \1 #ig' \
\
-e 's#-AND-# AND #g' \
-e 's#-WITH-# WITH #g' \
-e 's#\s+# #g' \
-e 's#^\s+##' \
-e 's#\s+$##' \
licenses.list \
| sort \
| uniq -c \
| sort -nr
SORTER
chmod +x sorter
./sorter > summary
echo "---> Here's the summary:"
cat summary
@robinst
Copy link

robinst commented Apr 27, 2016

Nice script! Ran it again just now:

   2614 "MIT"
    910 "MIT/Apache-2.0"
    266 "Apache-2.0"
    102 "GPL-3.0"
    100 "BSD-3-Clause"
     86 "non-standard"
     79 "MPL-2.0"
     69 "CC0-1.0"
     61 "BSD-2-Clause"
     40 "WTFPL"
     38 "ISC"
     37 "Unlicense"
     37 null
     37 "LGPL-3.0"
     30 "Zlib"
     27 "Unlicense/MIT"
     21 "GPL-2.0"
     20 "LGPL-3.0+"
     20 "AGPL-3.0"
     18 "LGPL-2.1"
     16 "GPL-3.0+"
     11 "GPL-2.0+"
     10 "LGPL-2.1+"
     10 "BSL-1.0"
      7 "zlib-acknowledgement"
      6 " GPL-2.0"
      5 "AML"
      3 "MIT/ISC"
      2 "Python-2.0"
      2 "MITNFA"
      2 "GPL-2.0+ AND AGPL-3.0+"
      2 "BSL-1.0/Apache-2.0"
      2 "BSD-4-Clause"
      2 "Apache-2.0/BSD-3-Clause-Clear/MIT"
      2 "AML/Apache-2.0"
      1 "Zlib/Libpng"
      1 "Zed"
      1 "Unlicense/MPL-1.1/MIT"
      1 "Unlicense/Apache-2.0"
      1 "NCSA"
      1 "MPL-2.0-no-copyleft-exception"
      1 "MIT/WTFPL/BSL-1.0"
      1 "MIT/BSD-3-Clause"
      1 "MIT/BSD-2-Clause"
      1 "MIT/Apache-2.0/BSD-3-Clause"
      1 "MIT/Apache-1.0"
      1 "MIT/AGPL-1.0"
      1 "MirOS"
      1 "LGPL-2.0+"
      1 "LGPL-2.0"
      1 "IJG"
      1 "GPL-3.0/LGPL-3.0"
      1 "GPL-3.0+/BSD-3-Clause"
      1 " GPL-3.0"
      1 "GPL-2.0/GPL-3.0/MIT/Apache-2.0"
      1 "FTL / GPL-2.0"
      1 "CC-BY-SA-4.0/MIT"
      1 "CC-BY-NC-4.0"
      1 "Apache-2.0/GPL-2.0"
      1 "AGPL-3.0 WITH eCos-exception-2.0"
      1 "AGPL-3.0+"

(Used ls | xargs cat -- | sed 's|MIT / Apache-2.0|MIT/Apache-2.0|' | sed 's|MIT OR Apache-2.0|MIT/Apache-2.0|' | sed 's|Apache-2.0 / MIT|MIT/Apache-2.0|' | sed 's|Apache-2.0 OR MIT|MIT/Apache-2.0|' | sed 's|Apache-2.0/MIT|MIT/Apache-2.0|' | sort | uniq -c | sort -nr to consolidate duplicates.)

@vmx
Copy link

vmx commented Feb 3, 2020

@passcod Thanks a lot for the script! I updated to make it work with the current index and also used @robinst sed commands:

#!/usr/bin/bash
# Generator script for the raw summary
# Obviously DO NOT run all the time, don't want to overload Crates.io
# Félix Saparelli, Public Domain (CC0)
# Dependencies: bash, ls, sort, uniq, grep, wc, xargs, aria2c
# And jq which is available at: http://stedolan.github.io/jq/
# The entire script takes about 30 seconds to run, bottleneck is net

folder="metacrate-$(date +"%Y.%m.%d-%H-%M-%S")"
echo "---> Create unique folder $folder"
mkdir $folder
cd $folder

echo "---> Fetch the current state of the registry"
git clone --depth=1 git://github.com/rust-lang/crates.io-index.git index

echo "---> Compile a list of every crate indexed"
cd index
ls -1F ** | grep -E '[^/:*@=>|]$' > ../index.tmp
ls -1F **/** | grep -E '[^/:*@=>|]$' >> ../index.tmp
cd ..
cat index.tmp | grep -oP '(?<=/)?[^/]+$' | sort | uniq > index.list
rm index.tmp

echo "---> Got a total of $(wc -l index.list | cut -d\  -f1) crates"

echo "---> Fetch JSON description of every crate"
cat index.list | xargs -n1 echo https://crates.io/api/v1/crates/ | tr -d ' ' > index.urls
mkdir crates
aria2c -j 50 -d crates -i index.urls

echo "---> Extract license information of every crate"
find crates/* -exec cat {} \; | jq -r '.versions[0].license' > licenses.list

echo "---> Compile summary of license usage"
cat licenses.list| sed 's|MIT / Apache-2.0|MIT/Apache-2.0|' | sed 's|MIT OR Apache-2.0|MIT/Apache-2.0|' | sed 's|Apache-2.0 / MIT|MIT/Apache-2.0|' | sed 's|Apache-2.0 OR MIT|MIT/Apache-2.0|' | sed 's|Apache-2.0/MIT|MIT/Apache-2.0|' | sort | uniq -c | sort -nr > summary

echo "---> Here's the summary:"
cat summary

The result from 2020-02-03 is (I left the ones with less that 10 crates out for for brevity):

  15613 MIT
   9381 MIT/Apache-2.0
   3001 Apache-2.0
    978 non-standard
    886 GPL-3.0
    714 MPL-2.0
    656 BSD-3-Clause
    352 CC0-1.0
    348 ISC
    340 GPL-3.0-or-later
    300 BSD-2-Clause
    236 AGPL-3.0
    209 Unlicense
    183 WTFPL
    159 LGPL-3.0
    127 GPL-3.0-only
    126 GPL-3.0+
    118 LGPL-2.1
    117 0BSD
    101 Zlib
     91 Apache-2.0 WITH LLVM-exception
     83 GPL-2.0
     76 Unlicense/MIT
     68 AGPL-3.0-or-later
     53 LGPL-3.0+
     50 LGPL-3.0-or-later
     49 AGPL-3.0+
     38 Unlicense OR MIT
     36 null
     35 MIT / BSL-1.0
     34 GPL-2.0+
     32 AGPL-3.0-only
     28 MITNFA
     26 MIT OR BSD-3-Clause
     25 GPL-2.0-or-later
     23 BSL-1.0
     22 GPL-2.0-only
     21 LGPL-2.1+
     21 BSD-2-Clause OR MIT
     20 Fair
     19 MPL-2.0+
     18 LGPL-2.1-or-later
     14 MIT/Apache-2.0/BSD-3-Clause
     14 BSD-4-Clause
     13 MPL-2.0/MIT/Apache-2.0
     13 LGPL-3.0-only
     12 zlib-acknowledgement
     11 MIT-0
     10 MPL-2.0 OR MIT/Apache-2.0
     10 MIT/X11 OR Apache-2.0
     10 MIT/Apache-2.0 OR MPL-2.0
     10 Apache-2.0 AND MIT
…

@passcod
Copy link
Author

passcod commented Feb 4, 2020

Updated the gist with your changes plus some more, thanks

@vmx
Copy link

vmx commented Feb 4, 2020

@passcod: the "Compile a list of every crate indexed" step creates a lot of duplicated entries. The sorting needs to be done after the grep:

$ sort index.tmp | uniq | grep -oP '(?<=/)?[^/]+$' | wc -l
70579
$ grep -oP '(?<=/)?[^/]+$' index.tmp | sort | uniq | wc -l
35290

@passcod
Copy link
Author

passcod commented Feb 4, 2020

Ahhh, I didn't catch that while reading through

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment