]> git.ipfire.org Git - pakfire.git/blame - pakfire/packages/__init__.py
One huge commit, that breaks pakfire.
[pakfire.git] / pakfire / packages / __init__.py
CommitLineData
47a4cb89 1#!/usr/bin/python
b792d887
MT
2###############################################################################
3# #
4# Pakfire - The IPFire package management system #
5# Copyright (C) 2011 Pakfire development team #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
47a4cb89 21
8276111d
MT
22import tarfile
23
47a4cb89 24from binary import BinaryPackage
114ac7ee 25from file import InnerTarFile
fa6d335b 26from installed import DatabasePackage, InstalledPackage
c605d735 27from solv import SolvPackage
47a4cb89 28from source import SourcePackage
47a4cb89 29
47a4cb89 30from make import Makefile
03f33deb 31from packager import BinaryPackager
677ff42a
MT
32
33from pakfire.constants import *
34
35def open(pakfire, repo, filename):
36 """
37 Function to open all packages and return the right object.
38
39 Abstractly, this detects if a package is a source package or
40 not.
41 """
42 # XXX We should make this check much better...
8276111d
MT
43
44 # Simply check if the given file is a tarfile.
45 if tarfile.is_tarfile(filename):
46 if filename.endswith(".src.%s" % PACKAGE_EXTENSION):
47 return SourcePackage(pakfire, repo, filename)
48
49 return BinaryPackage(pakfire, repo, filename)
677ff42a 50
7c8f2953
MT
51 elif filename.endswith(".%s" % MAKEFILE_EXTENSION):
52 return Makefile(pakfire, filename)