Mail Archives: cygwin/2007/01/07/23:14:42
--------------030500040301030900070206
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cygport automates many of the tedious steps of the build process for
cygwin ports (and that's a GOOD thing). However, at present there are
cases when the existing customization/extension points provided by
cygport are not sufficient -- the user needs to intervene
before/after/during some of the automated steps.
[implementation details]
[1] Possibiliyt: remove the readonly protection on the existing,
internal, automation functions (like __prep_installdir or src_prep).
This is a really bad idea: some of these functions (especially the __*
ones) are NOT part of cygport's public interface, and are subject to
change in later releases -- a .cygport file that redefines these is
brittle with respect to future releases of the cygport framework.
Others, like src_prep(), are large, complicated, and must NOT be changed
in any appreciable way, because other functions in cygport depend on
stuff being "just so". .cygport files that redefine these functions
will ALSO be brittle -- and worse, could break things with respect to
later cygport framework releases that are hard to identify. Finally,
carrying around duplicate copies (one in cygport itself, the other in
the .cygport file) with only minor difference is a silly waste. IMNSHO.
[2] Possibility: supply additional customization/extension points to
allow the end user more flexibility to customize certain aspects of the
automated "tedious steps" when necessary. Without, mind you, obligating
.cygport files to carry around lots of redundant copies of functions
defined in the main cygport framework, nor overriding functions which
are *supposed* to be internal implementation details of the cygport
framework itself.
Obviously, I prefer [2], which is implemented below for the prep and
install stages.
Note that src_prep_init_hook is NOT called as the absolute first step in
'cygport ... prep', because that makes no sense: src_prep needs to at
least create the various (empty) directories that all cygports expect to
be present, and unpack the main src entities. It isn't clear to me
whether this customization point should come before or after applying
the patches in cygport-0.2.7's new PATCH_URI list. I choose "before",
because that will work better for ncurses[*].
---------------------------------------------------------------
[*] ncurses's official patches are distributed as:
(1) a "rollup patch" that is a shell script, and which contains a
shar archive of all patches prior to that date. This script applies the
patches itself. The upstream maintainer generates rollup patches every
three months or so.
(2) a possibly empty set of up to 12 weekly, noncumulative .patch files.
If I put the patches in (2) into PATCH_URI, they need to be applied
after the rollup patch script is run -- and THAT needs to be done in
src_prep_init_hook(). So, src_prep invokes src_prep_init_hook() before
it applies the patches in PATCH_URI.
---------------------------------------------------------------
2007-01-05 Charles Wilson <...>
* cygport.in (src_prep_init_hook): new (empty) function
(src_prep_fini_hook): ditto
(src_prep): fix bug where 'cd ${SRCDIR}' happened before
checking if '${SRCDIR}' actually exists.
(src_prep): call src_prep_init_hook() after setting up the
cygport directory structure, unpacking all entities in SRC_URI,
but before applying any of the patches in PATCH_URI, and before
mirroring the origsrc directory to the src directory, or
applying the .src.patch and .cygwin.patch to the src directory).
(src_prep): call src_prep_fini_hook() after doing ALL of the
above.
(src_install_init_hook): new (empty) function
(src_install_fini_hook): new (empty) function
(main) [case inst*]: call src_install_init_hook FIRST, then
other automated installation steps, then src_install_fini_hook
LAST
(main): export all hook functions.
--
Chuck
--------------030500040301030900070206
Content-Type: text/plain;
name="cygport-hooks.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="cygport-hooks.patch"
Index: bin/cygport.in
===================================================================
RCS file: /cvsroot/cygwin-ports/cygport/bin/cygport.in,v
retrieving revision 1.45
diff -u -r1.45 cygport.in
--- bin/cygport.in 4 Jan 2007 02:35:26 -0000 1.45
+++ bin/cygport.in 6 Jan 2007 03:11:40 -0000
@@ -566,6 +566,19 @@
fi
}
+# provides a hook for cygclasses/cygports to take action
+# *before* origsrc directory is mirrored to src directory
+# NOTE that all sources in SRC_URI have already been unpacked,
+# but the patches in PATCH_URI have NOT been applied,
+# when this function is invoked.
+src_prep_init_hook() {
+ :
+}
+# provides a hook for cygclasses/cygports to take action
+# *after* origsrc directory is mirrored to src directory
+src_prep_fini_hook() {
+ :
+}
src_prep() {
local sigext;
local src_patch;
@@ -612,20 +625,23 @@
unpack ${top}/${src_pkg};
done
- cd ${origsrcdir}/${SRC_DIR};
+ if [ ! -d ${origsrcdir}/${SRC_DIR} ]
+ then
+ error "SRC_DIR is not correctly defined"
+ fi
+
+ src_prep_init_hook
+ cd ${origsrcdir}/${SRC_DIR};
for src_patch in ${_src_orig_patches}
do
apply_patch ${top}/${src_patch};
done
- if [ ! -d ${origsrcdir}/${SRC_DIR} ]
- then
- error "SRC_DIR is not correctly defined"
- fi
__step "Preparing working source directory";
+ cd ${top}
cp -fpr ${origsrcdir}/* ${srcdir};
mkdir -p ${C};
@@ -637,11 +653,15 @@
then
apply_patch ${top}/${cygwin_patchfile} ${top}/${src_patchfile};
fi
+
+ cd ${top}
+ src_prep_fini_hook
+ cd ${S}
}
# protect functions
readonly -f fetch src_fetch unpack gpg_verify __mkdirs apply_patch __oldpatch src_prep
-
+export -f src_prep_init_hook src_prep_fini_hook
################################################################################
#
@@ -969,8 +989,21 @@
cyginstall
}
+# provides a hook for cygclasses/cygports to take action
+# *before* built-in preinstall steps.
+src_install_init_hook() {
+ :
+}
+
+# provides a hook for cygclasses/cygports to take action
+# *after* built-in postinstall steps.
+src_install_fini_hook() {
+ :
+}
+
# protect functions
export -f dodir docinto exeinto insinto
+export -f src_install_init_hook src_install_fini_hook
readonly -f dodir docinto exeinto insinto __prepinstalldirs cyginstall
@@ -1678,7 +1711,7 @@
;;
inst*)
__stage Installing;
- (__prepinstalldirs && src_install && src_postinst) 2>&1 | tee ${installlog};
+ (src_install_init_hook && __prepinstalldirs && src_install && src_postinst && src_install_fini_hook) 2>&1 | tee ${installlog};
_status=$?;
;;
list)
--------------030500040301030900070206
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
--------------030500040301030900070206--
- Raw text -