mock build.Part 4
This commit is contained in:
31
app.rb
31
app.rb
@@ -833,15 +833,46 @@ get "/gitpackages/:git_id" do
|
|||||||
@page = params["p"].to_i
|
@page = params["p"].to_i
|
||||||
if @page < 1
|
if @page < 1
|
||||||
@page = 1
|
@page = 1
|
||||||
|
else
|
||||||
|
@page = @page + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if rpms_lst.nil?
|
||||||
|
rpms_lst = []
|
||||||
|
end
|
||||||
items_per_page = cfg.get_items_per_page
|
items_per_page = cfg.get_items_per_page
|
||||||
@rpms_list = rpms_lst[(@page - 1) * items_per_page, items_per_page]
|
@rpms_list = rpms_lst[(@page - 1) * items_per_page, items_per_page]
|
||||||
|
@max_pages = rpms_lst.length / items_per_page
|
||||||
|
if (@max_pages * items_per_page) != rpms_lst.length
|
||||||
|
@max_pages = @max_pages + 1
|
||||||
|
end
|
||||||
|
@git_id = params["git_id"]
|
||||||
erb :rpmlistgit
|
erb :rpmlistgit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get "/rpminfo/:rpm_id" do
|
||||||
|
rpm_info = db.get_rpm_info(params["rpm_id"])
|
||||||
|
if rpm_info.nil?
|
||||||
|
print_error_page(503, "Пакета не существует")
|
||||||
|
else
|
||||||
|
@page_name = "Информация о пакете #{rpm_info[:rpmname]}"
|
||||||
|
@rpm_data = rpm_info
|
||||||
|
@repo_id = rpm_info[:repo_id]
|
||||||
|
rpm_reader = RPMReader.new()
|
||||||
|
rpm_pkg = rpm_reader.get_rpm_info(rpm_info[:savepath])
|
||||||
|
if rpm_pkg[:error].nil?
|
||||||
|
@build_id = db.get_rpm_build(params["rpm_id"])
|
||||||
|
@pkg_info = rpm_pkg[:pkginfo]
|
||||||
|
@rpms_info = db.get_rpm_srpms(params["rpm_id"])
|
||||||
|
erb :rpminfo
|
||||||
|
else
|
||||||
|
print_error_page(503, "Ошибка чтения пакета #{rpm_info[:rpmname]}: #{rpm_pkg[:error]}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
not_found do
|
not_found do
|
||||||
status 404
|
status 404
|
||||||
@page_name = "Кто-то потерялся"
|
@page_name = "Кто-то потерялся"
|
||||||
|
|||||||
@@ -270,4 +270,40 @@ class DBase
|
|||||||
def get_rpms_for_git(git_id)
|
def get_rpms_for_git(git_id)
|
||||||
$DDB["select t2.id as rpmid, t2.rpmname, t1.reponame as repoid, t4.id as builid, t4.proj_id as prjid, t4.create_at from repos as t1 join rpms as t2 on t2.repo_id = t1.id join build_rpm as t3 on t3.rpm_id = t2.id join buildtask as t4 on t4.id = t3.build_id where t1.id = ? and t2.savepath not like '%.src.rpm' order by t4.create_at, t2.rpmname", git_id.to_i].all
|
$DDB["select t2.id as rpmid, t2.rpmname, t1.reponame as repoid, t4.id as builid, t4.proj_id as prjid, t4.create_at from repos as t1 join rpms as t2 on t2.repo_id = t1.id join build_rpm as t3 on t3.rpm_id = t2.id join buildtask as t4 on t4.id = t3.build_id where t1.id = ? and t2.savepath not like '%.src.rpm' order by t4.create_at, t2.rpmname", git_id.to_i].all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_rpm_info(rpm_id)
|
||||||
|
Rpms[rpm_id.to_i]
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_rpm_build(rpm_id)
|
||||||
|
bld_info = BuildRpms.where(rpm_id: rpm_id.to_i).first
|
||||||
|
if bld_info.nil?
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
bld_info[:build_id]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_rpm_srpms(rpm_id)
|
||||||
|
bld_info = BuildRpms.where(rpm_id: rpm_id.to_i).first
|
||||||
|
if bld_info.nil?
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
bld_info[:build_id]
|
||||||
|
result = BuildRpms.where(build_id: bld_info[:build_id].to_i)
|
||||||
|
if result.nil?
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
result.each do |item|
|
||||||
|
rpm_p = Rpms[item[:rpm_id].to_i]
|
||||||
|
unless rpm_p.nil?
|
||||||
|
if rpm_p[:savepath] =~ /\.src\.rpm$/
|
||||||
|
return rpm_p
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,6 +4,19 @@ require "rpm"
|
|||||||
|
|
||||||
require_relative "runner"
|
require_relative "runner"
|
||||||
|
|
||||||
|
class RPMReader
|
||||||
|
def get_rpm_info(path_to_rpm)
|
||||||
|
res = { :error => nil }
|
||||||
|
if File.exist?(path_to_rpm)
|
||||||
|
pkg = RPM::Package.open(path_to_rpm)
|
||||||
|
res[:pkginfo] = pkg
|
||||||
|
else
|
||||||
|
res[:error] = "#{path_to_rpm} не существует"
|
||||||
|
end
|
||||||
|
res
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class RepoManager
|
class RepoManager
|
||||||
attr :path, :error, :last_status, :last_pid
|
attr :path, :error, :last_status, :last_pid
|
||||||
|
|
||||||
@@ -13,6 +26,7 @@ class RepoManager
|
|||||||
Dir.mkdir(path)
|
Dir.mkdir(path)
|
||||||
end
|
end
|
||||||
@path = path
|
@path = path
|
||||||
|
@reader = RPMReader.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_repo
|
def create_repo
|
||||||
@@ -28,13 +42,6 @@ class RepoManager
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_rpm_info(path_to_rpm)
|
def get_rpm_info(path_to_rpm)
|
||||||
res = { :error => nil }
|
@reader.get_rpm_info(path_to_rpm)
|
||||||
if File.exist?(path_to_rpm)
|
|
||||||
pkg = RPM::Package.open(path_to_rpm)
|
|
||||||
res[:pkginfo] = pkg
|
|
||||||
else
|
|
||||||
res[:error] = "#{path_to_rpm} не существует"
|
|
||||||
end
|
|
||||||
res
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
116
views/rpminfo.erb
Normal file
116
views/rpminfo.erb
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
<%= erb :header %>
|
||||||
|
<div class="container">
|
||||||
|
<div>
|
||||||
|
<span class="fs-3 fw-medium"><%=@rpm_data[:rpmname] %></span>
|
||||||
|
<% unless @build_id.nil? %>
|
||||||
|
<a href="/buildinfof/<%= ERB::Util.url_encode(@build_id) %>"><i class="bi bi-box"></i></a>
|
||||||
|
<% end %>
|
||||||
|
<a href="/gitpackages/<%= ERB::Util.url_encode(@repo_id) %>"><i class="bi bi-git"></i></a>
|
||||||
|
</div>
|
||||||
|
<div class="accordion" id="rpmInfo">
|
||||||
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header">
|
||||||
|
<button class="accordion-button" type="button" data-bs-toggle="collapse"
|
||||||
|
data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
|
||||||
|
Информация о пакете
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div id="collapseOne" class="accordion-collapse collapse show" data-bs-parent="#rpmInfo">
|
||||||
|
<div class="accordion-body">
|
||||||
|
<table class="table">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Имя пакета</th>
|
||||||
|
<td><%= @pkg_info.name %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Версия</th>
|
||||||
|
<td><%= @pkg_info.version %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Архитектура</th>
|
||||||
|
<td><%= @pkg_info.arch %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">Исходный пакет</th>
|
||||||
|
<% if @rpms_info.nil? %>
|
||||||
|
<td>Не найден</td>
|
||||||
|
<% else %>
|
||||||
|
<td><a href="/rpminfo/<%= ERB::Util.url_encode(@rpms_info[:id]) %>"><%= @rpms_info[:rpmname] %>.src</a></td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header">
|
||||||
|
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
|
||||||
|
data-bs-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
|
||||||
|
ChangeLog
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div id="collapseTwo" class="accordion-collapse collapse" data-bs-parent="#rpmInfo">
|
||||||
|
<div class="accordion-body">
|
||||||
|
<div class="vstack gap-1">
|
||||||
|
<% @pkg_info.changelog.each do |entry| %>
|
||||||
|
<div class="p-1 text-warning-emphasis border">
|
||||||
|
<p><%= entry.time %> <%= entry.name %></p>
|
||||||
|
<p><%= entry.text %></p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header">
|
||||||
|
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
|
||||||
|
data-bs-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
|
||||||
|
Список файлов
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div id="collapseThree" class="accordion-collapse collapse" data-bs-parent="#rpmInfo">
|
||||||
|
<div class="accordion-body">
|
||||||
|
<div class="vstack gap-0">
|
||||||
|
<% @pkg_info.files.each do |file| %>
|
||||||
|
<div class="p-0 fw-light text-secondary"><%= file.path %> (<%= file.size %>)</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header">
|
||||||
|
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
|
||||||
|
data-bs-target="#collapseFour" aria-expanded="false" aria-controls="collapseThree">
|
||||||
|
Зависимости
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div id="collapseFour" class="accordion-collapse collapse" data-bs-parent="#rpmInfo">
|
||||||
|
<div class="accordion-body">
|
||||||
|
<div class="vstack gap-0">
|
||||||
|
<div class="p-2">Provides</div>
|
||||||
|
<% @pkg_info.provides.each do |item| %>
|
||||||
|
<div class="p-0 fw-light text-info-emphasis"><%= item.name %></div>
|
||||||
|
<% end %>
|
||||||
|
<div class="p-2">Requires</div>
|
||||||
|
<% @pkg_info.requires.each do |item| %>
|
||||||
|
<div class="p-0 fw-light text-info-emphasis"><%= item.name %></div>
|
||||||
|
<% end %>
|
||||||
|
<div class="p-2">Obsoletes</div>
|
||||||
|
<% @pkg_info.obsoletes.each do |item| %>
|
||||||
|
<div class="p-0 fw-light text-info-emphasis"><%= item.name %></div>
|
||||||
|
<% end %>
|
||||||
|
<div class="p-2">Conflists</div>
|
||||||
|
<% @pkg_info.conflicts.each do |item| %>
|
||||||
|
<div class="p-0 fw-light text-info-emphasis"><%= item.name %></div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%= erb :footer %>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<td scope="row"><%= item[:rpmname] %></td>
|
<td scope="row"><%= item[:rpmname] %></td>
|
||||||
<td><%= item[:create_at] %></td>
|
<td><%= item[:create_at] %></td>
|
||||||
<td class="text-center"><a href="/repos/<%= ERB::Util.url_encode(item[:repoid]) %>"><%= item[:repoid] %></a></td>
|
<td class="text-center"><a href="/repos/<%= ERB::Util.url_encode(item[:repoid]) %>"><%= item[:repoid] %></a></td>
|
||||||
<td class="text-center"><a href="/buildinfo/<%= ERB::Util.url_encode(item[:builid]) %>">build#<%= item[:builid] %></a></td>
|
<td class="text-center"><a href="/buildinfof/<%= ERB::Util.url_encode(item[:builid]) %>">build#<%= item[:builid] %></a></td>
|
||||||
<td class="text-center"><a href="/prjedit/<%= ERB::Util.url_encode(item[:prjid]) %>">Перейти к проекту</a></td>
|
<td class="text-center"><a href="/prjedit/<%= ERB::Util.url_encode(item[:prjid]) %>">Перейти к проекту</a></td>
|
||||||
<td class="text-center"><a href="/rpminfo/<%= ERB::Util.url_encode(item[:rpmid]) %>">Информация о пакете</a></td>
|
<td class="text-center"><a href="/rpminfo/<%= ERB::Util.url_encode(item[:rpmid]) %>">Информация о пакете</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -31,11 +31,15 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<nav aria-label="Навигация по доступным пакетам">
|
<nav aria-label="Навигация по доступным пакетам">
|
||||||
<ul class="pagination pagination-sm justify-content-center">
|
<ul class="pagination pagination-sm justify-content-center">
|
||||||
|
<% @max_pages.times.each do |item| %>
|
||||||
|
<% if (item+1) == @page %>
|
||||||
<li class="page-item active" aria-current="page">
|
<li class="page-item active" aria-current="page">
|
||||||
<span class="page-link">1</span>
|
<span class="page-link"><%= item+1 %></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
<% else %>
|
||||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
<li class="page-item"><a class="page-link" href="/gitpackages/<%= ERB::Util.url_encode(@git_id) %>/?p=<%= item+1 %>"><%= item+1 %></a></li>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user