Compare commits
No commits in common. "c10s" and "c8" have entirely different histories.
49
.gitignore
vendored
49
.gitignore
vendored
@ -1,48 +1 @@
|
||||
/yelp-tools-3.1.4.tar.xz
|
||||
/yelp-tools-3.1.5.tar.xz
|
||||
/yelp-tools-3.1.6.tar.xz
|
||||
/yelp-tools-3.1.7.tar.xz
|
||||
/yelp-tools-3.2.0.tar.xz
|
||||
/yelp-tools-3.2.1.tar.xz
|
||||
/yelp-tools-3.3.1.tar.xz
|
||||
/yelp-tools-3.3.2.tar.xz
|
||||
/yelp-tools-3.3.3.tar.xz
|
||||
/yelp-tools-3.3.4.tar.xz
|
||||
/yelp-tools-3.4.0.tar.xz
|
||||
/yelp-tools-3.4.1.tar.xz
|
||||
/yelp-tools-3.5.91.tar.xz
|
||||
/yelp-tools-3.5.92.tar.xz
|
||||
/yelp-tools-3.6.0.tar.xz
|
||||
/yelp-tools-3.6.1.tar.xz
|
||||
/yelp-tools-3.9.1.tar.xz
|
||||
/yelp-tools-3.9.90.tar.xz
|
||||
/yelp-tools-3.10.0.tar.xz
|
||||
/yelp-tools-3.11.1.tar.xz
|
||||
/yelp-tools-3.11.2.tar.xz
|
||||
/yelp-tools-3.11.3.tar.xz
|
||||
/yelp-tools-3.11.5.tar.xz
|
||||
/yelp-tools-3.12.0.tar.xz
|
||||
/yelp-tools-3.12.1.tar.xz
|
||||
/yelp-tools-3.13.3.tar.xz
|
||||
/yelp-tools-3.14.0.tar.xz
|
||||
/yelp-tools-3.14.1.tar.xz
|
||||
/yelp-tools-3.16.1.tar.xz
|
||||
/yelp-tools-3.17.3.tar.xz
|
||||
/yelp-tools-3.17.4.tar.xz
|
||||
/yelp-tools-3.18.0.tar.xz
|
||||
/yelp-tools-3.27.90.tar.xz
|
||||
/yelp-tools-3.28.0.tar.xz
|
||||
/yelp-tools-3.31.90.tar.xz
|
||||
/yelp-tools-3.32.0.tar.xz
|
||||
/yelp-tools-3.32.1.tar.xz
|
||||
/yelp-tools-3.32.2.tar.xz
|
||||
/yelp-tools-3.37.90.tar.xz
|
||||
/yelp-tools-3.38.0.tar.xz
|
||||
/yelp-tools-40.beta.tar.xz
|
||||
/yelp-tools-40.rc.tar.xz
|
||||
/yelp-tools-40.0.tar.xz
|
||||
/yelp-tools-41.beta.tar.xz
|
||||
/yelp-tools-41.0.tar.xz
|
||||
/yelp-tools-42.beta.tar.xz
|
||||
/yelp-tools-42.0.tar.xz
|
||||
/yelp-tools-42.1.tar.xz
|
||||
SOURCES/yelp-tools-3.28.0.tar.xz
|
||||
|
1
.yelp-tools.metadata
Normal file
1
.yelp-tools.metadata
Normal file
@ -0,0 +1 @@
|
||||
bd0cb2599c63d488ec1f62d0ad848bf2f93dd728 SOURCES/yelp-tools-3.28.0.tar.xz
|
877
SOURCES/covscan.patch
Normal file
877
SOURCES/covscan.patch
Normal file
@ -0,0 +1,877 @@
|
||||
diff --git a/tools/yelp-build.in b/tools/yelp-build.in
|
||||
index 898325b..0397410 100755
|
||||
--- a/tools/yelp-build.in
|
||||
+++ b/tools/yelp-build.in
|
||||
@@ -32,7 +32,7 @@ xsl_mal_files='@DATADIR@/xslt/mal-files.xsl'
|
||||
|
||||
mkdir_p () {
|
||||
if [ ! -d "$1" ]; then
|
||||
- mkdir_p `dirname "$1"`
|
||||
+ mkdir_p "$(dirname "$1")"
|
||||
mkdir "$1"
|
||||
fi
|
||||
}
|
||||
@@ -154,7 +154,7 @@ yelp_paths_normalize () {
|
||||
|
||||
yelp_cache_in_page () {
|
||||
fbase=$(basename "$1")
|
||||
- fdir=$( (cd $(dirname "$1") && pwd) )
|
||||
+ fdir=$( (cd "$(dirname "$1")" && pwd) )
|
||||
sdir=${fdir##${cache_site_root}}/
|
||||
url=file://$(echo "$fdir/$fbase" | urlencode)
|
||||
if [ "x$cache_site" = "x1" ]; then
|
||||
@@ -166,7 +166,7 @@ yelp_cache_in_page () {
|
||||
yelp_cache_in_site () {
|
||||
for dir in "$1"/*; do
|
||||
if [ -d "$dir" ]; then
|
||||
- if [ $(basename "$dir") != "__pintail__" ]; then
|
||||
+ if [ "$(basename "$dir")" != "__pintail__" ]; then
|
||||
yelp_cache_in_site "$dir"
|
||||
fi
|
||||
fi
|
||||
@@ -219,7 +219,7 @@ yelp_cache () {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] ||[ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_cache
|
||||
exit 1
|
||||
fi
|
||||
@@ -237,10 +237,10 @@ yelp_html_xsl_common () {
|
||||
echo '<xsl:variable name="yelp.internal.datadir" select="'"''"'"/>'
|
||||
fi
|
||||
if [ "x$html_internal_xsl" != "x" ]; then
|
||||
- echo '<xsl:include href="file://'`echo "$html_internal_xsl" | urlencode`'"/>'
|
||||
+ echo '<xsl:include href="file://'"$(echo "$html_internal_xsl" | urlencode)"'"/>'
|
||||
fi
|
||||
if [ "x$html_custom" != "x" ]; then
|
||||
- echo '<xsl:include href="file://'`echo "$html_custom" | urlencode`'"/>'
|
||||
+ echo '<xsl:include href="file://'"$(echo "$html_custom" | urlencode)"'"/>'
|
||||
fi
|
||||
echo '<xsl:template name="html.css">'
|
||||
echo ' <xsl:param name="node" select="."/>'
|
||||
@@ -281,8 +281,8 @@ yelp_html_xsl_common () {
|
||||
}
|
||||
yelp_html_db2html () {
|
||||
for xml in "$@"; do
|
||||
- xmldir=`dirname "$xml"`
|
||||
- xmldir=`(cd "$xmldir" && pwd)`
|
||||
+ xmldir=$(dirname "$xml")
|
||||
+ xmldir=$( (cd "$xmldir" && pwd))
|
||||
# Output HTML
|
||||
(
|
||||
echo '<xsl:stylesheet'
|
||||
@@ -292,9 +292,9 @@ yelp_html_db2html () {
|
||||
echo ' extension-element-prefixes="exsl"'
|
||||
echo ' version="1.0">'
|
||||
if [ "x$is_xhtml" = "x1" ]; then
|
||||
- xsl='file://'`echo "$xsl_db2xhtml" | urlencode`
|
||||
+ xsl='file://'$(echo "$xsl_db2xhtml" | urlencode)
|
||||
else
|
||||
- xsl='file://'`echo "$xsl_db2html" | urlencode`
|
||||
+ xsl='file://'$(echo "$xsl_db2html" | urlencode)
|
||||
fi
|
||||
echo '<xsl:import href="'"$xsl"'"/>'
|
||||
yelp_html_xsl_common
|
||||
@@ -317,12 +317,12 @@ yelp_html_db2html () {
|
||||
echo ' </xsl:for-each>'
|
||||
echo '</xsl:template>'
|
||||
echo '</xsl:stylesheet>'
|
||||
- ) | xsltproc --path "$html_paths" --xinclude - "$xml" | while read media; do
|
||||
- mfile=`echo "$media" | urldecode`
|
||||
+ ) | xsltproc --path "$html_paths" --xinclude - "$xml" | while read -r media; do
|
||||
+ mfile=$(echo "$media" | urldecode)
|
||||
minput="$xmldir/$mfile"
|
||||
moutput="$html_out/$mfile"
|
||||
- mkdir_p `dirname "$moutput"`
|
||||
- if [ ! -f "$minput" -a "x$html_paths" != "x" ]; then
|
||||
+ mkdir_p "$(dirname "$moutput")"
|
||||
+ if [ ! -f "$minput" ] && [ "x$html_paths" != "x" ]; then
|
||||
minput_rel=${minput#"$(pwd)/"}
|
||||
if [ "x$minput_rel" != "x$minput_src" ]; then
|
||||
for path in $html_paths; do
|
||||
@@ -333,7 +333,7 @@ yelp_html_db2html () {
|
||||
done
|
||||
fi
|
||||
fi
|
||||
- if [ -f "$minput" -o "x$html_ignore_media" != "x1" ]; then
|
||||
+ if [ -f "$minput" ] || [ "x$html_ignore_media" != "x1" ]; then
|
||||
cp "$minput" "$moutput"
|
||||
fi
|
||||
done
|
||||
@@ -345,13 +345,13 @@ yelp_html_db2html () {
|
||||
|
||||
yelp_html_mal2html () {
|
||||
if [ "x$html_cache_file" != "x" ]; then
|
||||
- html_cache_file=`(cd $(dirname "$html_cache_file") && pwd)`/`basename "$html_cache_file"`
|
||||
+ html_cache_file=$( (cd "$(dirname "$html_cache_file")" && pwd))/$(basename "$html_cache_file")
|
||||
else
|
||||
html_cache_file_is_tmp="yes"
|
||||
- html_cache_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
|
||||
+ html_cache_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
|
||||
yelp_cache -o "$html_cache_file" "$@"
|
||||
fi
|
||||
- html_tmp_infile=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
|
||||
+ html_tmp_infile=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
|
||||
yelp_cache_in "$@" > "$html_tmp_infile"
|
||||
# Output HTML
|
||||
(
|
||||
@@ -365,15 +365,15 @@ yelp_html_mal2html () {
|
||||
echo ' extension-element-prefixes="exsl"'
|
||||
echo ' version="1.0">'
|
||||
if [ "x$is_xhtml" = "x1" ]; then
|
||||
- xsl='file://'`echo "$xsl_mal2xhtml" | urlencode`
|
||||
+ xsl='file://'$(echo "$xsl_mal2xhtml" | urlencode)
|
||||
else
|
||||
- xsl='file://'`echo "$xsl_mal2html" | urlencode`
|
||||
+ xsl='file://'$(echo "$xsl_mal2html" | urlencode)
|
||||
fi
|
||||
echo '<xsl:import href="'"$xsl"'"/>'
|
||||
echo '<xsl:include href="'"$xsl_mal_files"'"/>'
|
||||
echo '<xsl:output method="text"/>'
|
||||
yelp_html_xsl_common
|
||||
- html_cache_url='file://'`echo "$html_cache_file" | urlencode`
|
||||
+ html_cache_url='file://'$(echo "$html_cache_file" | urlencode)
|
||||
echo '<xsl:param name="mal.cache.file" select="'"'$html_cache_url'"'"/>'
|
||||
echo '<xsl:template match="/">'
|
||||
echo '<xsl:for-each select="cache:cache/mal:page">'
|
||||
@@ -387,14 +387,14 @@ yelp_html_mal2html () {
|
||||
echo '</xsl:for-each>'
|
||||
echo '</xsl:template>'
|
||||
echo '</xsl:stylesheet>'
|
||||
- ) | (cd "$html_out" && xsltproc $html_profile \
|
||||
+ ) | (cd "$html_out" && xsltproc "$html_profile" \
|
||||
--path "$html_paths" --xinclude \
|
||||
- "$html_tmp_infile") | sort | uniq | \
|
||||
- while read line; do
|
||||
+ while read -r line; do
|
||||
# Copy media from paths output by HTML transform
|
||||
line_src=$(echo "$line" | cut -d' ' -f1 | urldecode)
|
||||
line_dest="$html_out/"$(echo "$line" | cut -d' ' -f2)
|
||||
- if [ ! -f "$line_src" -a "x$html_paths" != "x" ]; then
|
||||
+ if [ ! -f "$line_src" ] && [ "x$html_paths" != "x" ]; then
|
||||
line_src_rel=${line_src#"$(pwd)/"}
|
||||
if [ "x$line_src_rel" != "x$line_src" ]; then
|
||||
for path in $html_paths; do
|
||||
@@ -405,11 +405,11 @@ yelp_html_mal2html () {
|
||||
done
|
||||
fi
|
||||
fi
|
||||
- line_dest=`echo "$line_dest" | urldecode`
|
||||
+ line_dest=$(echo "$line_dest" | urldecode)
|
||||
if [ "$line_src" != "$line_dest" ]; then
|
||||
- line_dir=`dirname "$line_dest"`
|
||||
+ line_dir=$(dirname "$line_dest")
|
||||
mkdir_p "$line_dir"
|
||||
- if [ -f "$line_src" -o "x$html_ignore_media" != "x1" ]; then
|
||||
+ if [ -f "$line_src" ] || [ "x$html_ignore_media" != "x1" ]; then
|
||||
cp "$line_src" "$line_dest"
|
||||
fi
|
||||
fi
|
||||
@@ -465,18 +465,18 @@ yelp_html () {
|
||||
echo "Error: output must be a directory." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
- html_out=`(cd "$html_out" && pwd)`
|
||||
+ html_out=$( (cd "$html_out" && pwd))
|
||||
if [ "x$html_custom" != "x" ]; then
|
||||
- html_custom_dir=`dirname "$html_custom"`
|
||||
- html_custom_dir=`(cd "$html_custom_dir" && pwd)`
|
||||
- html_custom="$html_custom_dir"/`basename "$html_custom"`
|
||||
+ html_custom_dir=$(dirname "$html_custom")
|
||||
+ html_custom_dir=$( (cd "$html_custom_dir" && pwd))
|
||||
+ html_custom="$html_custom_dir"/$(basename "$html_custom")
|
||||
fi
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_html
|
||||
exit 1
|
||||
fi
|
||||
- ext=`echo "$1" | sed -e 's/.*\.//'`
|
||||
- if [ "x$ext" = "xxml" -o "x$ext" = "xdocbook" ]; then
|
||||
+ ext=$(echo "$1" | sed -e 's/.*\.//')
|
||||
+ if [ "x$ext" = "xxml" ] || [ "x$ext" = "xdocbook" ]; then
|
||||
yelp_html_db2html "$@"
|
||||
else
|
||||
yelp_html_mal2html "$@"
|
||||
@@ -515,19 +515,19 @@ yelp_epub () {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_epub
|
||||
exit 1
|
||||
fi
|
||||
if [ "x$epub_cache_file" != "x" ]; then
|
||||
- epub_cache_file=`(cd $(dirname "$epub_cache_file") && pwd)`/`basename "$epub_cache_file"`
|
||||
+ epub_cache_file=$( (cd "$(dirname "$epub_cache_file")" && pwd))/$(basename "$epub_cache_file")
|
||||
else
|
||||
epub_cache_file_is_tmp="yes"
|
||||
- epub_cache_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
|
||||
+ epub_cache_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
|
||||
yelp_cache -o "$epub_cache_file" "$@"
|
||||
fi
|
||||
html_cache_file="$epub_cache_file"
|
||||
- epub_data_out=`mktemp -d "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
|
||||
+ epub_data_out=$(mktemp -d "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
|
||||
html_out="$epub_data_out/OPS"
|
||||
mkdir "$html_out"
|
||||
mkdir "$html_out/yelp"
|
||||
@@ -535,8 +535,8 @@ yelp_epub () {
|
||||
html_internal_xsl="$xsl_mal_epub"
|
||||
yelp_html_mal2html "$@"
|
||||
|
||||
- epub_id=`uuidgen`
|
||||
- epub_data=`(cd "$html_out" && ls yelp/*.*)`
|
||||
+ epub_id=$(uuidgen)
|
||||
+ epub_data=$( (cd "$html_out" && ls yelp/*.*))
|
||||
xsltproc \
|
||||
--path "$html_paths" \
|
||||
-o "$html_out/opf.opf" \
|
||||
@@ -562,9 +562,9 @@ yelp_epub () {
|
||||
) > "$epub_data_out/META-INF/container.xml"
|
||||
|
||||
if [ "x$epub_out" = "x" ]; then
|
||||
- epub_out=`pwd`/index.epub
|
||||
+ epub_out=$(pwd)/index.epub
|
||||
else
|
||||
- epub_out=`(cd $(dirname "$epub_out") && pwd)`/`basename "$epub_out"`
|
||||
+ epub_out=$( (cd "$(dirname "$epub_out")" && pwd))/$(basename "$epub_out")
|
||||
fi
|
||||
(cd "$epub_data_out" && zip -q -r "$epub_out" mimetype META-INF OPS)
|
||||
|
||||
diff --git a/tools/yelp-check.in b/tools/yelp-check.in
|
||||
index 526679d..6b1a595 100755
|
||||
--- a/tools/yelp-check.in
|
||||
+++ b/tools/yelp-check.in
|
||||
@@ -282,7 +282,7 @@ fi
|
||||
yelp_check_iter_site () {
|
||||
for dir in "$1"/*; do
|
||||
if [ -d "$dir" ]; then
|
||||
- if [ $(basename "$dir") != "__pintail__" ]; then
|
||||
+ if [ "$(basename "$dir")" != "__pintail__" ]; then
|
||||
yelp_check_iter_site "$dir"
|
||||
fi
|
||||
fi
|
||||
@@ -307,9 +307,9 @@ yelp_check_iter_args () {
|
||||
fi
|
||||
done
|
||||
fi
|
||||
- elif [ "x$ext" = "xpage" -o "x$ext" = "xstub" -o "x$ext" = "xcache" ]; then
|
||||
+ elif [ "x$ext" = "xpage" ] || [ "x$ext" = "xstub" ] || [ "x$ext" = "xcache" ]; then
|
||||
$check_page "$arg" || yelp_check_retval="$?"
|
||||
- elif [ "x$check_db" != "x" -a \( "x$ext" = "xdocbook" -o "x$ext" = "xxml" \) ]; then
|
||||
+ elif [ "x$check_db" != "x" ] && ([ "x$ext" = "xdocbook" ] || [ "x$ext" = "xxml" ]); then
|
||||
$check_db "$arg" || yelp_check_retval="$?"
|
||||
else
|
||||
echo "Unrecognized page $arg" 1>&2
|
||||
@@ -322,7 +322,7 @@ yelp_check_iter_args () {
|
||||
yelp_hrefs_page () {
|
||||
base=$(dirname "$1")
|
||||
if [ "x$check_site" = "x1" ]; then
|
||||
- sdir=$(cd $(dirname "$1") && pwd)
|
||||
+ sdir=$(cd "$(dirname "$1")" && pwd)
|
||||
sdir=${sdir##${check_site_root}}/
|
||||
fi
|
||||
(
|
||||
@@ -355,23 +355,23 @@ yelp_hrefs_page () {
|
||||
echo '</xsl:template>'
|
||||
echo '</xsl:stylesheet>'
|
||||
) | xsltproc --xinclude - "$1" | sort | uniq | \
|
||||
- while read id url; do
|
||||
- colon=`echo "$url" | cut -d: -f1`
|
||||
+ while read -r id url; do
|
||||
+ colon=$(echo "$url" | cut -d: -f1)
|
||||
if [ "x$colon" = "x$url" ]; then
|
||||
- test -f "$base/"$(urldecode "$url") || echo "$sdir$id: $url"
|
||||
+ test -f "$base/""$(urldecode "$url")" || echo "$sdir$id: $url"
|
||||
else
|
||||
- status=$(cat "$check_href_cache" | while read trystatus tryurl; do
|
||||
+ status=$(while read -r trystatus tryurl; do
|
||||
if [ "x$tryurl" = "x$url" ]; then echo "$trystatus"; break; fi
|
||||
- done)
|
||||
+ done < "$check_href_cache")
|
||||
if [ "x$status" = "x1" ]; then
|
||||
true
|
||||
elif [ "x$status" = "x0" ]; then
|
||||
echo "$sdir$id: $url"
|
||||
else
|
||||
- (curl -s -I -L "$url" | \
|
||||
+ ( (curl -s -I -L "$url" | \
|
||||
grep '^HTTP/' | tail -n 1 | head -n 1 | \
|
||||
grep -q 'HTTP/.\.. 200 .*') \
|
||||
- && (echo "1 $url" >> "$check_href_cache") \
|
||||
+ && (echo "1 $url" >> "$check_href_cache")) \
|
||||
|| (echo "0 $url" >> "$check_href_cache"; echo "$sdir$id: $url")
|
||||
fi
|
||||
fi
|
||||
@@ -379,7 +379,7 @@ yelp_hrefs_page () {
|
||||
}
|
||||
|
||||
yelp_hrefs () {
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_hrefs
|
||||
exit 1
|
||||
fi
|
||||
@@ -395,12 +395,12 @@ yelp_hrefs () {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_hrefs
|
||||
exit 1
|
||||
fi
|
||||
- check_out_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
|
||||
- check_href_cache=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
|
||||
+ check_out_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
|
||||
+ check_href_cache=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
|
||||
echo > "$check_href_cache"
|
||||
check_db=yelp_hrefs_page
|
||||
check_page=yelp_hrefs_page
|
||||
@@ -432,9 +432,9 @@ yelp_ids_page () {
|
||||
bname=$(basename "$1")
|
||||
if [ "x$pageid.page" != "x$bname" ]; then
|
||||
if [ "x$check_site" = "x1" ]; then
|
||||
- sdir=$(cd $(dirname "$1") && pwd)
|
||||
+ sdir=$(cd "$(dirname "$1")" && pwd)
|
||||
sdir=${sdir##${check_site_root}}/
|
||||
- echo $sdir$(basename "$1")": $pageid"
|
||||
+ echo "$sdir$(basename "$1"): $pageid"
|
||||
elif [ "x$dname" = 'x.' ]; then
|
||||
echo "$bname: $pageid"
|
||||
else
|
||||
@@ -445,7 +445,7 @@ yelp_ids_page () {
|
||||
}
|
||||
|
||||
yelp_ids () {
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_ids
|
||||
exit 1
|
||||
fi
|
||||
@@ -461,7 +461,7 @@ yelp_ids () {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_ids
|
||||
exit 1
|
||||
fi
|
||||
@@ -497,7 +497,7 @@ yelp_links_db () {
|
||||
|
||||
yelp_links_page () {
|
||||
if [ "x$check_site" = "x1" ]; then
|
||||
- sdir=$(cd $(dirname "$1") && pwd)
|
||||
+ sdir=$(cd "$(dirname "$1")" && pwd)
|
||||
sdir=${sdir##${check_site_root}}/
|
||||
fi
|
||||
(
|
||||
@@ -508,9 +508,9 @@ yelp_links_page () {
|
||||
echo ' xmlns:exsl="http://exslt.org/common"'
|
||||
echo ' extension-element-prefixes="exsl"'
|
||||
echo ' version="1.0">'
|
||||
- xsl='file://'`urlencode "$xsl_mal_link"`
|
||||
+ xsl='file://'$(urlencode "$xsl_mal_link")
|
||||
echo '<xsl:import href="'"$xsl"'"/>'
|
||||
- check_cache_url='file://'`urlencode "$check_cache_file"`
|
||||
+ check_cache_url='file://'$(urlencode "$check_cache_file")
|
||||
echo '<xsl:param name="mal.cache.file" select="'"'$check_cache_url'"'"/>'
|
||||
echo '<xsl:variable name="site.dir" select="'"'$sdir'"'"/>'
|
||||
echo '<xsl:output method="text"/>'
|
||||
@@ -544,7 +544,7 @@ yelp_links_page () {
|
||||
}
|
||||
|
||||
yelp_links () {
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_links
|
||||
exit 1
|
||||
fi
|
||||
@@ -569,7 +569,7 @@ yelp_links () {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_links
|
||||
exit 1
|
||||
fi
|
||||
@@ -585,7 +585,7 @@ yelp_links () {
|
||||
check_cache_file=1
|
||||
;;
|
||||
*)
|
||||
- break
|
||||
+ return
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
@@ -599,7 +599,7 @@ yelp_links () {
|
||||
fi
|
||||
fi
|
||||
|
||||
- check_out_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
|
||||
+ check_out_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
|
||||
check_db=yelp_links_db
|
||||
check_page=yelp_links_page
|
||||
yelp_check_iter_args "$@" > "$check_out_file"
|
||||
@@ -632,7 +632,7 @@ yelp_media_page () {
|
||||
fi
|
||||
xsltproc "$xsl_media" "$1" | \
|
||||
sort | uniq | \
|
||||
- while read line; do
|
||||
+ while read -r line; do
|
||||
src=$(urldecode "$line")
|
||||
if [ ! -f "$dname$src" ]; then
|
||||
echo "$sdir$bname: $line"
|
||||
@@ -641,7 +641,7 @@ yelp_media_page () {
|
||||
}
|
||||
|
||||
yelp_media () {
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_media
|
||||
exit 1
|
||||
fi
|
||||
@@ -657,11 +657,11 @@ yelp_media () {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_media
|
||||
exit 1
|
||||
fi
|
||||
- check_out_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
|
||||
+ check_out_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
|
||||
check_db=yelp_media_page
|
||||
check_page=yelp_media_page
|
||||
yelp_check_iter_args "$@" > "$check_out_file"
|
||||
@@ -676,7 +676,7 @@ yelp_media () {
|
||||
|
||||
yelp_orphans_page () {
|
||||
if [ "x$check_site" = "x1" ]; then
|
||||
- sdir=$(cd $(dirname "$1") && pwd)
|
||||
+ sdir=$(cd "$(dirname "$1")" && pwd)
|
||||
sdir=${sdir##${check_site_root}}/
|
||||
fi
|
||||
(
|
||||
@@ -686,9 +686,9 @@ yelp_orphans_page () {
|
||||
echo ' xmlns:exsl="http://exslt.org/common"'
|
||||
echo ' extension-element-prefixes="exsl"'
|
||||
echo ' version="1.0">'
|
||||
- xsl='file://'`urlencode "$xsl_mal_link"`
|
||||
+ xsl='file://'$(urlencode "$xsl_mal_link")
|
||||
echo '<xsl:import href="'"$xsl"'"/>'
|
||||
- check_cache_url='file://'`urlencode "$check_cache_file"`
|
||||
+ check_cache_url='file://'$(urlencode "$check_cache_file")
|
||||
echo '<xsl:param name="mal.cache.file" select="'"'$check_cache_url'"'"/>'
|
||||
echo '<xsl:variable name="site.dir" select="'"'$sdir'"'"/>'
|
||||
echo '<xsl:output method="text"/>'
|
||||
@@ -707,7 +707,7 @@ yelp_orphans_page () {
|
||||
}
|
||||
|
||||
yelp_orphans () {
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_orphans
|
||||
exit 1
|
||||
fi
|
||||
@@ -728,7 +728,7 @@ yelp_orphans () {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_orphans
|
||||
exit 1
|
||||
fi
|
||||
@@ -744,7 +744,7 @@ yelp_orphans () {
|
||||
check_cache_file=1
|
||||
;;
|
||||
*)
|
||||
- break
|
||||
+ return
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
@@ -758,7 +758,7 @@ yelp_orphans () {
|
||||
fi
|
||||
fi
|
||||
|
||||
- check_out_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
|
||||
+ check_out_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
|
||||
check_db=
|
||||
check_page=yelp_orphans_page
|
||||
yelp_check_iter_args "$@" > "$check_out_file"
|
||||
@@ -778,7 +778,7 @@ yelp_comments_page () {
|
||||
ext=$(echo "$1" | sed -e 's/.*\.//')
|
||||
bname=$(basename "$1" ".$ext")
|
||||
if [ "x$check_site" = "x1" ]; then
|
||||
- sdir=$(cd $(dirname "$1") && pwd)
|
||||
+ sdir=$(cd "$(dirname "$1")" && pwd)
|
||||
sdir=${sdir##${check_site_root}}/
|
||||
fi
|
||||
xsltproc --stringparam basename "$bname" \
|
||||
@@ -787,7 +787,7 @@ yelp_comments_page () {
|
||||
}
|
||||
|
||||
yelp_comments () {
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_comments
|
||||
exit 1
|
||||
fi
|
||||
@@ -803,7 +803,7 @@ yelp_comments () {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_comments
|
||||
exit 1
|
||||
fi
|
||||
@@ -815,7 +815,7 @@ yelp_comments () {
|
||||
|
||||
yelp_license_page () {
|
||||
if [ "x$check_site" = "x1" ]; then
|
||||
- sdir=$(cd $(dirname "$1") && pwd)
|
||||
+ sdir=$(cd "$(dirname "$1")" && pwd)
|
||||
sdir=${sdir##${check_site_root}}/
|
||||
fi
|
||||
xsltproc --xinclude \
|
||||
@@ -827,7 +827,7 @@ yelp_license_page () {
|
||||
}
|
||||
|
||||
yelp_license () {
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_license
|
||||
exit 1
|
||||
fi
|
||||
@@ -857,7 +857,7 @@ yelp_license () {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_license
|
||||
exit 1
|
||||
fi
|
||||
@@ -875,7 +875,7 @@ yelp_style_page () {
|
||||
ext=$(echo "$1" | sed -e 's/.*\.//')
|
||||
bname=$(basename "$1" ".$ext")
|
||||
if [ "x$check_site" = "x1" ]; then
|
||||
- sdir=$(cd $(dirname "$1") && pwd)
|
||||
+ sdir=$(cd "$(dirname "$1")" && pwd)
|
||||
sdir=${sdir##${check_site_root}}/
|
||||
fi
|
||||
style=$(echo "$mallard_style" | xsltproc - "$1")
|
||||
@@ -886,7 +886,7 @@ yelp_style_page () {
|
||||
# We treat an empty --only '' as requesting pages with no style
|
||||
if [ "x$style" = "x" ]; then output=1; fi
|
||||
else
|
||||
- for pstyle in "$style"; do
|
||||
+ for pstyle in $style; do
|
||||
for sstyle in $(echo "$check_only" | sed -e 's/,/ /g'); do
|
||||
if [ "$pstyle" = "$sstyle" ]; then
|
||||
output=1
|
||||
@@ -902,7 +902,7 @@ yelp_style_page () {
|
||||
# We treat an empty --except '' as excluding pages with no style
|
||||
if [ "x$style" = "x" ]; then output=0; fi
|
||||
else
|
||||
- for pstyle in "$style"; do
|
||||
+ for pstyle in $style; do
|
||||
for sstyle in $(echo "$check_except" | sed -e 's/,/ /g'); do
|
||||
if [ "$pstyle" = "$sstyle" ]; then
|
||||
output=0
|
||||
@@ -919,7 +919,7 @@ yelp_style_page () {
|
||||
}
|
||||
|
||||
yelp_style () {
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_style
|
||||
exit 1
|
||||
fi
|
||||
@@ -951,7 +951,7 @@ yelp_style () {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_style
|
||||
exit 1
|
||||
fi
|
||||
@@ -959,7 +959,7 @@ yelp_style () {
|
||||
check_page=yelp_style_page
|
||||
if [ "x$check_totals" = "x1" ]; then
|
||||
yelp_check_iter_args "$@" | \
|
||||
- while read line; do
|
||||
+ while read -r line; do
|
||||
styles=$(echo "$line" | sed -e 's/^[^:]*://')
|
||||
if [ "x$styles" = "x" ]; then
|
||||
echo ""
|
||||
@@ -976,7 +976,7 @@ yelp_style () {
|
||||
}
|
||||
|
||||
yelp_status () {
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_status
|
||||
exit 1
|
||||
fi
|
||||
@@ -1031,11 +1031,11 @@ yelp_status () {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_status
|
||||
exit 1
|
||||
fi
|
||||
- check_cache_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
|
||||
+ check_cache_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
|
||||
if [ "x$check_site" = "x1" ]; then
|
||||
yelp-build cache -s -o "$check_cache_file" "$@"
|
||||
else
|
||||
@@ -1059,7 +1059,7 @@ yelp_validate_db () {
|
||||
version=$(echo "$docbook_version" | xsltproc - "$1")
|
||||
major=$(echo "$version" | cut -c1)
|
||||
if [ "x$major" = "x5" ]; then
|
||||
- check_out_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
|
||||
+ check_out_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
|
||||
rng_uri="http://docbook.org/xml/$version/rng/docbook.rng"
|
||||
if [ "x$check_jing" = "x1" ]; then
|
||||
jing -i "$rng_uri" "$1" > "$check_out_file" 2>&1
|
||||
@@ -1067,7 +1067,7 @@ yelp_validate_db () {
|
||||
xmllint --noout --xinclude --noent --relaxng "$rng_uri" "$1" > "$check_out_file" 2>&1
|
||||
fi
|
||||
yelp_check_retval="$?"
|
||||
- cat "$check_out_file" | grep -v 'validates$'
|
||||
+ grep -v 'validates$' "$check_out_file"
|
||||
rm "$check_out_file"
|
||||
elif xmllint --nocdata "$1" | grep -q '<!DOCTYPE'; then
|
||||
xmllint --noout --xinclude --noent --postvalid "$1" || yelp_check_retval="$?"
|
||||
@@ -1081,10 +1081,10 @@ yelp_validate_page () {
|
||||
# Using temp files because pipes create subshells, making it really
|
||||
# hard to return the right exit status in a portable way.
|
||||
if [ "x$check_rng_dir" = "x" ]; then
|
||||
- check_rng_dir=`mktemp -d "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
|
||||
+ check_rng_dir=$(mktemp -d "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
|
||||
fi
|
||||
- check_out_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
|
||||
- check_rng_file=`(
|
||||
+ check_out_file=$(mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX)
|
||||
+ check_rng_file=$( (
|
||||
echo '<xsl:stylesheet'
|
||||
echo ' xmlns:cache="http://projectmallard.org/cache/1.0/"'
|
||||
echo ' xmlns:xsl="http://www.w3.org/1999/XSL/Transform"'
|
||||
@@ -1104,15 +1104,15 @@ yelp_validate_page () {
|
||||
echo '</xsl:choose>'
|
||||
echo '</xsl:template>'
|
||||
echo '</xsl:stylesheet>'
|
||||
- ) | xsltproc - "$1"`
|
||||
- check_rng_file=`urlencode "$check_rng_file" /`.rng
|
||||
+ ) | xsltproc - "$1")
|
||||
+ check_rng_file=$(urlencode "$check_rng_file" /).rng
|
||||
if [ ! -f "$check_rng_dir/$check_rng_file" ]; then
|
||||
# If we've already made an RNG file for this version string, don't
|
||||
# do it again. We've urlencoded the file name + slashes, because
|
||||
# version strings often contain slashes. But xsltproc treats the
|
||||
# -o option as a URL and urldecodes, so doubly urlencode, because
|
||||
# we want the urlencoded string to be the on-disk name.
|
||||
- xsltproc -o "$check_rng_dir/"`urlencode "$check_rng_file"` \
|
||||
+ xsltproc -o "$check_rng_dir/""$(urlencode "$check_rng_file")" \
|
||||
--param rng.strict "$check_strict" \
|
||||
--stringparam rng.strict.allow "$check_strict_allow" \
|
||||
"$xsl_mal_rng" "$1"
|
||||
@@ -1123,13 +1123,13 @@ yelp_validate_page () {
|
||||
xmllint --noout --xinclude --noent --relaxng "$check_rng_dir/$check_rng_file" "$1" > "$check_out_file" 2>&1
|
||||
fi
|
||||
ret="$?"
|
||||
- cat "$check_out_file" | grep -v 'validates$'
|
||||
+ grep -v 'validates$' "$check_out_file"
|
||||
rm "$check_out_file"
|
||||
return $ret;
|
||||
}
|
||||
|
||||
yelp_validate () {
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_validate
|
||||
exit 1
|
||||
fi
|
||||
@@ -1160,7 +1160,7 @@ yelp_validate () {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
- if [ "$#" = "0" -o "x$1" = "x--help" -o "x$1" = "x-h" ]; then
|
||||
+ if [ "$#" = "0" ] || [ "x$1" = "x--help" ] || [ "x$1" = "x-h" ]; then
|
||||
yelp_usage_validate
|
||||
exit 1
|
||||
fi
|
||||
diff --git a/tools/yelp-new.in b/tools/yelp-new.in
|
||||
index 76bd101..522c3a2 100755
|
||||
--- a/tools/yelp-new.in
|
||||
+++ b/tools/yelp-new.in
|
||||
@@ -19,8 +19,8 @@
|
||||
tmpldir="@YELP_TMPL_DIR@"
|
||||
|
||||
yelp_describe_tmpl () {
|
||||
- line=" "`basename "$1" | sed -e 's/\.'$2'$//'`
|
||||
- desc=`cat "$f" | grep '<\?yelp-tmpl-desc' | sed -e 's/<?yelp-tmpl-desc //' -e 's/?>$//'`
|
||||
+ line=" "$(basename "$1" | sed -e 's/\.'"$2"'$//')
|
||||
+ desc=$(grep '<\?yelp-tmpl-desc' "$f" | sed -e 's/<?yelp-tmpl-desc //' -e 's/?>$//')
|
||||
if [ "x$desc" != "x" ]; then
|
||||
line="$line - $desc"
|
||||
fi
|
||||
@@ -37,34 +37,50 @@ yelp_usage() {
|
||||
echo "Options:"
|
||||
echo " --stub Create a .page.stub file instead of a .page file"
|
||||
echo " --tmpl Copy an installed template to a local template"
|
||||
- if [ -f *.page.tmpl ]; then
|
||||
- echo ""
|
||||
- echo "Local Mallard Templates:"
|
||||
- for f in *.page.tmpl; do
|
||||
+ wroteheader=0
|
||||
+ for f in *.page.tmpl; do
|
||||
+ if [ -e "$f" ]; then
|
||||
+ if [ $wroteheader = 0 ]; then
|
||||
+ echo ""
|
||||
+ echo "Local Mallard Templates:"
|
||||
+ wroteheader=1
|
||||
+ fi
|
||||
yelp_describe_tmpl "$f" "page.tmpl"
|
||||
- done
|
||||
- fi
|
||||
- if [ -f ${tmpldir}*.page ]; then
|
||||
- echo ""
|
||||
- echo "Mallard Templates:"
|
||||
- for f in ${tmpldir}*.page; do
|
||||
+ fi
|
||||
+ done
|
||||
+ wroteheader=0
|
||||
+ for f in ${tmpldir}*.page; do
|
||||
+ if [ -e "$f" ]; then
|
||||
+ if [ $wroteheader = 0 ]; then
|
||||
+ echo ""
|
||||
+ echo "Mallard Templates:"
|
||||
+ wroteheader=1
|
||||
+ fi
|
||||
yelp_describe_tmpl "$f" "page"
|
||||
- done
|
||||
- fi
|
||||
- if [ -f *.docbook.tmpl ]; then
|
||||
- echo ""
|
||||
- echo "Local DocBook Templates:"
|
||||
- for f in *.docbook.tmpl; do
|
||||
+ fi
|
||||
+ done
|
||||
+ wroteheader=0
|
||||
+ for f in *.docbook.tmpl; do
|
||||
+ if [ -e "$f" ]; then
|
||||
+ if [ $wroteheader = 0 ]; then
|
||||
+ echo ""
|
||||
+ echo "Local DocBook Templates:"
|
||||
+ wroteheader=1
|
||||
+ fi
|
||||
yelp_describe_tmpl "$f" "xml.tmpl"
|
||||
- done
|
||||
- fi
|
||||
- if [ -f ${tmpldir}*.docbook ]; then
|
||||
- echo ""
|
||||
- echo "DocBook Templates:"
|
||||
- for f in ${tmpldir}*.docbook; do
|
||||
+ fi
|
||||
+ done
|
||||
+ wroteheader=0
|
||||
+ for f in ${tmpldir}*.docbook; do
|
||||
+ if [ -e "$f" ]; then
|
||||
+ if [ $wroteheader = 0 ]; then
|
||||
+ echo ""
|
||||
+ echo "DocBook Templates:"
|
||||
+ wroteheader=1
|
||||
+ fi
|
||||
yelp_describe_tmpl "$f" "xml"
|
||||
- done
|
||||
- fi
|
||||
+ fi
|
||||
+ done
|
||||
}
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
@@ -91,9 +107,9 @@ while [ $# -gt 0 ]; do
|
||||
done
|
||||
|
||||
# Locate the template file
|
||||
-if [ $(yelp_get_extension ${1}) = "tmpl" -a -f "${1}" ]; then
|
||||
+if [ "$(yelp_get_extension "${1}")" = "tmpl" ] && [ -f "${1}" ]; then
|
||||
infile="${1}"
|
||||
- outext="."$(yelp_get_extension $(basename "${1}" ".tmpl"))
|
||||
+ outext="."$(yelp_get_extension "$(basename "${1}" ".tmpl")")
|
||||
elif [ -f "${1}.page.tmpl" ]; then
|
||||
infile="${1}.page.tmpl"
|
||||
outext=".page"
|
||||
@@ -112,17 +128,17 @@ else
|
||||
fi
|
||||
|
||||
# Set up some variables for substitution
|
||||
-if type git >/dev/null 2>&1; then
|
||||
- username=`git config user.name`
|
||||
- useremail=`git config user.email`
|
||||
+if command -v git >/dev/null 2>&1; then
|
||||
+ username=$(git config user.name)
|
||||
+ useremail=$(git config user.email)
|
||||
fi
|
||||
-if [ "x$username" = "x" -a "x$useremail" = "x" ]; then
|
||||
- if type bzr >/dev/null 2>&1; then
|
||||
- username=`bzr whoami | sed -e 's/ <.*//'`
|
||||
- useremail=`bzr whoami --email`
|
||||
+if [ "x$username" = "x" ] && [ "x$useremail" = "x" ]; then
|
||||
+ if command -v bzr >/dev/null 2>&1; then
|
||||
+ username=$(bzr whoami | sed -e 's/ <.*//')
|
||||
+ useremail=$(bzr whoami --email)
|
||||
fi
|
||||
fi
|
||||
-if [ "x$username" = "x" -a "x$useremail" = "x" ]; then
|
||||
+if [ "x$username" = "x" ] && [ "x$useremail" = "x" ]; then
|
||||
username='YOUR NAME'
|
||||
useremail='YOUR EMAIL ADDRESS'
|
||||
fi
|
||||
@@ -134,14 +150,14 @@ fi
|
||||
outid=$(basename "${2}")
|
||||
|
||||
if [ "x$spec" != "x" ]; then
|
||||
- if [ "."$(yelp_get_extension "${2}") = "$spec" ]; then
|
||||
+ if [ ".""$(yelp_get_extension "${2}")" = "$spec" ]; then
|
||||
outfile="${2}"
|
||||
- elif [ "."$(yelp_get_extension "${2}") = "$outext" ]; then
|
||||
+ elif [ ".""$(yelp_get_extension "${2}")" = "$outext" ]; then
|
||||
outfile="${2}${spec}"
|
||||
else
|
||||
outfile="${2}${outext}${spec}"
|
||||
fi
|
||||
-elif [ "."$(yelp_get_extension ${2}) = "$outext" ]; then
|
||||
+elif [ ".""$(yelp_get_extension "${2}")" = "$outext" ]; then
|
||||
outfile="${2}"
|
||||
else
|
||||
outfile="${2}${outext}"
|
||||
@@ -150,10 +166,10 @@ fi
|
||||
if [ "x$spec" = "x.tmpl" ]; then
|
||||
cp "$infile" "$outfile"
|
||||
else
|
||||
- cat "$infile" | grep -v '<\?yelp-tmpl-desc' | sed \
|
||||
+ grep -v '<\?yelp-tmpl-desc' "$infile" | sed \
|
||||
-e s/@ID@/"$outid"/ \
|
||||
- -e s/@DATE@/`date +%Y-%m-%d`/ \
|
||||
- -e s/@YEAR@/`date +%Y`/ \
|
||||
+ -e s/@DATE@/"$(date +%Y-%m-%d)"/ \
|
||||
+ -e s/@YEAR@/"$(date +%Y)"/ \
|
||||
-e s/@NAME@/"$username"/ \
|
||||
-e s/@EMAIL@/"$useremail"/ \
|
||||
-e s/@TITLE@/"$pagetitle"/ \
|
@ -1,31 +1,24 @@
|
||||
%global tarball_version %%(echo %{version} | tr '~' '.')
|
||||
|
||||
%bcond url_handler 0%{?rhel}
|
||||
|
||||
Name: yelp-tools
|
||||
Version: 42.1
|
||||
Release: 8%{?dist}
|
||||
Version: 3.28.0
|
||||
Release: 3%{?dist}
|
||||
Summary: Create, manage, and publish documentation for Yelp
|
||||
|
||||
License: GPL-2.0-or-later
|
||||
Group: Applications/Publishing
|
||||
License: GPLv2+
|
||||
URL: https://wiki.gnome.org/Apps/Yelp/Tools
|
||||
Source0: https://download.gnome.org/sources/%{name}/42/%{name}-%{tarball_version}.tar.xz
|
||||
Source0: https://download.gnome.org/sources/%{name}/3.28/%{name}-%{version}.tar.xz
|
||||
BuildArch: noarch
|
||||
|
||||
# https://gitlab.gnome.org/GNOME/yelp-tools/-/merge_requests/12
|
||||
Patch: url-handler.patch
|
||||
# https://gitlab.gnome.org/GNOME/yelp-tools/merge_requests/1
|
||||
Patch0: covscan.patch
|
||||
|
||||
BuildRequires: meson
|
||||
BuildRequires: pkgconfig(yelp-xsl)
|
||||
BuildRequires: python3-lxml
|
||||
BuildRequires: itstool
|
||||
BuildRequires: libxslt
|
||||
|
||||
Requires: /usr/bin/itstool
|
||||
Requires: /usr/bin/xmllint
|
||||
Requires: /usr/bin/xsltproc
|
||||
Requires: mallard-rng
|
||||
Requires: python3-lxml
|
||||
Requires: yelp-xsl
|
||||
|
||||
%description
|
||||
@ -35,133 +28,33 @@ lifting is done by packages like yelp-xsl and itstool. This package just
|
||||
wraps things up in a developer-friendly way.
|
||||
|
||||
%prep
|
||||
%autosetup -p1 -n %{name}-%{tarball_version}
|
||||
%setup -q
|
||||
%patch0 -p1 -b .covscan
|
||||
|
||||
%build
|
||||
%meson \
|
||||
%if %{with url_handler}
|
||||
-Durl_handler=enabled \
|
||||
%endif
|
||||
%{nil}
|
||||
%meson_build
|
||||
%configure
|
||||
make %{?_smp_mflags}
|
||||
|
||||
%install
|
||||
%meson_install
|
||||
%make_install
|
||||
|
||||
%files
|
||||
%doc AUTHORS README.md NEWS
|
||||
%doc AUTHORS README
|
||||
%license COPYING COPYING.GPL
|
||||
%{_bindir}/yelp-build
|
||||
%if %{with url_handler}
|
||||
%{_bindir}/yelp-build-url-handler
|
||||
%endif
|
||||
%{_bindir}/yelp-check
|
||||
%{_bindir}/yelp-new
|
||||
%if %{with url_handler}
|
||||
%{_datadir}/applications/yelp-build-url-handler.desktop
|
||||
%endif
|
||||
%{_datadir}/yelp-tools
|
||||
%{_datadir}/aclocal/yelp.m4
|
||||
|
||||
%changelog
|
||||
* Mon Jan 27 2025 Michael Catanzaro <mcatanzaro@redhat.com> - 42.1-8
|
||||
- Add URL handler to open help files in web browser
|
||||
Resolves: RHEL-76398
|
||||
* Fri Oct 12 2018 Tomas Popela <tpopela@redhat.com> - 3.28.0-3
|
||||
- Apply the covscan patch
|
||||
- Resolves: rhbz#1637940
|
||||
|
||||
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 42.1-7
|
||||
- Bump release for October 2024 mass rebuild:
|
||||
Resolves: RHEL-64018
|
||||
|
||||
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 42.1-6
|
||||
- Bump release for June 2024 mass rebuild
|
||||
|
||||
* Mon Feb 12 2024 Tomas Popela <tpopela@redhat.com> - 42.1-5
|
||||
- Build for the SPDX license format change
|
||||
|
||||
* Sat Jan 27 2024 Fedora Release Engineering <releng@fedoraproject.org> - 42.1-4
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
|
||||
|
||||
* Sat Jul 22 2023 Fedora Release Engineering <releng@fedoraproject.org> - 42.1-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
|
||||
|
||||
* Sat Jan 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 42.1-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
|
||||
|
||||
* Mon Oct 31 2022 David King <amigadave@amigadave.com> - 42.1-1
|
||||
- Update to 42.1
|
||||
|
||||
* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 42.0-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
|
||||
|
||||
* Sat Mar 19 2022 David King <amigadave@amigadave.com> - 42.0-1
|
||||
- Update to 42.0
|
||||
|
||||
* Mon Feb 14 2022 David King <amigadave@amigadave.com> - 42~beta-1
|
||||
- Update to 42.beta
|
||||
|
||||
* Sat Jan 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 41.0-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
|
||||
|
||||
* Sat Sep 18 2021 Kalev Lember <klember@redhat.com> - 41.0-1
|
||||
- Update to 41.0
|
||||
|
||||
* Thu Aug 19 2021 Kalev Lember <klember@redhat.com> - 41~beta-1
|
||||
- Update to 41.beta
|
||||
|
||||
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 40.0-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
|
||||
|
||||
* Mon Mar 22 2021 Kalev Lember <klember@redhat.com> - 40.0-1
|
||||
- Update to 40.0
|
||||
|
||||
* Mon Mar 15 2021 Kalev Lember <klember@redhat.com> - 40~rc-1
|
||||
- Update to 40.rc
|
||||
|
||||
* Tue Feb 23 2021 David King <amigadave@amigadave.com> - 40~beta-2
|
||||
- Add Requires on python3-lxml (#1932011)
|
||||
|
||||
* Thu Feb 18 2021 Kalev Lember <klember@redhat.com> - 40~beta-1
|
||||
- Update to 40.beta
|
||||
- Switch to meson build system
|
||||
|
||||
* Thu Jan 28 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.38.0-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||
|
||||
* Sat Sep 12 2020 Kalev Lember <klember@redhat.com> - 3.38.0-1
|
||||
- Update to 3.38.0
|
||||
|
||||
* Mon Aug 17 2020 Kalev Lember <klember@redhat.com> - 3.37.90-1
|
||||
- Update to 3.37.90
|
||||
|
||||
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.32.2-5
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
|
||||
|
||||
* Fri Jan 31 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.32.2-4
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||
|
||||
* Sat Jul 27 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.32.2-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||
|
||||
* Sat Jul 20 2019 David King <amigadave@amigadave.com> - 3.32.2-2
|
||||
- Add xsltproc to Requires
|
||||
|
||||
* Wed Jun 12 2019 Kalev Lember <klember@redhat.com> - 3.32.2-1
|
||||
- Update to 3.32.2
|
||||
|
||||
* Tue May 07 2019 Kalev Lember <klember@redhat.com> - 3.32.1-1
|
||||
- Update to 3.32.1
|
||||
|
||||
* Mon Mar 11 2019 Kalev Lember <klember@redhat.com> - 3.32.0-1
|
||||
- Update to 3.32.0
|
||||
|
||||
* Mon Feb 04 2019 David King <amigadave@amigadave.com> - 3.31.90-1
|
||||
- Update to 3.31.90
|
||||
|
||||
* Sun Feb 03 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.28.0-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
|
||||
|
||||
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.28.0-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||
* Fri Oct 12 2018 Tomas Popela <tpopela@redhat.com> - 3.28.0-2
|
||||
- Fix the Coverity Scan issues
|
||||
- Resolves: rhbz#1637940
|
||||
|
||||
* Mon Mar 12 2018 Kalev Lember <klember@redhat.com> - 3.28.0-1
|
||||
- Update to 3.28.0
|
@ -1,6 +0,0 @@
|
||||
--- !Policy
|
||||
product_versions:
|
||||
- rhel-10
|
||||
decision_context: osci_compose_gate
|
||||
rules:
|
||||
- !PassingTestCaseRule {test_case_name: desktop-qe.desktop-ci.tier1-gating.functional}
|
1
sources
1
sources
@ -1 +0,0 @@
|
||||
SHA512 (yelp-tools-42.1.tar.xz) = e05a61d18179a9816ec38d1a2335091a3846cf74bb1ecec5374c9a13cc8962d14416208e04eec92f4ee43ec90e1992cc4a263bc4c267caac5d154a15f10d3006
|
@ -1,304 +0,0 @@
|
||||
From 66d2d8d8239f781f20f913dbe388b52e14f8dffb Mon Sep 17 00:00:00 2001
|
||||
From: Ray Strode <rstrode@redhat.com>
|
||||
Date: Thu, 18 May 2023 11:28:37 -0400
|
||||
Subject: [PATCH] tools: Add a url handler that generates html from
|
||||
documentation
|
||||
|
||||
Some systems don't install yelp by default but still want to show
|
||||
documentation.
|
||||
|
||||
This commit adds a small url handler to automatically convert
|
||||
documentation to html format and then launch a web browser to show
|
||||
it.
|
||||
---
|
||||
meson_options.txt | 4 +
|
||||
tools/meson.build | 24 +++
|
||||
tools/yelp-build-url-handler.desktop.in | 6 +
|
||||
tools/yelp-build-url-handler.in | 212 ++++++++++++++++++++++++
|
||||
4 files changed, 246 insertions(+)
|
||||
create mode 100644 tools/yelp-build-url-handler.desktop.in
|
||||
create mode 100755 tools/yelp-build-url-handler.in
|
||||
|
||||
diff --git a/meson_options.txt b/meson_options.txt
|
||||
index 0526e6f..03e9050 100644
|
||||
--- a/meson_options.txt
|
||||
+++ b/meson_options.txt
|
||||
@@ -5,3 +5,7 @@ option('yelpm4',
|
||||
option('help',
|
||||
type: 'boolean', value: false,
|
||||
description: 'Install help files')
|
||||
+
|
||||
+option('url_handler',
|
||||
+ type: 'feature', value: 'disabled',
|
||||
+ description: 'Install URL handler to open help in web browesr, use when not building Yelp')
|
||||
diff --git a/tools/meson.build b/tools/meson.build
|
||||
index 35187ca..b2518d6 100644
|
||||
--- a/tools/meson.build
|
||||
+++ b/tools/meson.build
|
||||
@@ -1,5 +1,10 @@
|
||||
yelp_tools_in = configuration_data()
|
||||
yelp_tools_in.set('DATADIR', pkgdir)
|
||||
+yelp_tools_in.set('HELPDIR', join_paths (
|
||||
+ datadir,
|
||||
+ 'help',
|
||||
+ )
|
||||
+)
|
||||
|
||||
yelp_tools_in.set('YELP_JS_DIR', yelp_js_dir)
|
||||
|
||||
@@ -48,3 +53,22 @@ if get_option('yelpm4') == true
|
||||
)
|
||||
)
|
||||
endif
|
||||
+
|
||||
+if get_option('url_handler').enabled()
|
||||
+ configure_file(
|
||||
+ input: 'yelp-build-url-handler.in',
|
||||
+ output: 'yelp-build-url-handler',
|
||||
+ configuration: yelp_tools_in,
|
||||
+ install: true,
|
||||
+ install_dir: bindir,
|
||||
+ )
|
||||
+
|
||||
+ configure_file(
|
||||
+ input: 'yelp-build-url-handler.desktop.in',
|
||||
+ output: '@BASENAME@',
|
||||
+ configuration: {
|
||||
+ 'bindir': join_paths(get_option('prefix'), get_option('bindir'))
|
||||
+ },
|
||||
+ install_dir: join_paths(datadir, 'applications')
|
||||
+ )
|
||||
+endif
|
||||
diff --git a/tools/yelp-build-url-handler.desktop.in b/tools/yelp-build-url-handler.desktop.in
|
||||
new file mode 100644
|
||||
index 0000000..9ead646
|
||||
--- /dev/null
|
||||
+++ b/tools/yelp-build-url-handler.desktop.in
|
||||
@@ -0,0 +1,6 @@
|
||||
+[Desktop Entry]
|
||||
+Name=Yelp URL Handler
|
||||
+Exec=@bindir@/yelp-build-url-handler %u
|
||||
+Type=Application
|
||||
+MimeType=x-scheme-handler/help;
|
||||
+NoDisplay=true
|
||||
diff --git a/tools/yelp-build-url-handler.in b/tools/yelp-build-url-handler.in
|
||||
new file mode 100755
|
||||
index 0000000..8742d67
|
||||
--- /dev/null
|
||||
+++ b/tools/yelp-build-url-handler.in
|
||||
@@ -0,0 +1,212 @@
|
||||
+#!/usr/bin/python3
|
||||
+#
|
||||
+# yelp-build-url-handler
|
||||
+# Copyright (C) 2023, 2024 Red Hat Inc.
|
||||
+#
|
||||
+# This program is free software; you can redistribute it and/or modify
|
||||
+# it under the terms of the GNU General Public License as published by
|
||||
+# the Free Software Foundation; either version 2 of the License, or
|
||||
+# (at your option) any later version.
|
||||
+#
|
||||
+# This program is distributed in the hope that it will be useful, but
|
||||
+# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+# General Public License for more details.
|
||||
+#
|
||||
+# You should have received a copy of the GNU General Public License
|
||||
+# along with this program; if not, write to the Free Software
|
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+import os
|
||||
+import sys
|
||||
+import subprocess
|
||||
+import urllib.parse
|
||||
+import gi
|
||||
+import errno
|
||||
+import dbus
|
||||
+from dbus import Interface, SessionBus
|
||||
+
|
||||
+gi.require_version('Gio', '2.0')
|
||||
+from gi.repository import Gio, GLib
|
||||
+
|
||||
+class YelpBuildUrlHandler:
|
||||
+ def main(self):
|
||||
+ if len(sys.argv) != 2:
|
||||
+ print('Usage: yelp-build-url-handler <URL>', file=sys.stderr)
|
||||
+ return 1
|
||||
+ url = sys.argv[1]
|
||||
+ return self.handle_url(url)
|
||||
+
|
||||
+ def determine_paths_from_url(self, url):
|
||||
+ parsed_url = urllib.parse.urlparse(url)
|
||||
+ if parsed_url.scheme != 'help':
|
||||
+ print(f'Invalid URI scheme: {parsed_url.scheme}', file=sys.stderr)
|
||||
+ return None
|
||||
+
|
||||
+ path = parsed_url.path.lstrip('/')
|
||||
+ languages = GLib.get_language_names() + ['C']
|
||||
+
|
||||
+ for language in languages:
|
||||
+ base_path = os.path.join('@HELPDIR@', language)
|
||||
+ cache_path = os.path.join(GLib.get_user_cache_dir(), 'yelp-build', language)
|
||||
+ full_source_path = os.path.join(base_path, path)
|
||||
+
|
||||
+ if os.path.isdir(full_source_path):
|
||||
+ source_dir = full_source_path
|
||||
+ output_dir = os.path.join(cache_path, path)
|
||||
+ output_file = os.path.join(output_dir, 'index.html')
|
||||
+ return {
|
||||
+ 'source_dir': source_dir,
|
||||
+ 'output_dir': output_dir,
|
||||
+ 'output_file': output_file,
|
||||
+ 'full_source_path': full_source_path
|
||||
+ }
|
||||
+ else:
|
||||
+ full_source_file = full_source_path + '.page'
|
||||
+ if os.path.isfile(full_source_file):
|
||||
+ source_dir = os.path.dirname(full_source_file)
|
||||
+ output_file = os.path.join(cache_path, path + '.html')
|
||||
+ output_dir = os.path.dirname(output_file)
|
||||
+ return {
|
||||
+ 'source_dir': source_dir,
|
||||
+ 'output_dir': output_dir,
|
||||
+ 'output_file': output_file,
|
||||
+ 'full_source_path': full_source_file
|
||||
+ }
|
||||
+
|
||||
+ print(f'Help content not found for path: {path}', file=sys.stderr)
|
||||
+ return None
|
||||
+
|
||||
+ def handle_url(self, url):
|
||||
+ paths = self.determine_paths_from_url(url)
|
||||
+
|
||||
+ if paths is None:
|
||||
+ return 1
|
||||
+
|
||||
+ source_dir = paths['source_dir']
|
||||
+ output_dir = paths['output_dir']
|
||||
+ output_file = paths['output_file']
|
||||
+ full_source_path = paths['full_source_path']
|
||||
+
|
||||
+ cache_stale = True
|
||||
+ try:
|
||||
+ output_status = os.stat(output_dir)
|
||||
+ source_status = os.stat(source_dir)
|
||||
+ if output_status.st_mtime < source_status.st_mtime:
|
||||
+ cache_stale = False
|
||||
+ except OSError as e:
|
||||
+ pass
|
||||
+
|
||||
+ if cache_stale:
|
||||
+ cache_stale = not self.generate_html(source_dir, output_dir)
|
||||
+
|
||||
+ if cache_stale:
|
||||
+ print(f'Failed to generate HTML for path {full_source_path}', file=sys.stderr)
|
||||
+ return 1
|
||||
+
|
||||
+ sandboxed_dir = self.grant_access_to_browser(output_dir)
|
||||
+ if sandboxed_dir is None:
|
||||
+ print(f'Failed to grant browser access to generated HTML for path {full_source_path}', file=sys.stderr)
|
||||
+ return 1
|
||||
+
|
||||
+ basename = os.path.basename(output_file)
|
||||
+ sandboxed_file = os.path.join(sandboxed_dir, basename)
|
||||
+ redirect_file = self.write_redirect_file(sandboxed_dir, sandboxed_file)
|
||||
+ if redirect_file is None:
|
||||
+ return 1
|
||||
+
|
||||
+ if not self.show_generated_html(redirect_file):
|
||||
+ print('Failed to start browser', file=sys.stderr)
|
||||
+ return 1
|
||||
+
|
||||
+ def generate_html(self, source_dir, output_dir):
|
||||
+ os.makedirs(output_dir, exist_ok=True)
|
||||
+ argv = ['yelp-build', 'html', '.', '-o', output_dir]
|
||||
+ try:
|
||||
+ subprocess.run(argv, cwd=source_dir, check=True)
|
||||
+ return True
|
||||
+ except subprocess.CalledProcessError as e:
|
||||
+ print(f'Could not run "{" ".join(argv)}": {e}', file=sys.stderr)
|
||||
+ return False
|
||||
+
|
||||
+ def grant_access_to_browser(self, output_dir):
|
||||
+ default_browser = Gio.AppInfo.get_default_for_type('text/html', False)
|
||||
+ if default_browser is None:
|
||||
+ print('Default web browser not found!', file=sys.stderr)
|
||||
+ return None
|
||||
+
|
||||
+ app_id = default_browser.get_id()
|
||||
+ if app_id is None:
|
||||
+ print('Default web browser has no app ID!', file=sys.stderr)
|
||||
+ return None
|
||||
+
|
||||
+ app_id = app_id.removesuffix('.desktop')
|
||||
+
|
||||
+ try:
|
||||
+ dir_fd = os.open(output_dir, os.O_PATH)
|
||||
+ except OSError as e:
|
||||
+ print(f'Failed to open directory {output_dir}: {e}', file=sys.stderr)
|
||||
+ return None
|
||||
+
|
||||
+ bus = SessionBus()
|
||||
+ try:
|
||||
+ portal_documents_object = bus.get_object('org.freedesktop.portal.Documents', '/org/freedesktop/portal/documents')
|
||||
+ portal_documents = Interface(portal_documents_object, dbus_interface='org.freedesktop.portal.Documents')
|
||||
+ except dbus.DBusException as e:
|
||||
+ print(f'Failed to connect to Documents portal: {e}', file=sys.stderr)
|
||||
+ os.close(dir_fd)
|
||||
+ return None
|
||||
+
|
||||
+ flags = (
|
||||
+ 1 << 0 # ReuseExisting
|
||||
+ | 1 << 1 # Persistent
|
||||
+ | 1 << 3 # ExportDirectory
|
||||
+ )
|
||||
+ permissions = ['read']
|
||||
+
|
||||
+ try:
|
||||
+ doc_with_signature, *_ = portal_documents.AddFull([dbus.types.UnixFd(dir_fd)], flags, app_id, permissions)
|
||||
+ if not doc_with_signature:
|
||||
+ print('No document IDs returned from portal', file=sys.stderr)
|
||||
+ os.close(dir_fd)
|
||||
+ return None
|
||||
+
|
||||
+ doc_id, *_ = doc_with_signature
|
||||
+ sandboxed_dir = os.path.join(GLib.get_user_runtime_dir(), 'doc', doc_id, os.path.basename(output_dir))
|
||||
+ os.close(dir_fd)
|
||||
+ except dbus.DBusException as e:
|
||||
+ print(f'Failed to call AddFull method: {e}', file=sys.stderr)
|
||||
+ os.close(dir_fd)
|
||||
+ return None
|
||||
+
|
||||
+ return sandboxed_dir
|
||||
+
|
||||
+ def show_generated_html(self, output):
|
||||
+ try:
|
||||
+ uri = GLib.filename_to_uri(output)
|
||||
+ Gio.AppInfo.launch_default_for_uri(uri, None)
|
||||
+ except Exception as e:
|
||||
+ print(f'Failed to launch default application: {e}', file=sys.stderr)
|
||||
+ return False
|
||||
+
|
||||
+ return True
|
||||
+
|
||||
+ def write_redirect_file(self, sandboxed_dir, sandboxed_file):
|
||||
+ html = f'<meta http-equiv="refresh" content="0; url=file://{sandboxed_file}">'
|
||||
+ redirect_file = os.path.join(sandboxed_dir, 'yelp-build-redirect.html')
|
||||
+
|
||||
+ try:
|
||||
+ with open(redirect_file, 'w') as f:
|
||||
+ f.write(html)
|
||||
+ except Exception as e:
|
||||
+ print(f'Error writing redirect file {redirect_file}: {e}', file=sys.stderr)
|
||||
+ return None
|
||||
+
|
||||
+ return redirect_file
|
||||
+
|
||||
+if __name__ == '__main__':
|
||||
+ try:
|
||||
+ sys.exit(YelpBuildUrlHandler().main())
|
||||
+ except KeyboardInterrupt:
|
||||
+ sys.exit(1)
|
||||
+
|
||||
--
|
||||
GitLab
|
||||
|
Loading…
Reference in New Issue
Block a user