Kaydet (Commit) 4e685a78 authored tarafından Your Name's avatar Your Name

inary-template options improvement

üst dec64a4a
#!/bin/bash
set -e
#define constants
available_build_types=(autotools cmaketools mesontools qt)
inf_msg(){
......@@ -10,7 +11,8 @@ err_msg(){
echo " General Options:"
echo " -o output directory (default: package name)"
echo " -n package name (required)"
echo " -x build package after create [true/false] (default false)"
echo " -x build package after create"
echo " -y do not ask anything"
echo " -h write help message"
echo " Actions options:"
echo " -t build type (default: autotools)"
......@@ -28,6 +30,7 @@ err_msg(){
echo " -b build dependencies list"
echo " -a package source archive list (required)"
echo " -q rfp status [true/false] (default true)"
echo " -qq rfp description"
echo " Package section:"
echo " -r runtime dependencies list"
echo " -v package verison"
......@@ -36,6 +39,7 @@ err_msg(){
#default variables
name=""
directory=""
homepage="https://gitlab.com/sulinos/devel/inary"
buildtype="autotools"
packager="Your Name"
......@@ -44,6 +48,7 @@ license="GPLv3"
isa=""
summary="Package summary missing"
description="Package description missing"
rfpdescription="This is a rfp package"
src=""
bdeps=""
rdeps=""
......@@ -51,8 +56,9 @@ ver="1.0.0"
rfp=true
bnow=false
confopt=""
forceyes=""
#opt parse
while getopts -- ':o:n:x:t:c:p:u:e:l:i:s:d:b:a:r:v:q:' OPTION; do
while getopts -- ':o:n:t:c:p:u:e:l:i:s:d:b:a:r:v:q:qq:' OPTION; do
case "$OPTION" in
o)
directory="${OPTARG[@]}"
......@@ -61,13 +67,6 @@ while getopts -- ':o:n:x:t:c:p:u:e:l:i:s:d:b:a:r:v:q:' OPTION; do
n)
name="${OPTARG[@]}"
;;
x)
bnow="${OPTARG[@]}"
if [ "$bnow" != "true" ] && [ "$bnow" != "false" ]; then
echo "Error: Invalid status: $bnow"
err_msg
fi
;;
t)
buildtype="${OPTARG[@]}"
a=0
......@@ -136,9 +135,24 @@ while getopts -- ':o:n:x:t:c:p:u:e:l:i:s:d:b:a:r:v:q:' OPTION; do
err_msg
fi
;;
qq)
rfpdescription="${OPTARGS[@]}"
;;
?)
inf_msg
err_msg
for arg in ${OPTARG[@]} ; do
case "$arg" in
y)
forceyes="-y"
;;
x)
bnow="true"
;;
*)
inf_msg
err_msg
;;
esac
done
;;
esac
done
......@@ -156,6 +170,10 @@ if [ "$src" == "" ] ; then
err_msg
fi
info(){
echo -e "\033[32;1m$1\033[;0m: $2"
}
write_pspec(){
echo "<?xml version=\"1.0\" ?>"
echo "<!DOCTYPE INARY SYSTEM \"https://gitlab.com/sulinos/sulinproject/inary/raw/master/inary-spec.dtd\">"
......@@ -163,7 +181,9 @@ echo "<INARY>"
echo " <Source>"
echo " <Name>$name</Name>"
if [ "$rfp" != "false" ] ; then
echo " <Rfp>$name is a rfp package</Rfp>"
echo " <Rfp>$rfpdescription</Rfp>"
else
echo " <!--Rfp>$rfpdescription</Rfp-->"
fi
echo " <Homepage>$homepage</Homepage>"
echo " <Packager>"
......@@ -177,10 +197,15 @@ done
echo " <Summary>$summary</Summary>"
echo " <Description>$description</Description>"
for i in $src ; do
out=$(mktemp)
wget -c $i -O $out
echo " <Archive sha1sum=\"$(sha1sum $out | sed 's/ .*//g')\">$i</Archive>"
rm -f $out
if [ "$bnow" == "true" ] ; then
# TODO: Download with inary support needed.
out=$(mktemp)
wget -c $i -O $out || true
echo " <Archive sha1sum=\"$(sha1sum $out | sed 's/ .*//g')\">$i</Archive>"
rm -f $out
else
echo " <Archive sha1sum=\"FIXME\">$i</Archive>"
fi
done
echo " <BuildDependencies>"
for i in $bdeps ; do
......@@ -279,13 +304,37 @@ def install():
EOF
}
mkdir -p $(pwd)/$name
echo "Creating pspec.xml to $(pwd)/$name/pspec.xml"
write_pspec > $(pwd)/$name/pspec.xml
echo "Creating actions.py to $(pwd)/$name/actions.py"
write_actions > $(pwd)/$name/actions.py
# Write info after creating
info "Package name" "$name"
info "Output directory" "$(realpath $directory)"
info "Package version" "$version"
info "Homepage" "$homepage"
info "Packager" "$packager"
info "Email" "$email"
info "License" "$license"
info "Summary" "$summary"
info "Description" "$description"
info "Build type" "$buildtype"
if [ "$forceyes" == "" ] ; then
echo ""
info ">>>" "Are informations correct? [y/N]"
read -s -n 1 c
if ! [ "$c" == "y" ] || [ "$c" == ""Y ] ; then
echo " Operation canceled."
exit
fi
fi
directory=$(realpath $directory)
mkdir -p $directory
info "Creating" "pspec.xml to $directory/pspec.xml"
write_pspec > $directory/pspec.xml
info "Creating" "actions.py to $directory/actions.py"
write_actions > $directory/actions.py
if [ "$bnow" == "true" ] ; then
cd $(pwd)/$name
inary bi --verbose --debug
cd $directory
exec inary bi --verbose --debug $forceyes
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment