[newlib-cygwin] cygwin doc: Add postinstall/preremove scripts to install Start Menu entries

Corinna Vinschen corinna@sourceware.org
Sat Apr 22 12:03:00 GMT 2017


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8e0876727b9ae339ef1c2526e6b15cf4e29396ca

commit 8e0876727b9ae339ef1c2526e6b15cf4e29396ca
Author: Brian Inglis <Brian.Inglis@SystematicSw.ab.ca>
Date:   Fri Apr 21 13:26:10 2017 +0200

    cygwin doc: Add postinstall/preremove scripts to install Start Menu entries
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/doc/Makefile.in                   | 11 +++-
 winsup/doc/etc.postinstall.cygwin-doc.sh | 92 ++++++++++++++++++++++++++++++++
 winsup/doc/etc.preremove.cygwin-doc.sh   | 14 +++++
 3 files changed, 115 insertions(+), 2 deletions(-)

diff --git a/winsup/doc/Makefile.in b/winsup/doc/Makefile.in
index 252ed5b..bcf0c1f 100644
--- a/winsup/doc/Makefile.in
+++ b/winsup/doc/Makefile.in
@@ -18,6 +18,7 @@ mandir = @mandir@
 man1dir = $(mandir)/man1
 man3dir = $(mandir)/man3
 infodir:=@infodir@
+sysconfdir:=@sysconfdir@
 
 override INSTALL:=@INSTALL@
 override INSTALL_DATA:=@INSTALL_DATA@
@@ -39,7 +40,7 @@ include $(srcdir)/../Makefile.common
 	$(srcdir)/bodysnatcher.pl $<
 
 .PHONY: all clean install install-all install-pdf install-html install-man \
-	info install-info
+	info install-info install-etc
 
 all: Makefile Makefile.dep \
 	cygwin-ug-net/cygwin-ug-net.html \
@@ -66,7 +67,7 @@ clean:
 
 install: install-all
 
-install-all: install-pdf install-html install-man install-info
+install-all: install-pdf install-html install-man install-info install-etc
 
 install-pdf: cygwin-ug-net/cygwin-ug-net.pdf cygwin-api/cygwin-api.pdf
 	@$(MKDIRP) $(DESTDIR)$(docdir)
@@ -92,6 +93,12 @@ install-info: cygwin-ug-net.info cygwin-api.info
 	$(MKDIRP) $(DESTDIR)$(infodir)
 	$(INSTALL_DATA) *.info* $(DESTDIR)$(infodir)
 
+install-etc:
+	@$(MKDIRP) $(DESTDIR)$(sysconfdir)/postinstall
+	$(INSTALL) $(srcdir)/etc.postinstall.cygwin-doc.sh $(DESTDIR)$(sysconfdir)/postinstall/cygwin-doc.sh
+	@$(MKDIRP) $(DESTDIR)$(sysconfdir)/preremove
+	$(INSTALL) $(srcdir)/etc.preremove.cygwin-doc.sh $(DESTDIR)$(sysconfdir)/preremove/cygwin-doc.sh
+
 cygwin-ug-net/cygwin-ug-net-nochunks.html.gz : $(cygwin-ug-net_SOURCES) html.xsl
 	-$(XMLTO) html-nochunks -m $(srcdir)/html.xsl $<
 	-@$(MKDIRP) cygwin-ug-net
