set -${shopts}
}
- preinst_bsdflags() {
- hasq chflags $FEATURES || return
- # Save all the file flags for restoration after installation.
- mtree -c -p "${D}" -k flags > "${T}/bsdflags.mtree"
- # Remove all the file flags so that the merge phase can do anything
- # necessary.
- chflags -R noschg,nouchg,nosappnd,nouappnd "${D}"
- chflags -R nosunlnk,nouunlnk "${D}" 2>/dev/null
- }
-
- postinst_bsdflags() {
- hasq chflags $FEATURES || return
- # Restore all the file flags that were saved before installation.
- mtree -e -p "${ROOT}" -U -k flags < "${T}/bsdflags.mtree" &> /dev/null
- }
-
+preinst_aix() {
+ if [[ ${CHOST} != *-aix* ]] || hasq binchecks ${RESTRICT}; then
+ return 0
+ fi
+ local ar strip
+ if type ${CHOST}-ar >/dev/null 2>&1 && type ${CHOST}-strip >/dev/null 2>&1; then
+ ar=${CHOST}-ar
+ strip=${CHOST}-strip
+ elif [[ ${CBUILD} == "${CHOST}" ]] && type ar >/dev/null 2>&1 && type strip >/dev/null 2>&1; then
+ ar=ar
+ strip=strip
+ elif [[ -x /usr/ccs/bin/ar && -x /usr/ccs/bin/strip ]]; then
+ ar=/usr/ccs/bin/ar
+ strip=/usr/ccs/bin/strip
+ else
+ die "cannot find where to use 'ar' and 'strip' from"
+ fi
+ local archives_members= archives=() chmod400files=()
+ local archive_member soname runpath needed archive contentmember
+ while read archive_member; do
+ archive_member=${archive_member#*;${EPREFIX}/} # drop "^type;EPREFIX/"
+ soname=${archive_member#*;}
+ runpath=${soname#*;}
+ needed=${runpath#*;}
+ soname=${soname%%;*}
+ runpath=${runpath%%;*}
+ archive_member=${archive_member%%;*} # drop ";soname;runpath;needed$"
+ archive=${archive_member%[*}
+ if [[ ${archive_member} != *'['*']' ]]; then
+ if [[ "${soname};${runpath};${needed}" == "${archive##*/};;" && -e ${EROOT}${archive} ]]; then
+ # most likely is an archive stub that already exists,
+ # may have to preserve members being a shared object.
+ archives[${#archives[@]}]=${archive}
+ fi
+ continue
+ fi
+ archives_members="${archives_members}:(${archive_member}):"
+ contentmember="${archive%/*}/.${archive##*/}${archive_member#${archive}}"
+ # portage does os.lstat() on merged files every now
+ # and then, so keep stamp-files for archive members
+ # around to get the preserve-libs feature working.
+ { echo "Please leave this file alone, it is an important helper"
+ echo "for portage to implement the 'preserve-libs' feature on AIX."
+ } > "${ED}${contentmember}" || die "cannot create ${contentmember}"
+ chmod400files[${#chmod400files[@]}]=${ED}${contentmember}
+ done < "${PORTAGE_BUILDDIR}"/build-info/NEEDED.XCOFF.1
+ [[ ${#chmod400files[@]} == 0 ]] ||
+ chmod 0400 "${chmod400files[@]}" || die "cannot chmod ${chmod400files[@]}"
+
+ local preservemembers libmetadir prunedirs=()
+ local FILE MEMBER FLAGS
+ for archive in "${archives[@]}"; do
+ preservemembers=
+ while read line; do
+ [[ -n ${line} ]] || continue
+ FILE= MEMBER= FLAGS=
+ eval ${line}
+ [[ ${FILE} == ${EROOT}${archive} ]] ||
+ die "invalid result of aixdll-query for ${EROOT}${archive}"
+ [[ -n ${MEMBER} && " ${FLAGS} " == *" SHROBJ "* ]] || continue
+ [[ ${archives_members} == *":(${archive}[${MEMBER}]):"* ]] && continue
+ preservemembers="${preservemembers} ${MEMBER}"
+ done <<-EOF
+ $(aixdll-query "${EROOT}${archive}" FILE MEMBER FLAGS)
+ EOF
+ [[ -n ${preservemembers} ]] || continue
+ einfo "preserving (on spec) ${archive}[${preservemembers# }]"
+ libmetadir=${ED}${archive%/*}/.${archive##*/}
+ mkdir "${libmetadir}" || die "cannot create ${libmetadir}"
+ pushd "${libmetadir}" >/dev/null || die "cannot cd to ${libmetadir}"
+ ${ar} -X32_64 -x "${EROOT}${archive}" ${preservemembers} || die "cannot unpack ${EROOT}${archive}"
+ chmod u+w ${preservemembers} || die "cannot chmod${preservemembers}"
+ ${strip} -X32_64 -e ${preservemembers} || die "cannot strip${preservemembers}"
+ ${ar} -X32_64 -q "${ED}${archive}" ${preservemembers} || die "cannot update ${archive}"
+ eend $?
+ popd >/dev/null || die "cannot leave ${libmetadir}"
+ prunedirs[${#prunedirs[@]}]=${libmetadir}
+ done
+ [[ ${#prunedirs[@]} == 0 ]] ||
+ rm -rf "${prunedirs[@]}" || die "cannot prune ${prunedirs[@]}"
+ return 0
+}
+
+postinst_aix() {
+ if [[ ${CHOST} != *-aix* ]] || hasq binchecks ${RESTRICT}; then
+ return 0
+ fi
+ local MY_PR=${PR%r0}
+ local ar strip
+ if type ${CHOST}-ar >/dev/null 2>&1 && type ${CHOST}-strip >/dev/null 2>&1; then
+ ar=${CHOST}-ar
+ strip=${CHOST}-strip
+ elif [[ ${CBUILD} == "${CHOST}" ]] && type ar >/dev/null 2>&1 && type strip >/dev/null 2>&1; then
+ ar=ar
+ strip=strip
+ elif [[ -x /usr/ccs/bin/ar && -x /usr/ccs/bin/strip ]]; then
+ ar=/usr/ccs/bin/ar
+ strip=/usr/ccs/bin/strip
+ else
+ die "cannot find where to use 'ar' and 'strip' from"
+ fi
+ local archives_members= archives=() activearchives=
+ local archive_member soname runpath needed
+ while read archive_member; do
+ archive_member=${archive_member#*;${EPREFIX}/} # drop "^type;EPREFIX/"
+ soname=${archive_member#*;}
+ runpath=${soname#*;}
+ needed=${runpath#*;}
+ soname=${soname%%;*}
+ runpath=${runpath%%;*}
+ archive_member=${archive_member%%;*} # drop ";soname;runpath;needed$"
+ [[ ${archive_member} == *'['*']' ]] && continue
+ [[ "${soname};${runpath};${needed}" == "${archive_member##*/};;" ]] || continue
+ # most likely is an archive stub, we might have to
+ # drop members being preserved shared objects.
+ archives[${#archives[@]}]=${archive_member}
+ activearchives="${activearchives}:(${archive_member}):"
+ done < "${PORTAGE_BUILDDIR}"/build-info/NEEDED.XCOFF.1
+
+ local type allcontentmembers= oldarchives=()
+ local contentmember
+ while read type contentmember; do
+ [[ ${type} == 'obj' ]] || continue
+ contentmember=${contentmember% *} # drop " timestamp$"
+ contentmember=${contentmember% *} # drop " hash$"
+ [[ ${contentmember##*/} == *'['*']' ]] || continue
+ contentmember=${contentmember#${EPREFIX}/}
+ allcontentmembers="${allcontentmembers}:(${contentmember}):"
+ contentmember=${contentmember%[*}
+ contentmember=${contentmember%/.*}/${contentmember##*/.}
+ [[ ${activearchives} == *":(${contentmember}):"* ]] && continue
+ oldarchives[${#oldarchives[@]}]=${contentmember}
+ done < "${EPREFIX}/var/db/pkg/${CATEGORY}/${P}${MY_PR:+-}${MY_PR}/CONTENTS"
+
+ local archive line delmembers
+ local FILE MEMBER FLAGS
+ for archive in "${archives[@]}"; do
+ [[ -r ${EROOT}${archive} && -w ${EROOT}${archive} ]] ||
+ chmod a+r,u+w "${EROOT}${archive}" || die "cannot chmod ${EROOT}${archive}"
+ delmembers=
+ while read line; do
+ [[ -n ${line} ]] || continue
+ FILE= MEMBER= FLAGS=
+ eval ${line}
+ [[ ${FILE} == "${EROOT}${archive}" ]] ||
+ die "invalid result '${FILE}' of aixdll-query, expected '${EROOT}${archive}'"
+ [[ -n ${MEMBER} && " ${FLAGS} " == *" SHROBJ "* ]] || continue
+ [[ ${allcontentmembers} == *":(${archive%/*}/.${archive##*/}[${MEMBER}]):"* ]] && continue
+ delmembers="${delmembers} ${MEMBER}"
+ done <<-EOF
+ $(aixdll-query "${EROOT}${archive}" FILE MEMBER FLAGS)
+ EOF
+ [[ -n ${delmembers} ]] || continue
+ einfo "dropping ${archive}[${delmembers# }]"
+ rm -f "${EROOT}${archive}".new || die "cannot prune ${EROOT}${archive}.new"
+ cp "${EROOT}${archive}" "${EROOT}${archive}".new || die "cannot backup ${archive}"
+ ${ar} -X32_64 -z -o -d "${EROOT}${archive}".new ${delmembers} || die "cannot remove${delmembers} from ${archive}.new"
+ mv -f "${EROOT}${archive}".new "${EROOT}${archive}" || die "cannot put ${EROOT}${archive} in place"
+ eend $?
+ done
+ local libmetadir keepmembers prunedirs=()
+ for archive in "${oldarchives[@]}"; do
+ [[ -r ${EROOT}${archive} && -w ${EROOT}${archive} ]] ||
+ chmod a+r,u+w "${EROOT}${archive}" || die "cannot chmod ${EROOT}${archive}"
+ keepmembers=
+ while read line; do
+ FILE= MEMBER= FLAGS=
+ eval ${line}
+ [[ ${FILE} == "${EROOT}${archive}" ]] ||
+ die "invalid result of aixdll-query for ${EROOT}${archive}"
+ [[ -n ${MEMBER} && " ${FLAGS} " == *" SHROBJ "* ]] || continue
+ [[ ${allcontentmembers} == *":(${archive%/*}/.${archive##*/}[${MEMBER}]):"* ]] || continue
+ keepmembers="${keepmembers} ${MEMBER}"
+ done <<-EOF
+ $(aixdll-query "${EROOT}${archive}" FILE MEMBER FLAGS)
+ EOF
+
+ if [[ -n ${keepmembers} ]]; then
+ einfo "preserving (extra)${keepmembers}"
+ libmetadir=${EROOT}${archive%/*}/.${archive##*/}
+ [[ ! -e ${libmetadir} ]] || rm -rf "${libmetadir}" || die "cannot prune ${libmetadir}"
+ mkdir "${libmetadir}" || die "cannot create ${libmetadir}"
+ pushd "${libmetadir}" >/dev/null || die "cannot cd to ${libmetadir}"
+ ${ar} -X32_64 -x "${EROOT}${archive}" ${keepmembers} || die "cannot unpack ${archive}"
+ ${strip} -X32_64 -e ${keepmembers} || die "cannot strip ${keepmembers}"
+ rm -f "${EROOT}${archive}.new" || die "cannot prune ${EROOT}${archive}.new"
+ ${ar} -X32_64 -q "${EROOT}${archive}.new" ${keepmembers} || die "cannot create ${EROOT}${archive}.new"
+ mv -f "${EROOT}${archive}.new" "${EROOT}${archive}" || die "cannot put ${EROOT}${archive} in place"
+ popd > /dev/null || die "cannot leave ${libmetadir}"
+ prunedirs[${#prunedirs[@]}]=${libmetadir}
+ eend $?
+ fi
+ done
+ [[ ${#prunedirs[@]} == 0 ]] ||
+ rm -rf "${prunedirs[@]}" || die "cannot prune ${prunedirs[@]}"
+ return 0
+}
+
preinst_mask() {
if [ -z "${D}" ]; then
eerror "${FUNCNAME}: D is unset"