slpkg/setup.py

104 lines
3.5 KiB
Python
Raw Normal View History

2014-05-23 08:46:51 +03:00
#!/usr/bin/python
# -*- coding: utf-8 -*-
2014-08-27 21:12:17 +03:00
# setup.py file is part of slpkg.
2014-08-13 07:28:04 +03:00
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
2014-12-19 06:57:56 +02:00
# Slpkg is a user-friendly package manager for Slackware installations
2014-08-13 07:28:04 +03:00
# https://github.com/dslackw/slpkg
2014-08-27 21:12:17 +03:00
# Slpkg is free software: you can redistribute it and/or modify
2014-08-13 07:28:04 +03:00
# 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 <http://www.gnu.org/licenses/>.
2014-06-20 04:43:40 +03:00
import os
import sys
2014-10-03 16:57:18 +03:00
import gzip
2014-06-20 04:43:40 +03:00
import shutil
2014-05-23 08:46:51 +03:00
2015-01-24 17:19:06 +02:00
from slpkg.__metadata__ import MetaData as _m
2014-12-07 14:19:30 +02:00
from slpkg.md5sum import md5
2014-11-26 05:42:23 +02:00
2014-07-16 06:21:47 +03:00
2014-07-17 05:46:34 +03:00
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
2014-05-23 08:46:51 +03:00
setup(
2014-09-21 23:08:20 +03:00
name="slpkg",
2014-11-07 06:44:16 +02:00
packages=["slpkg", "slpkg/sbo", "slpkg/pkg", "slpkg/slack",
2015-01-29 04:21:22 +02:00
"slpkg/binary"],
2014-09-21 23:08:20 +03:00
scripts=["bin/slpkg"],
2015-01-24 17:19:06 +02:00
version=_m.__version__,
2014-06-20 04:43:40 +03:00
description="Python tool to manage Slackware packages",
keywords=["slackware", "slpkg", "upgrade", "install", "remove",
2014-10-14 06:01:38 +03:00
"view", "slackpkg", "tool", "build"],
2015-01-24 17:19:06 +02:00
author=_m.__author__,
author_email=_m.__email__,
2014-06-20 04:43:40 +03:00
url="https://github.com/dslackw/slpkg",
package_data={"": ["LICENSE", "README.rst", "CHANGELOG"]},
classifiers=[
2014-07-17 05:46:34 +03:00
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
2014-05-23 08:46:51 +03:00
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: POSIX :: Linux",
2014-07-17 05:46:34 +03:00
"Operating System :: Unix",
2014-05-23 08:46:51 +03:00
"Programming Language :: Python",
2014-07-17 05:46:34 +03:00
"Programming Language :: Python :: 2",
2014-05-23 08:46:51 +03:00
"Programming Language :: Python :: 2.7",
2014-07-17 05:46:34 +03:00
"Programming Language :: Unix Shell",
"Topic :: Software Development :: Build Tools",
"Topic :: System :: Archiving :: Packaging",
"Topic :: System :: Software Distribution",
"Topic :: Utilities"],
2014-05-23 08:46:51 +03:00
long_description=open("README.rst").read()
2014-07-16 06:21:47 +03:00
)
2014-05-23 08:46:51 +03:00
2014-10-14 06:01:38 +03:00
# install man page and blacklist configuration
2014-10-03 16:57:18 +03:00
# file if not exists.
2014-09-21 23:08:20 +03:00
if "install" in sys.argv:
2014-05-23 08:46:51 +03:00
man_path = "/usr/man/man8/"
2014-09-27 23:54:30 +03:00
os.system("mkdir -p {0}".format(man_path))
2014-05-23 08:46:51 +03:00
if os.path.exists(man_path):
man_page = "man/slpkg.8"
2014-10-03 16:57:18 +03:00
gzip_man = "man/slpkg.8.gz"
print("Installing man pages")
f_in = open(man_page, "rb")
f_out = gzip.open(gzip_man, 'wb')
f_out.writelines(f_in)
f_out.close()
f_in.close()
shutil.copy2(gzip_man, man_path)
2014-09-21 23:08:20 +03:00
os.chmod(man_path, int("444", 8))
2014-11-13 13:32:40 +02:00
2014-11-22 11:16:39 +02:00
conf_file = [
'conf/slpkg.conf',
'conf/blacklist',
2015-01-04 03:40:35 +02:00
'conf/slackware-mirrors',
'conf/custom-repositories'
2014-11-22 11:16:39 +02:00
]
2015-01-24 17:19:06 +02:00
if not os.path.exists(_m.conf_path):
os.system("mkdir -p {0}".format(_m.conf_path))
2015-01-29 03:42:31 +02:00
shutil.copy2(conf_file[0], _m.conf_path + conf_file[0])
for conf in conf_file[1:]:
2014-11-26 05:42:23 +02:00
filename = conf.split("/")[-1]
print("Installing '{0}' file".format(filename))
2015-01-24 17:19:06 +02:00
if os.path.isfile(_m.conf_path + filename):
old = md5(_m.conf_path + filename)
2014-12-07 14:19:30 +02:00
new = md5(conf)
2014-11-26 05:42:23 +02:00
if old != new:
2015-01-24 17:19:06 +02:00
shutil.copy2(conf, _m.conf_path + filename + ".new")
2014-11-26 05:42:23 +02:00
else:
2015-01-24 17:19:06 +02:00
shutil.copy2(conf, _m.conf_path)