diff --git a/winsup/doc/etc.postinstall.cygwin-doc.sh b/winsup/doc/etc.postinstall.cygwin-doc.sh
new file mode 100755
index 0000000..dbb6412
--- /dev/null
+++ b/winsup/doc/etc.postinstall.cygwin-doc.sh
@@ -0,0 +1,92 @@
+#!/bin/bash
+# /etc/postinstall/cygwin-doc.sh - cygwin-doc postinstall script.
+# installs Cygwin Start Menu shortcuts for Cygwin User Guide and API PDF and
+# HTML if in doc dir, and links to Cygwin web site home page and FAQ
+#
+# Assumes you are running setup.exe 2.510.2.2 or newer, executed by /bin/bash
+# and not /bin/[da]sh (if you are running an older setup.exe, this postinstall
+# script can't do anything).
+#
+# CYGWINFORALL=-A if install for All Users
+# installs local shortcuts for All Users or Current User in
+# {ProgramData,~/Appdata/Roaming}/Microsoft/Windows/Start Menu/Programs/Cygwin/
+
+cygp=/bin/cygpath
+mks=/bin/mkshortcut
+un=/bin/uname
+site=https://cygwin.com
+
+# check for programs
+for p in $un $cygp $mks
+do
+	if [ ! -x $p ]
+	then
+		echo "Can't find program '$p'"
+		exit 2
+	fi
+done
+
+cygver=$($un -r)	# release - numeric version (build info)
+cygver=${cygver%\(*\)}	# strip build info
+doc=/usr/share/doc/cygwin-$cygver
+html=$doc/html
+smpc_dir="$($cygp $CYGWINFORALL -P -U)/Cygwin"
+
+for d in $doc $html "$smpc_dir"
+do
+	if [ ! -d "$d/" ]
+	then
+		echo "Can't find directory '$d'"
+		exit 2
+	fi
+done
+
+if [ ! -w "$smpc_dir/" ]
+then
+	echo "Can't write to directory '$smpc_dir'"
+	exit 1
+fi
+
+# mkshortcut works only in current directory - change to Cygwin Start Menu
+cd "$smpc_dir" || exit 2	# quit if not found
+
+# User Guide PDF & HTML
+p=$doc/cygwin-ug-net.pdf
+n="User Guide (PDF)"
+d="PDF Cygwin User Guide"
+
+[ -r $p ] && $mks -n "$n" -d "$d" $p
+
+i=$html/cygwin-ug-net/index.html
+n="User Guide (HTML)"
+d="HTML Cygwin User Guide"
+
+[ -r $i ] && $mks -n "$n" -d "$d" $i
+
+# API PDF & HTML
+p=$doc/cygwin-api.pdf
+n="API (PDF)"
+d="PDF Cygwin API Reference"
+
+[ -r $p ] && $mks -n "$n" -d "$d" $p
+
+i=$html/cygwin-api/index.html
+n="API (HTML)"
+d="HTML Cygwin API Reference"
+
+[ -r $i ] && $mks -n "$n" -d "$d" $i
+
+# Home Page URL
+h=$site/index.html
+n="Home Page"
+d="Cygwin $n"
+
+$mks -n "$n" -d "$d" $h
+
+# FAQ URL
+h=$site/faq.html
+n="FAQ"
+d="Cygwin Frequently Asked Questions (with answers)"
+
+$mks -n "$n" -d "$d" $h
+
diff --git a/winsup/doc/etc.preremove.cygwin-doc.sh b/winsup/doc/etc.preremove.cygwin-doc.sh
new file mode 100755
index 0000000..817d6d6
--- /dev/null
+++ b/winsup/doc/etc.preremove.cygwin-doc.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+# /etc/preremove/cygwin-doc.sh - cygwin-doc preremove script.
+# removes Cygwin Start Menu shortcuts for Cygwin User Guide and API PDF and
+# HTML, and links to Cygwin web site home page and FAQ
+#
+# CYGWINFORALL=-A if remove for All Users
+# remove local shortcuts for All Users or Current User in
+# {ProgramData,~/Appdata/Roaming}/Microsoft/Windows/Start Menu/Programs/Cygwin/
+
+cd "$(/bin/cygpath $CYGWINFORALL -P -U)/Cygwin" || exit 2
+
+/bin/rm -f -- "User Guide (PDF).lnk" "User Guide (HTML).lnk" \
+	"API (PDF).lnk" "API (HTML).lnk" "Home Page.lnk" "FAQ.lnk"
+



More information about the Cygwin-cvs mailing list