You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mock-gui/db/migrations/202503190000000_adddata.rb

40 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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