Last active
April 16, 2018 01:22
-
-
Save mnacharov/9ab2f6381d23ddfe70891f25b5ca888e to your computer and use it in GitHub Desktop.
pyenv debian-package builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pyenv (2017.02.09-1) stable; urgency=medium | |
* Initial Release | |
-- Mikhail Nacharov <www-webnach-ru> Thu, 09 Feb 2017 22:36:16 +0500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/etc/profile.d/pyenv.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Package: pyenv | |
Version: 2017.02.09-1 | |
Maintainer: Mikhail Nacharov <www-webnach-ru> | |
Architecture: all | |
Section: python | |
Depends: make, gcc, libssl-dev, zlib1g-dev, libbz2-dev, libreadline-dev, libsqlite3-dev | |
Suggests: libxml2-dev, libxslt1-dev, zlib1g-dev, libmysqlclient-dev | |
Priority: optional | |
Origin: https://github.com/yyuu/pyenv | |
Description: Simple Python Version Management: pyenv. | |
pyenv lets you easily switch between multiple versions of Python. | |
It's simple, unobtrusive, and follows the UNIX tradition of | |
single-purpose tools that do one thing well. | |
. | |
This project was forked from rbenv and ruby-build, and | |
modified for Python. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Copyright (c) 2017 Yamashita, Yuu | |
Copyright (c) 2017 Sam Stephenson | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
"Software"), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, | |
distribute, sublicense, and/or sell copies of the Software, and to | |
permit persons to whom the Software is furnished to do so, subject to | |
the following conditions: | |
The above copyright notice and this permission notice shall be | |
included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Makefile for update and build pyenv debian package # | |
# Used directories | |
PYENV_SRC=pyenv.src | |
PYENV_BUILD=pyenv | |
PYENV_TARGET=$(PYENV_BUILD)/usr/share/pyenv | |
# Files wich needs to be removed from debian package | |
NOT_NEEDED_FILES=.agignore CHANGELOG.md CONDUCT.md .git .gitignore LICENSE \ | |
Makefile src test .travis.yml .vimrc plugins/.gitignore plugins/*/.git \ | |
plugins/*/.gitignore plugins/*/test plugins/*/LICENSE | |
# Extract version from control for package name | |
VERSION="`cat pyenv/DEBIAN/control|grep 'Version:'|awk '{print $$2}'`" | |
build: pyenv | |
fakeroot dpkg-deb --build $(PYENV_BUILD) | |
mkdir -p dists | |
mv -v pyenv.deb dists/pyenv_$(VERSION)_all.deb | |
# configure build dir | |
pyenv: pyenv.src update | |
rm -Rf $(PYENV_BUILD); | |
`# move pyenv directory to PYENV_TARGET` | |
mkdir -p `dirname $(PYENV_TARGET)` | |
cp -R pyenv.src $(PYENV_TARGET) | |
cd $(PYENV_TARGET) && rm -Rf $(NOT_NEEDED_FILES) | |
`# users from pyenv group can write to those directories` | |
mkdir -p -m 775 $(PYENV_TARGET)/cache | |
mkdir -p -m 775 $(PYENV_TARGET)/shims | |
mkdir -p -m 775 $(PYENV_TARGET)/versions | |
`# install virtualenv for all new pythons` | |
echo "virtualenv" > $(PYENV_TARGET)/default-packages | |
`# all pythons must have envs for virutual environments` | |
cp mkdir-envs.bash $(PYENV_TARGET)/plugins/pyenv-default-packages/etc/pyenv.d/install/ | |
`# copy profile.d and doc directory in usr` | |
mkdir -p $(PYENV_BUILD)/etc/profile.d | |
cp pyenv.sh $(PYENV_BUILD)/etc/profile.d | |
mkdir -p $(PYENV_BUILD)/usr/share/doc/pyenv | |
cp copyright $(PYENV_BUILD)/usr/share/doc/pyenv | |
gzip --best -k -c changelog.Debian > $(PYENV_BUILD)/usr/share/doc/pyenv/changelog.Debian.gz | |
`# package information` | |
mkdir $(PYENV_BUILD)/DEBIAN | |
for file in conffiles control postinst postrm preinst; do \ | |
cp $$file $(PYENV_BUILD)/DEBIAN; \ | |
done; | |
# initial clone - pyenv and relevant plugins | |
pyenv.src: | |
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer \ | |
| PYENV_ROOT=$(PYENV_SRC) bash | |
git clone https://github.com/jawshooah/pyenv-default-packages $(PYENV_SRC)/plugins/pyenv-default-packages | |
# pyenv-update do all work for us | |
update: | |
PYENV_ROOT=$(PYENV_SRC) PATH="$(PYENV_SRC)/bin:$(PATH)" pyenv update | |
# remove all temporary directories | |
clean: | |
rm -Rf $(PYENV_BUILD) | |
rm -Rf $(PYENV_SRC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if declare -Ff after_install >/dev/null; then | |
after_install 'mkdir -m 770 $PYENV_ROOT/versions/$VERSION_NAME/envs && \ | |
chmod +t $PYENV_ROOT/versions/$VERSION_NAME/envs' | |
else | |
echo "pyenv: pyenv-default-packages plugin requires pyenv v0.1.0 or later" >&2 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chown root:pyenv -R /usr/share/pyenv | |
chmod g+s /usr/share/pyenv/versions | |
chmod +t /usr/share/pyenv/versions | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
groupdel pyenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
groupadd -f -r pyenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if groups | grep &>/dev/null '\bpyenv\b'; then | |
export PYENV_ROOT="/usr/share/pyenv"; | |
export PATH="$PYENV_ROOT/bin:$PATH"; | |
eval "$(pyenv init -)"; | |
eval "$(pyenv virtualenv-init -)"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment