Files
mock-gui/db/migrations/202503190000000_adddata.rb
2025-03-20 00:37:19 +03:00

40 lines
1.3 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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