mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
jw-pkg: Add command compile-templates
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
4c54a52c66
commit
246246573f
1 changed files with 63 additions and 22 deletions
|
|
@ -20,19 +20,20 @@ cat << EOT
|
|||
|
||||
command is one of
|
||||
|
||||
help: show this help screen
|
||||
init: initialize
|
||||
uninit: undo initialization
|
||||
install: install packages in [arguments]
|
||||
update: update all jannet software on the system
|
||||
restore: restore a previous jannet software version state
|
||||
info: query information about installed software packages
|
||||
info-projects: query information about installed software projects
|
||||
checklog: update the installation log file if necessary
|
||||
rpmnew: remove superfluous rpmnew files and show conflicts
|
||||
for others
|
||||
build-date: show installed jannet packages along with build date
|
||||
built-today: show installed jannet packages that were built today
|
||||
help: show this help screen
|
||||
init: initialize
|
||||
uninit: undo initialization
|
||||
install: install packages in [arguments]
|
||||
update: update all jannet software on the system
|
||||
restore: restore a previous jannet software version state
|
||||
info: query information about installed software packages
|
||||
info-projects: query information about installed software projects
|
||||
checklog: update the installation log file if necessary
|
||||
rpmnew: remove superfluous rpmnew files and show conflicts
|
||||
for others
|
||||
build-date: show installed jannet packages along with build date
|
||||
built-today: show installed jannet packages that were built today
|
||||
compile-templates: compile templates
|
||||
|
||||
global options are
|
||||
|
||||
|
|
@ -90,7 +91,7 @@ list_packages()
|
|||
{
|
||||
local names="$1"
|
||||
local rpm_args
|
||||
if [ "$names" ]; then
|
||||
if [ -n "$names" ]; then
|
||||
rpm_args="$rpm_args $names"
|
||||
else
|
||||
rpm_args="$rpm_args -a"
|
||||
|
|
@ -103,7 +104,7 @@ list_packages()
|
|||
|
||||
list_projects()
|
||||
{
|
||||
list_packages "$@" | xargs rpm -qa --queryformat '%{SOURCERPM}: %{URL}\n' | \
|
||||
list_packages "$@" | xargs -r rpm -q --queryformat '%{SOURCERPM}: %{URL}\n' | \
|
||||
sed 's/\(^[^ ]\+\) *:.*/\1/; s/[ ]*$//; s/-[0-9]\+.*//' |\
|
||||
sort -u
|
||||
}
|
||||
|
|
@ -113,7 +114,7 @@ cmd_rpmnew()
|
|||
local file
|
||||
|
||||
list_packages "$@" |
|
||||
xargs rpm -ql |
|
||||
xargs -r rpm -ql |
|
||||
while read file; do
|
||||
if [ -e "$file.rpmnew" ]; then
|
||||
if diff -q $file $file.rpmnew; then
|
||||
|
|
@ -137,7 +138,7 @@ cmd_diff()
|
|||
local file
|
||||
|
||||
list_packages "$@" |
|
||||
xargs rpm -qV |
|
||||
xargs -r rpm -qV |
|
||||
sed '/^....L\|^..5/ !d; s%[^/]*/%/%' |
|
||||
while read file; do
|
||||
if diff -q $file $file.rpmnew; then
|
||||
|
|
@ -158,7 +159,7 @@ cmd_diff()
|
|||
cmd_build_date()
|
||||
{
|
||||
list_packages "$@" |
|
||||
xargs rpm -q --queryformat '%{BUILDTIME} %{NAME}\n' |
|
||||
xargs -r rpm -q --queryformat '%{BUILDTIME} %{NAME}\n' |
|
||||
sort -n |
|
||||
sed 's/-run\|-devel//' |
|
||||
sort -u |
|
||||
|
|
@ -167,6 +168,45 @@ cmd_build_date()
|
|||
done
|
||||
}
|
||||
|
||||
cmd_compile_templates()
|
||||
{
|
||||
local ext_from=".jw-tmpl"
|
||||
local ext_to=""
|
||||
local ext_tables=".jw-secret .jw-vars"
|
||||
local group=root
|
||||
local owner=root
|
||||
local mode=600
|
||||
local ext_from_re=`echo $ext_from | sed 's/\./\\./g'`
|
||||
|
||||
# TODO: allow target file attributes to be specified in options
|
||||
umask 0077
|
||||
|
||||
local f
|
||||
list_packages "$@" | xargs -r rpm -ql | while read f; do
|
||||
echo searching $ext_from_re in $f
|
||||
echo $f | grep -q "$ext_from_re$" || continue
|
||||
local base=`echo $f | sed "s/$ext_from_re$//"`
|
||||
local to=$base$ext_to
|
||||
local table="" ext
|
||||
for ext in $ext_tables; do
|
||||
table=$base$ext
|
||||
[ -f "$table" ] && break
|
||||
done
|
||||
[ -f $table ] || {
|
||||
echo "WARNING: No key-value table found for template $f, not compiling." >&2
|
||||
continue
|
||||
}
|
||||
# TODO: use mktemp -d and keep temporary files in read-only dir
|
||||
local tmp=$to.tmp
|
||||
echo "Applying macros in $table to $f."
|
||||
sed 's|\([^ ]\+\) \(.*\)|s/\1/\2/g|' $table | sed -f - $f > $tmp
|
||||
chmod $mode $tmp
|
||||
chown $owner $tmp
|
||||
chgrp $owner $tmp
|
||||
mv $tmp $to
|
||||
done
|
||||
}
|
||||
|
||||
cmd_built_today()
|
||||
{
|
||||
local today=`date +'%Y-%m-%d'`
|
||||
|
|
@ -222,9 +262,9 @@ checklog)
|
|||
;;
|
||||
info)
|
||||
if [ "$opt_verbose" = true ]; then
|
||||
list_packages "$@" | xargs rpm -qi
|
||||
list_packages "$@" | xargs -r rpm -qi
|
||||
else
|
||||
list_packages "$@" | xargs rpm -q
|
||||
list_packages "$@" | xargs -r rpm -q
|
||||
fi
|
||||
;;
|
||||
info-projects)
|
||||
|
|
@ -238,6 +278,9 @@ cpp-glib)
|
|||
rpmnew)
|
||||
cmd_rpmnew "$@"
|
||||
;;
|
||||
compile-templates)
|
||||
cmd_compile_templates "$@"
|
||||
;;
|
||||
diff)
|
||||
cmd_diff "$@"
|
||||
;;
|
||||
|
|
@ -255,5 +298,3 @@ help)
|
|||
;;
|
||||
|
||||
esac
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue