diff --git a/app.rb b/app.rb index 74124a6..a6593aa 100644 --- a/app.rb +++ b/app.rb @@ -266,7 +266,8 @@ post "/rcpcreate" do session[:rcpcreate_error] = "Имя рецепта и описание не должны быть пустыми" redirect "/rcpcreate" else - @error_data = db.createrecip(params["filepath"], params["description"], params["codedata"], params["gitlst"]) + codedata = params["codedata"].gsub(/\r$/, "") + @error_data = db.createrecip(params["filepath"], params["description"], codedata, params["gitlst"]) unless @error_data.nil? session[:rcpcreate_error] = @error_data redirect "/rcpcreate" @@ -837,8 +838,6 @@ get "/gitpackages/:git_id" do @page = params["p"].to_i if @page < 1 @page = 1 - else - @page = @page + 1 end end if rpms_lst.nil? @@ -846,6 +845,9 @@ get "/gitpackages/:git_id" do end items_per_page = cfg.get_items_per_page @rpms_list = rpms_lst[(@page - 1) * items_per_page, items_per_page] + if @rpms_list.nil? + @rpms_list = [] + end @max_pages = rpms_lst.length / items_per_page if (@max_pages * items_per_page) != rpms_lst.length @max_pages = @max_pages + 1 @@ -886,8 +888,6 @@ get "/builds" do @page = params["p"].to_i if @page < 1 @page = 1 - else - @page = @page + 1 end end if builds_lst.nil? @@ -895,6 +895,9 @@ get "/builds" do end items_per_page = cfg.get_items_per_page @builds_list = builds_lst[(@page - 1) * items_per_page, items_per_page] + if @builds_list.nil? + @builds_list = [] + end @max_pages = builds_lst.length / items_per_page if (@max_pages * items_per_page) != builds_lst.length @max_pages = @max_pages + 1 @@ -968,8 +971,6 @@ get "/prjbuilds/:id" do @page = params["p"].to_i if @page < 1 @page = 1 - else - @page = @page + 1 end end if builds_lst.nil? @@ -977,6 +978,9 @@ get "/prjbuilds/:id" do end items_per_page = cfg.get_items_per_page @builds_list = builds_lst[(@page - 1) * items_per_page, items_per_page] + if @builds_list.nil? + @builds_list = [] + end @max_pages = builds_lst.length / items_per_page if (@max_pages * items_per_page) != builds_lst.length @max_pages = @max_pages + 1 @@ -1159,6 +1163,7 @@ get "/prjgitbld/:id/:git_id" do git_info = repo.get_repo_short_info_by_id(params["git_id"].to_i) @git_data = git_info @prj = prj_info + @git_id = params["git_id"] @page_name = "Список всех сборок для проекта #{prj_info[:projname]} и репозитория #{git_info[:reponame]}" builds_lst = db.get_builds_for_project_git(params["id"], params["git_id"]) if params["p"].nil? @@ -1167,8 +1172,6 @@ get "/prjgitbld/:id/:git_id" do @page = params["p"].to_i if @page < 1 @page = 1 - else - @page = @page + 1 end end if builds_lst.nil? @@ -1176,6 +1179,9 @@ get "/prjgitbld/:id/:git_id" do end items_per_page = cfg.get_items_per_page @builds_list = builds_lst[(@page - 1) * items_per_page, items_per_page] + if @builds_list.nil? + @builds_list = [] + end @max_pages = builds_lst.length / items_per_page if (@max_pages * items_per_page) != builds_lst.length @max_pages = @max_pages + 1 diff --git a/classes/db.rb b/classes/db.rb index a41fd38..cc6f5aa 100644 --- a/classes/db.rb +++ b/classes/db.rb @@ -263,11 +263,11 @@ class DBase end def get_gits_rpms() - $DDB["select t1.id, t1.reponame, count(*) as packages from repos as t1 join rpms as t2 on t2.repo_id = t1.id group by t1.id, t1.reponame order by t1.id"].all + $DDB["select t1.id, t1.reponame, count(*) as packages from repos as t1 join rpms as t2 on t2.repo_id = t1.id group by t1.id, t1.reponame order by t1.id desc"].all end 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.id desc, t2.rpmname", git_id.to_i].all end def get_rpm_info(rpm_id) @@ -307,7 +307,7 @@ class DBase end def get_builds() - $DDB["select t1.id as buildid, t1.create_at as createat, t1.result as state, t2.reponame as reponame, t2.id as gitid, t3.id as projid, t3.projname as prjname, count(*) as pkgcnt from buildtask as t1 join repos as t2 on t1.repo_id = t2.id join projects as t3 on t1.proj_id = t3.id left join build_rpm as t4 on t4.build_id = t1.id group by buildid, createat, state, reponame, projid, prjname, gitid order by t1.id"].all + $DDB["select t1.id as buildid, t1.create_at as createat, t1.result as state, t2.reponame as reponame, t2.id as gitid, t3.id as projid, t3.projname as prjname, count(*) as pkgcnt from buildtask as t1 join repos as t2 on t1.repo_id = t2.id join projects as t3 on t1.proj_id = t3.id left join build_rpm as t4 on t4.build_id = t1.id group by buildid, createat, state, reponame, projid, prjname, gitid order by t1.id desc"].all end def get_build_info(build_id) @@ -328,11 +328,11 @@ class DBase end def get_builds_for_project(prj_id) - $DDB["select t1.id as buildid, t1.create_at as createat, t1.result as state, t2.reponame as reponame, t2.id as gitid, t3.id as projid, t3.projname as prjname, count(*) as pkgcnt from buildtask as t1 join repos as t2 on t1.repo_id = t2.id join projects as t3 on t1.proj_id = t3.id left join build_rpm as t4 on t4.build_id = t1.id where t1.proj_id = ? group by buildid, createat, state, reponame, projid, prjname, gitid order by t1.id", prj_id.to_i].all + $DDB["select t1.id as buildid, t1.create_at as createat, t1.result as state, t2.reponame as reponame, t2.id as gitid, t3.id as projid, t3.projname as prjname, count(*) as pkgcnt from buildtask as t1 join repos as t2 on t1.repo_id = t2.id join projects as t3 on t1.proj_id = t3.id left join build_rpm as t4 on t4.build_id = t1.id where t1.proj_id = ? group by buildid, createat, state, reponame, projid, prjname, gitid order by t1.id desc", prj_id.to_i].all end def get_builds_for_project_git(prj_id, git_id) - $DDB["select t1.id as buildid, t1.create_at as createat, t1.result as state, t2.reponame as reponame, t2.id as gitid, t3.id as projid, t3.projname as prjname, count(*) as pkgcnt from buildtask as t1 join repos as t2 on t1.repo_id = t2.id join projects as t3 on t1.proj_id = t3.id left join build_rpm as t4 on t4.build_id = t1.id where t1.proj_id = ? and t1.repo_id = ? group by buildid, createat, state, reponame, projid, prjname, gitid order by t1.id", prj_id.to_i, git_id.to_i].all + $DDB["select t1.id as buildid, t1.create_at as createat, t1.result as state, t2.reponame as reponame, t2.id as gitid, t3.id as projid, t3.projname as prjname, count(*) as pkgcnt from buildtask as t1 join repos as t2 on t1.repo_id = t2.id join projects as t3 on t1.proj_id = t3.id left join build_rpm as t4 on t4.build_id = t1.id where t1.proj_id = ? and t1.repo_id = ? group by buildid, createat, state, reponame, projid, prjname, gitid order by t1.id desc", prj_id.to_i, git_id.to_i].all end def delete_git_from_project(prj_id, git_id) diff --git a/classes/mock.rb b/classes/mock.rb index eb375dc..a42c468 100644 --- a/classes/mock.rb +++ b/classes/mock.rb @@ -89,11 +89,12 @@ class MockManager @log.info("Формируем рецепт #{item[:filepath]}") rcp_name = "#{index}rcp_#{item[:filepath]}" File.open(File.join(@tmp_src, rcp_name), "w") do |f| - f.write(item[:content]) + f.write(item[:content].gsub(/\r$/, "")) end Dir.chdir(@tmp_src) do + spec_file = File.join(@tmp_src, @spec) script = File.join(@tmp_src, rcp_name) - cmd_args = %Q(/usr/bin/bash -x "#{script}") + cmd_args = %Q(/usr/bin/bash -x "#{script}" "#{spec_file}") @log.debug(cmd_args) cmd = Runner.new(cmd_args, @log) cmd.run_clean diff --git a/db/migrations/202503190000000_adddata.rb b/db/migrations/202503190000000_adddata.rb new file mode 100644 index 0000000..580e7b5 --- /dev/null +++ b/db/migrations/202503190000000_adddata.rb @@ -0,0 +1,39 @@ +require "sequel" + +Sequel.migration do + change do + script_content = <<~CODE + #!/bin/bash + + need_spec="n" + SPEC="$1" + FIND_SPEC="$SPEC" + if [ -z "$SPEC" ];then + need_spec="y" + fi + if [ -n "$SPEC" -a ! -e "$SPEC" ];then + need_spec="y" + fi + if [ "$need_spec" == "y" ];then + FIND_SPEC=$(/usr/bin/find . -iname "*.spec" -type f -print -quit) + fi + if [ -n "$FIND_SPEC" ];then + NAME=$(rpm -q --queryformat="%{NAME}\n" --specfile "$FIND_SPEC" | xargs) + VERSION=$(rpm -q --queryformat="%{VERSION}\n" --specfile "$FIND_SPEC" | xargs) + PKG_NAME="${NAME}-${VERSION}" + tar -h --exclude="${PKG_NAME}.tar.gz" --exclude=".git" --exclude="$FIND_SPEC" -cvf ${PKG_NAME}.tar.gz --transform "s,^,${PKG_NAME}/," * + exit 0 + else + echo "Не найден spec файл" + exit 255 + fi + CODE + + description = <<~CODE + Скрипт для создания архива из исходников в гите, на основании spec файла. + В репозитории должен быть один файл spec. Остальные будут игнорироваться. + CODE + + from(:recips).insert(content: script_content, filepath: "make_tar_from_git", descr: description) + end +end diff --git a/gen-scripts/install-key b/gen-scripts/install-key new file mode 100755 index 0000000..a1e504d --- /dev/null +++ b/gen-scripts/install-key @@ -0,0 +1,49 @@ +#!/bin/bash + +function usage(){ + echo "bash install-key UserName Email TimeToExpireInSecondsFromCurrentTime PhassPhrase" + exit 0 +} + +if [ -z "$1" -o -z "$2" -o -z "$3" -o -z "$4" ];then + usage +fi + +name="$1" +email="$2" +expdate="$3" +phassphrase="$4" + +cat >gen-key-script < "${pub_key_path}/mockgui-gpg-key" + +cat >~/.rpmmacros < +%_gpgbin /usr/bin/gpg +EOF + diff --git a/keys/readme b/keys/readme new file mode 100644 index 0000000..2f5fcec --- /dev/null +++ b/keys/readme @@ -0,0 +1 @@ +Каталог с ключами \ No newline at end of file diff --git a/views/buildslist.erb b/views/buildslist.erb index a84fd20..4305287 100644 --- a/views/buildslist.erb +++ b/views/buildslist.erb @@ -54,7 +54,7 @@ <%= item+1 %> <% else %> -
  • <%= item+1 %>
  • +
  • <%= item+1 %>
  • <% end %> <% end %> diff --git a/views/prjbuildslist.erb b/views/prjbuildslist.erb index 7f7f535..244efc5 100644 --- a/views/prjbuildslist.erb +++ b/views/prjbuildslist.erb @@ -55,7 +55,7 @@ <%= item+1 %> <% else %> -
  • <%= item+1 %>
  • +
  • <%= item+1 %>
  • <% end %> <% end %> diff --git a/views/prjbuildslistgit.erb b/views/prjbuildslistgit.erb index bc8868b..033c002 100644 --- a/views/prjbuildslistgit.erb +++ b/views/prjbuildslistgit.erb @@ -55,7 +55,7 @@ <%= item+1 %> <% else %> -
  • <%= item+1 %>
  • +
  • <%= item+1 %>
  • <% end %> <% end %> diff --git a/views/rcpedit.erb b/views/rcpedit.erb index 7a2e480..52f913e 100644 --- a/views/rcpedit.erb +++ b/views/rcpedit.erb @@ -27,7 +27,7 @@
    - +
    diff --git a/views/rpmlistgit.erb b/views/rpmlistgit.erb index a8c09a9..512efb1 100644 --- a/views/rpmlistgit.erb +++ b/views/rpmlistgit.erb @@ -37,7 +37,7 @@ <%= item+1 %> <% else %> -
  • <%= item+1 %>
  • +
  • <%= item+1 %>
  • <% end %> <% end %>