Commit e477d2ab authored by Lukas Appelhans's avatar Lukas Appelhans
Browse files

Add gitrepository, gitfolder and gitbranch to packages

parent 3d2b5d53
......@@ -15,7 +15,10 @@ CREATE TABLE IF NOT EXISTS packages (
`flags` TEXT NULL DEFAULT NULL ,
`screenshoturl` TEXT NULL DEFAULT NULL ,
`installreason` INTEGER NULL DEFAULT 0,
`installdate` INTEGER NULL DEFAULT NULL );
`installdate` INTEGER NULL DEFAULT NULL,
`gitrepository` TEXT NULL DEFAULT NULL,
`gitbranch` TEXT NULL DEFAULT 'master',
`gitfolder` TEXT NULL DEFAULT NULL);
CREATE INDEX `packages_name` ON `packages` (`name` ASC) ;
......
/* This file is part of the Chakra project
Copyright (C) 2010 Dario Freddi <drf@chakra-project.org>
Copyright (C) 2012 Lukas Appelhans <boom1992@chakra-project.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
......@@ -579,6 +580,18 @@ Package* Backend::loadPackageFromFile(const QString& path)
retpackage->d_func()->hasHooks = true;
} else if (key == "epoch") {
retpackage->d_func()->version.d->epoch = value.toInt();
} else if (key == "gitfolder") {
retpackage->d_func()->gitFolder = value;
} else if (key == "gitrepository") {
retpackage->d_func()->gitRepo = value;
} else if (key == "gitbranch") {
retpackage->d_func()->gitBranch = value;
} else if (key == "gitrepo") { //This is legacy support
QStringList split = value.split("-");
if (!split.isEmpty()) {
retpackage->d_func()->gitRepo = split.takeFirst();
retpackage->d_func()->gitBranch = split.isEmpty() ? "master" : split.first();
}
}
}
......
/* This file is part of the Chakra project
Copyright (C) 2010 Dario Freddi <drf@chakra-project.org>
Copyright (C) 2011 Lukas Appelhans <l.appelhans@gmx.de>
Copyright (C) 2011 - 2012 Lukas Appelhans <l.appelhans@gmx.de>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
......@@ -362,11 +362,11 @@ int QueryPerformer::insertPackage(SQLiteConnection &dbConnection, Package* p)
QString sqlQuery =
"INSERT INTO packages ('name', 'version', 'epoch', 'filename', 'description', 'size', 'installedsize', "
"'md5sum', 'url', 'builddate', 'arch', 'packager', "
"'flags', 'screenshoturl', 'installreason', 'installdate') "
"'flags', 'screenshoturl', 'installreason', 'installdate', 'gitrepository', 'gitbranch', 'gitfolder') "
"VALUES ("
":Name, :Version, :Epoch, :Filename, :Description, :Size, :InstalledSize, "
":MD5SUM, :URL, :BuildDate, :Arch, :Packager, "
":Flags, :ScreenShotURL, :InstallReason, :InstallDate)";
":Flags, :ScreenShotURL, :InstallReason, :InstallDate, :GitRepo, :GitBranch, :GitFolder)";
dbConnection.bind(":Name", p->name());
dbConnection.bind(":Version", p->version().toByteArray());
......@@ -396,6 +396,9 @@ int QueryPerformer::insertPackage(SQLiteConnection &dbConnection, Package* p)
dbConnection.bind(":InstallReason", (int)p->installReason());
dbConnection.bind(":InstallDate", p->installDate().toTime_t());
dbConnection.bind(":GitRepo", p->gitRepo());
dbConnection.bind(":GitBranch", p->gitBranch());
dbConnection.bind(":GitFolder", p->gitFolder());
dbConnection.query(sqlQuery);
int id = dbConnection.getLastRowId();
......@@ -407,17 +410,17 @@ int QueryPerformer::insertPackage(SQLiteConnection &dbConnection, Package* p)
sqlQuery = "INSERT INTO belongsgroup ('package', 'groupname') VALUES (:Package, :Group);";
dbConnection.bind(":Package", id);
dbConnection.bind(":Group", group->name());
dbConnection.query(sqlQuery);
dbConnection.query(sqlQuery);
}
foreach (const QString& dependency, p->dependencies()) {
sqlQuery = "INSERT INTO depends ('package', 'dependency') VALUES (:Package, :Depend);";
dbConnection.bind(":Package", id);
dbConnection.bind(":Depend", dependency);
dbConnection.query(sqlQuery);
dbConnection.query(sqlQuery);
}
foreach (const QString& opt, p->optionalDependencies()) {
foreach (const QString& opt, p->optionalDependencies()) {
sqlQuery = "INSERT INTO optional ('package', 'dependency') VALUES (:Package, :OptDepend);";
dbConnection.bind(":Package", id);
dbConnection.bind(":OptDepend", opt);
......@@ -428,21 +431,21 @@ int QueryPerformer::insertPackage(SQLiteConnection &dbConnection, Package* p)
sqlQuery = "INSERT INTO replaces ('package', 'replaces') VALUES (:Package, :Replace);";
dbConnection.bind(":Package", id);
dbConnection.bind(":Replace", replace);
dbConnection.query(sqlQuery);
dbConnection.query(sqlQuery);
}
foreach (const QString& provides, p->provides()) {
sqlQuery = "INSERT INTO provides ('package', 'provides') VALUES (:Package, :Provides);";
dbConnection.bind(":Package", id);
dbConnection.bind(":Provides", provides);
dbConnection.query(sqlQuery);
dbConnection.query(sqlQuery);
}
foreach (const QString& conflict, p->conflictsWith()) {
sqlQuery = "INSERT INTO conflicts ('package', 'conflict') VALUES (:Package, :Conflict);";
dbConnection.bind(":Package", id);
dbConnection.bind(":Conflict", conflict);
dbConnection.query(sqlQuery);
dbConnection.query(sqlQuery);
}
foreach (const QString &mimetype, p->mimetypes()) {
......@@ -546,7 +549,7 @@ int QueryPerformer::updatePackage(SQLiteConnection &dbConnection, Package* from,
"Name=:Name, Version=:Version, Epoch=:Epoch, Filename=:Filename, Description=:Description, Size=:Size, "
"InstalledSize=:InstalledSize, MD5SUM=:MD5SUM, URL=:URL, BuildDate=:BuildDate, Arch=:Arch, Packager=:Packager, "
"Flags=:Flags, ScreenShotURL=:ScreenShotURL, "
"InstallReason=:InstallReason, InstallDate=:InstallDate "
"InstallReason=:InstallReason, InstallDate=:InstallDate, GitRepository=:GitRepo, GitBranch=:GitBranch, GitFolder=:GitFolder "
"WHERE ID=:PreviousPackageId";
try {
......@@ -578,6 +581,9 @@ int QueryPerformer::updatePackage(SQLiteConnection &dbConnection, Package* from,
dbConnection.bind(":InstallReason", (int)p->installReason());
dbConnection.bind(":InstallDate", p->installDate().toTime_t());
dbConnection.bind(":GitRepo", p->gitRepo());
dbConnection.bind(":GitBranch", p->gitBranch());
dbConnection.bind(":GitFolder", p->gitFolder());
dbConnection.bind(":PreviousPackageId", from->databaseId());
dbConnection.query(sqlQuery);
......@@ -600,17 +606,17 @@ int QueryPerformer::updatePackage(SQLiteConnection &dbConnection, Package* from,
sqlQuery = "INSERT INTO belongsgroup ('package', 'groupname') VALUES (:Package, :Group);";
dbConnection.bind(":Package", p->databaseId());
dbConnection.bind(":Group", group->name());
dbConnection.query(sqlQuery);
dbConnection.query(sqlQuery);
}
foreach (const QString& dependency, p->dependencies()) {
sqlQuery = "INSERT INTO depends ('package', 'dependency') VALUES (:Package, :Depend);";
dbConnection.bind(":Package", p->databaseId());
dbConnection.bind(":Depend", dependency);
dbConnection.query(sqlQuery);
dbConnection.query(sqlQuery);
}
foreach (const QString& opt, p->optionalDependencies()) {
foreach (const QString& opt, p->optionalDependencies()) {
sqlQuery = "INSERT INTO optional ('package', 'dependency') VALUES (:Package, :OptDepend);";
dbConnection.bind(":Package", p->databaseId());
dbConnection.bind(":OptDepend", opt);
......@@ -621,21 +627,21 @@ int QueryPerformer::updatePackage(SQLiteConnection &dbConnection, Package* from,
sqlQuery = "INSERT INTO replaces ('package', 'replaces') VALUES (:Package, :Replace);";
dbConnection.bind(":Package", p->databaseId());
dbConnection.bind(":Replace", replace);
dbConnection.query(sqlQuery);
dbConnection.query(sqlQuery);
}
foreach (const QString& provides, p->provides()) {
sqlQuery = "INSERT INTO provides ('package', 'provides') VALUES (:Package, :Provides);";
dbConnection.bind(":Package", p->databaseId());
dbConnection.bind(":Provides", provides);
dbConnection.query(sqlQuery);
dbConnection.query(sqlQuery);
}
foreach (const QString& conflict, p->conflictsWith()) {
sqlQuery = "INSERT INTO conflicts ('package', 'conflict') VALUES (:Package, :Conflict);";
dbConnection.bind(":Package", p->databaseId());
dbConnection.bind(":Conflict", conflict);
dbConnection.query(sqlQuery);
dbConnection.query(sqlQuery);
}
foreach (const QString &mimetype, p->mimetypes()) {
......
......@@ -710,6 +710,24 @@ bool Package::operator==(const Akabei::Package& other) const
size() == other.size());
}
QString Package::gitRepo() const
{
Q_D(const Package);
return d->gitRepo;
}
QString Package::gitBranch() const
{
Q_D(const Package);
return d->gitBranch;
}
QString Package::gitFolder() const
{
Q_D(const Package);
return d->gitFolder;
}
Package* Package::generateInstalledPackage(Package::InstallReason ireason, const QDateTime& idate)
{
Q_D(Package);
......
......@@ -332,6 +332,22 @@ public:
*/
bool operator==(const Package &other) const;
/**
* @returns the git repository where we store the PKGBUILD
*/
QString gitRepo() const;
/**
* @returns the git branch where we store the PKGBUILD
*/
QString gitBranch() const;
/**
* @returns the git folder where we store the PKGBUILD
*/
QString gitFolder() const;
private:
PackagePrivate * const d_ptr;
......
......@@ -95,6 +95,10 @@ public:
bool _p_validated;
bool _p_md5checked;
QString gitRepo;
QString gitBranch;
QString gitFolder;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment