librepip installer

Sin respostas
jorgesumle
Desconectado
Joined: 06/01/2016

I made a script to check whether a PyPI distribution is free. The code repository is hosted in a Tor hidden service It's not very efficient, but here you are:

librepip file


#!/bin/bash

# Copyright (C) 2018 Jorge Maldonado Ventura <name at domain>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .

usage(){
cat << _EOF_
Checks if a PyPI distribution is nonfree, it takes into account all its
dependencies. The exit status is zero, unless a non-free distribution is
detected.
_EOF_
}

if [ "$1" = '--version' ]; then
echo "Librepip 0.1"
exit
elif [ "$1" = '--help' -o "$1" = '-h' ]; then
usage
exit
fi

for i in "$@"; do
case $i in
-v)
verbose=on
shift
;;
*)
DISTRIBUTIONS+=("$1")
shift
;;
esac
done

set -- "${DISTRIBUTIONS[@]}" # We only care about distributions now

verbose_echo () {
if [ -n "$verbose" ]; then
echo $1
fi
}

checked=$1

check_if_libre () {
if [ -z "$1" ]; then
return 0
fi

grep -q "\<$1\>" <<< $checked
if [ $? -eq 1 ]; then
return
fi

local req=$(pip show "$1" | grep 'Requires:' | cut -d: -f2 | sed -e 's/,[[:space:]]/ /g')
local licences=$(pip show --verbose "$1" | grep -o 'License ::.*')

if [ -z "$licenses" ]; then
verbose_echo "The distribution $1 is proprietary, because it lacks a license"
return 1
fi

while read -r license; do
grep -q "$license" <<< "$licenses"
if [ $? -ne 0 ]; then
verbose_echo "The license $license is not a free software license"
return 1
fi
done <<< $licenses

checked="$checked $1"
shift
check_if_libre $@ $req
}

check_if_libre $1

free_software_licenses file


License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
License :: DFSG approved
License :: Eiffel Forum License (EFL)
License :: Netscape Public License (NPL)
License :: Nokia Open Source License (NOKOS)
License :: OSI Approved :: Academic Free License (AFL)
License :: OSI Approved :: Apache Software License
License :: OSI Approved :: BSD License
License :: OSI Approved :: CEA CNRS Inria Logiciel Libre License, version 2.1 (CeCILL-2.1)
License :: OSI Approved :: Common Public License
License :: OSI Approved :: Eclipse Public License 1.0 (EPL-1.0)
License :: OSI Approved :: Eiffel Forum License
License :: OSI Approved :: European Union Public Licence 1.1 (EUPL 1.1)
License :: OSI Approved :: GNU Affero General Public License v3
License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
License :: OSI Approved :: GNU Free Documentation License (FDL)
License :: OSI Approved :: GNU General Public License (GPL)
License :: OSI Approved :: GNU General Public License v2 (GPLv2)
License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
License :: OSI Approved :: GNU General Public License v3 (GPLv3)
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)
License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)
License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
License :: OSI Approved :: IBM Public License
License :: OSI Approved :: Jabber Open Source License
License :: OSI Approved :: MIT License
License :: OSI Approved :: Mozilla Public License 1.0 (MPL)
License :: OSI Approved :: Mozilla Public License 1.1 (MPL 1.1)
License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
License :: OSI Approved :: Nokia Open Source License
License :: OSI Approved :: Python License (CNRI Python License)
License :: OSI Approved :: Python Software Foundation License
License :: OSI Approved :: Qt Public License (QPL)
License :: OSI Approved :: Sleepycat License
License :: OSI Approved :: Sun Industry Standards Source License (SISSL)
License :: OSI Approved :: Sun Public License
License :: OSI Approved :: Universal Permissive License (UPL)
License :: OSI Approved :: University of Illinois/NCSA Open Source License
License :: OSI Approved :: W3C License
License :: OSI Approved :: zlib/libpng License
License :: Public Domain

It was fun to made but it's not a great solution. PyPI doesn't let me make many queries, so if you abuse it you'll probably get blocked for some time. You can make lots of stuff with GNU Bash and basic GNU commands as you can see.