20 |
SMAGESUFFIX="smage2" |
SMAGESUFFIX="smage2" |
21 |
MLIBDIR=/usr/lib/mage |
MLIBDIR=/usr/lib/mage |
22 |
SMAGEVERSION="$( < ${MLIBDIR}/version)" |
SMAGEVERSION="$( < ${MLIBDIR}/version)" |
|
SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" |
|
|
|
|
23 |
|
|
24 |
## only for tests -> normally in /etc/rc.d/init.d/functions |
## only for tests -> normally in /etc/rc.d/init.d/functions |
25 |
COLRED="\033[1;6m\033[31m" |
COLRED="\033[1;6m\033[31m" |
50 |
|
|
51 |
source /etc/mage.rc.global |
source /etc/mage.rc.global |
52 |
source ${MAGERC} |
source ${MAGERC} |
53 |
|
source ${MLIBDIR}/mage4.functions.sh |
54 |
|
|
55 |
# set PKGDIR and BUILDDIR and BINDIR to MROOT |
# set PKGDIR and BUILDDIR and BINDIR to MROOT |
56 |
if [[ -n ${MROOT} ]] |
if [[ -n ${MROOT} ]] |
60 |
export BINDIR=${MROOT}/${BINDIR} |
export BINDIR=${MROOT}/${BINDIR} |
61 |
fi |
fi |
62 |
|
|
63 |
|
# sources the smage file and uses state from distribution file if exist |
64 |
|
# may helpful for repository support later on |
65 |
|
smagesource() |
66 |
|
{ |
67 |
|
local file="$1" |
68 |
|
local mystate |
69 |
|
local mycodename |
70 |
|
|
71 |
|
source ${file} |
72 |
|
|
73 |
|
[[ -n ${STATE} ]] && mystate="${STATE}" |
74 |
|
|
75 |
|
# do not overide if local state was broken or disabled! |
76 |
|
case ${STATE} in |
77 |
|
broken) return ;; |
78 |
|
disabled) return ;; |
79 |
|
esac |
80 |
|
|
81 |
|
if [ -f ${SMAGESCRIPTSDIR}/distribution ] |
82 |
|
then |
83 |
|
source ${SMAGESCRIPTSDIR}/distribution |
84 |
|
[[ -n ${STATE} ]] && mystate="${STATE}" |
85 |
|
fi |
86 |
|
# now switch state and export it |
87 |
|
STATE="${mystate}" |
88 |
|
} |
89 |
|
|
90 |
showversion() |
showversion() |
91 |
{ |
{ |
92 |
echo -en "Magellan Source Install v${SMAGEVERSION} " |
echo -en "Magellan Source Install v${SMAGEVERSION} " |
101 |
exit 1 |
exit 1 |
102 |
} |
} |
103 |
|
|
104 |
|
die_pipestatus() |
105 |
|
{ |
106 |
|
# the status change if we do any parameter declarations!! |
107 |
|
# dont do this anymore, keep this in mind! |
108 |
|
# |
109 |
|
# local pos="$1" |
110 |
|
# local comment="$2" |
111 |
|
# |
112 |
|
# [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}" |
113 |
|
# |
114 |
|
[ ${PIPESTATUS[$1]} -ne 0 ] && die "$2" |
115 |
|
} |
116 |
|
|
117 |
xtitle() |
xtitle() |
118 |
{ |
{ |
119 |
if [[ ${TERM} = xterm ]] |
if [[ ${TERM} = xterm ]] |
181 |
local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
182 |
local FETCHING |
local FETCHING |
183 |
local i mirror |
local i mirror |
184 |
|
local wget_opts |
185 |
|
|
186 |
|
# filter wget command if busybox was found |
187 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
188 |
|
|
189 |
# install SRCDIR/PNAME if not exist |
# install SRCDIR/PNAME if not exist |
190 |
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
191 |
|
|
192 |
# check if FETCHING is needed |
# check if FETCHING is needed |
193 |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null ) |
( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} &> /dev/null ) |
194 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
195 |
then |
then |
196 |
# md5's ok, no fetching needed |
# md5's ok, no fetching needed |
215 |
my_SOURCEDIR="${SOURCEDIR}/${PNAME}" |
my_SOURCEDIR="${SOURCEDIR}/${PNAME}" |
216 |
fi |
fi |
217 |
|
|
218 |
|
# create the SOURCEDIR |
219 |
|
install -d ${my_SOURCEDIR} |
220 |
|
|
221 |
# if an mirrored file than replace first the mirror uri |
# if an mirrored file than replace first the mirror uri |
222 |
if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]] |
if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]] |
223 |
then |
then |
229 |
then |
then |
230 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
231 |
wget \ |
wget \ |
232 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
233 |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
234 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
235 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
250 |
then |
then |
251 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
252 |
wget \ |
wget \ |
253 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
254 |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
255 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
256 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
271 |
then |
then |
272 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
273 |
wget \ |
wget \ |
274 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
275 |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
276 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
277 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
292 |
then |
then |
293 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
294 |
wget \ |
wget \ |
295 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
296 |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
297 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
298 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
313 |
then |
then |
314 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
315 |
wget \ |
wget \ |
316 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
317 |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
318 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
319 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
329 |
then |
then |
330 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}" |
331 |
wget \ |
wget \ |
332 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
333 |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \ |
334 |
"${my_SRC_URI}" |
"${my_SRC_URI}" |
335 |
fi |
fi |
345 |
# recheck md5 sums |
# recheck md5 sums |
346 |
echo |
echo |
347 |
echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}" |
348 |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
349 |
echo |
echo |
350 |
|
|
351 |
# not needed anymore |
# not needed anymore |
533 |
libtoolize ${opts} || die "running: mlibtoolize ${opts}" |
libtoolize ${opts} || die "running: mlibtoolize ${opts}" |
534 |
} |
} |
535 |
|
|
536 |
|
mautoreconf() |
537 |
|
{ |
538 |
|
local opts="$@" |
539 |
|
[[ -z ${opts} ]] && opts="--verbose --install --force" |
540 |
|
|
541 |
|
autoreconf ${opts} || die "running: mautoreconf ${opts}" |
542 |
|
} |
543 |
|
|
544 |
minstalldocs() |
minstalldocs() |
545 |
{ |
{ |
546 |
local docfiles |
local docfiles |
551 |
install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." |
install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." |
552 |
fi |
fi |
553 |
|
|
554 |
|
local i |
555 |
for i in ${docfiles} |
for i in ${docfiles} |
556 |
do |
do |
557 |
cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs." |
if [ -f ${i} ] |
558 |
install -m 0644 ${SRCDIR}/${i}.gz \ |
then |
559 |
${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs." |
cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs." |
560 |
|
install -m 0644 ${SRCDIR}/${i}.gz \ |
561 |
|
${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs." |
562 |
|
fi |
563 |
done |
done |
564 |
} |
} |
565 |
|
|
579 |
find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
580 |
} |
} |
581 |
|
|
582 |
|
mcompressdocs() |
583 |
|
{ |
584 |
|
local bindir="$@" |
585 |
|
|
586 |
|
if [ -d ${bindir}/usr/share/man ] |
587 |
|
then |
588 |
|
echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}" |
589 |
|
${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man |
590 |
|
fi |
591 |
|
|
592 |
|
if [ -d ${bindir}/usr/share/info ] |
593 |
|
then |
594 |
|
echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}" |
595 |
|
${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info |
596 |
|
fi |
597 |
|
} |
598 |
|
|
599 |
sminclude() |
sminclude() |
600 |
{ |
{ |
601 |
local i |
local i |
711 |
# INHERITS which functions get included |
# INHERITS which functions get included |
712 |
# SPECIAL_FUNCTIONS special functions which should also be added |
# SPECIAL_FUNCTIONS special functions which should also be added |
713 |
# warning: they get killed before the build starts ! |
# warning: they get killed before the build starts ! |
714 |
|
# SPLIT_PACKAGES names of all subpackages which are splitted from parent |
715 |
|
# SPLIT_PACKAGE_BASE base package name for splitpackages |
716 |
|
# (only in the resulting magefile} |
717 |
# |
# |
718 |
# MAGE_TREE_DEST target destination of the generated tree |
# MAGE_TREE_DEST target destination of the generated tree |
719 |
# REGEN_MAGE_TREE set to 'true' to enable this |
# REGEN_MAGE_TREE set to 'true' to enable this |
724 |
local magefile |
local magefile |
725 |
local dest |
local dest |
726 |
local target |
local target |
727 |
|
local split_pkg_base |
728 |
local sym |
local sym |
729 |
local depname |
local depname |
730 |
|
|
732 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
733 |
|
|
734 |
# determinate which suffix this mage file should get, if any |
# determinate which suffix this mage file should get, if any |
735 |
[ -n "$1" ] && target="-$1" |
[[ $1 = --target ]] && shift && target="-$1" |
736 |
|
|
737 |
|
# mark package as splitpackage |
738 |
|
[[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1" |
739 |
|
|
740 |
# name of magefile |
# name of magefile |
741 |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
751 |
# now build the mage file |
# now build the mage file |
752 |
> ${dest} |
> ${dest} |
753 |
|
|
|
# header |
|
|
echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $' >> ${dest} |
|
|
echo >> ${dest} |
|
|
|
|
754 |
# pgkname and state |
# pgkname and state |
755 |
echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
756 |
echo "STATE=\"${STATE}\"" >> ${dest} |
echo "STATE=\"${STATE}\"" >> ${dest} |
|
echo >> ${dest} |
|
757 |
|
|
758 |
# description and homepage |
# description and homepage |
759 |
echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} |
echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} |
760 |
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
|
echo >> ${dest} |
|
761 |
|
|
762 |
# special tags and vars |
# special tags and vars |
763 |
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
764 |
|
|
765 |
# echo MAGE_TARGETS ## note -target is needed ! |
# echo MAGE_TARGETS ## note -target is needed ! |
766 |
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
767 |
echo >> ${dest} |
|
768 |
|
# split package base |
769 |
|
echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest} |
770 |
|
|
771 |
# add special vars |
# add special vars |
772 |
if [ -n "${SPECIAL_VARS}" ] |
if [ -n "${SPECIAL_VARS}" ] |
777 |
# being tricky here :) |
# being tricky here :) |
778 |
echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} |
echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} |
779 |
done |
done |
|
echo >> ${dest} |
|
780 |
fi |
fi |
781 |
|
|
782 |
# add at least all includes |
# add at least all includes |
788 |
do |
do |
789 |
echo -n " ${i}" >> ${dest} |
echo -n " ${i}" >> ${dest} |
790 |
done |
done |
|
echo >> ${dest} |
|
791 |
fi |
fi |
|
echo >> ${dest} |
|
792 |
|
|
793 |
# deps and provides |
# deps and provides |
794 |
echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
|
echo >> ${dest} |
|
795 |
echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
|
echo >> ${dest} |
|
796 |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
|
echo >> ${dest} |
|
797 |
|
|
798 |
# add special functions |
# add special functions |
799 |
if [ -n "${SPECIAL_FUNCTIONS}" ] |
if [ -n "${SPECIAL_FUNCTIONS}" ] |
803 |
do |
do |
804 |
# add to mage (quotes needed !) |
# add to mage (quotes needed !) |
805 |
typeset -f "${i}" >> ${dest} |
typeset -f "${i}" >> ${dest} |
|
echo >> ${dest} |
|
806 |
# unset to be safe (quotes needed !) |
# unset to be safe (quotes needed !) |
807 |
#unset "${i}" <-- later to get every target built |
#unset "${i}" <-- later to get every target built |
808 |
done |
done |
|
echo >> ${dest} |
|
809 |
fi |
fi |
810 |
|
|
811 |
# pre|post-install|removes |
# pre|post-install|removes |
812 |
typeset -f preinstall >> ${dest} |
typeset -f preinstall >> ${dest} |
|
echo >> ${dest} |
|
813 |
typeset -f postinstall >> ${dest} |
typeset -f postinstall >> ${dest} |
|
echo >> ${dest} |
|
814 |
typeset -f preremove >> ${dest} |
typeset -f preremove >> ${dest} |
|
echo >> ${dest} |
|
815 |
typeset -f postremove >> ${dest} |
typeset -f postremove >> ${dest} |
|
echo >> ${dest} |
|
816 |
} |
} |
817 |
|
|
818 |
regen_mage_tree() |
regen_mage_tree() |
823 |
if [[ ${REGEN_MAGE_TREE} = true ]] |
if [[ ${REGEN_MAGE_TREE} = true ]] |
824 |
then |
then |
825 |
# run it without targets |
# run it without targets |
826 |
if [ -z "${MAGE_TARGETS}" ] |
if [[ -n ${MAGE_TARGETS} ]] |
827 |
then |
then |
828 |
|
# build for each target a mage file |
829 |
|
# run it with several targets |
830 |
echo |
echo |
831 |
build_mage_script |
for i in ${MAGE_TARGETS} |
832 |
|
do |
833 |
|
build_mage_script --target "${i}" |
834 |
|
done |
835 |
echo |
echo |
|
else |
|
836 |
|
|
837 |
# build for each target an mage file |
# run it for splitpackages |
838 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
839 |
|
then |
840 |
|
local split_pkg_base="${PNAME}" |
841 |
|
# save smage environment |
842 |
|
split_save_variables |
843 |
|
# build for each subpackage a mage file |
844 |
# run it with several targets |
# run it with several targets |
845 |
for i in ${MAGE_TARGETS} |
echo |
846 |
|
for i in ${SPLIT_PACKAGES} |
847 |
do |
do |
848 |
echo |
# get the right variables for the split |
849 |
build_mage_script "${i}" |
export PNAME="${i}" |
850 |
echo |
split_info_${i} |
851 |
|
build_mage_script --split-pkg-base "${split_pkg_base}" |
852 |
|
# restore smage environment |
853 |
|
split_restore_variables |
854 |
done |
done |
855 |
|
echo |
856 |
|
# unset all saved smage variables |
857 |
|
split_unset_variables |
858 |
|
|
859 |
|
else |
860 |
|
echo |
861 |
|
build_mage_script |
862 |
|
echo |
863 |
fi |
fi |
864 |
fi |
fi |
865 |
|
|
890 |
unset postremove |
unset postremove |
891 |
} |
} |
892 |
|
|
893 |
|
split_save_variables() |
894 |
|
{ |
895 |
|
export SAVED_PNAME="${PNAME}" |
896 |
|
export SAVED_PVER="${PVER}" |
897 |
|
export SAVED_PBUILD="${PBUILD}" |
898 |
|
export SAVED_PCATEGORIE="${PCATEGORIE}" |
899 |
|
export SAVED_DESCRIPTION="${DESCRIPTION}" |
900 |
|
export SAVED_HOMEPAGE="${HOMEPAGE}" |
901 |
|
export SAVED_SPECIAL_VARS="${SPECIAL_VARS}" |
902 |
|
export SAVED_STATE="${STATE}" |
903 |
|
export SAVED_PKGTYPE="${PKGTYPE}" |
904 |
|
export SAVED_INHERITS="${INHERITS}" |
905 |
|
export SAVED_DEPEND="${DEPEND}" |
906 |
|
export SAVED_SDEPEND="${SDEPEND}" |
907 |
|
export SAVED_PROVIDE="${PROVIDE}" |
908 |
|
export SAVED_NOPKGBUILD="${NOPKGBUILD}" |
909 |
|
|
910 |
|
# bindir too |
911 |
|
export SAVED_BINDIR="${BINDIR}" |
912 |
|
|
913 |
|
# export the SPLIT_PACKAGE_BASE |
914 |
|
export SPLIT_PACKAGE_BASE="${SAVED_PNAME}" |
915 |
|
|
916 |
|
# functions |
917 |
|
if [[ ! -z $(typeset -f preinstall) ]] |
918 |
|
then |
919 |
|
# rename the old one |
920 |
|
local saved_preinstall |
921 |
|
saved_preinstall=SAVED_$(typeset -f preinstall) |
922 |
|
eval "${saved_preinstall}" |
923 |
|
export -f SAVED_preinstall |
924 |
|
fi |
925 |
|
|
926 |
|
if [[ ! -z $(typeset -f postinstall) ]] |
927 |
|
then |
928 |
|
# rename the old one |
929 |
|
local saved_postinstall |
930 |
|
saved_postinstall=SAVED_$(typeset -f postinstall) |
931 |
|
eval "${saved_postinstall}" |
932 |
|
export -f SAVED_postinstall |
933 |
|
fi |
934 |
|
|
935 |
|
if [[ ! -z $(typeset -f preremove) ]] |
936 |
|
then |
937 |
|
# rename the old one |
938 |
|
local saved_preremove |
939 |
|
saved_preremove=SAVED_$(typeset -f preremove) |
940 |
|
eval "${saved_preremove}" |
941 |
|
export -f SAVED_preremove |
942 |
|
fi |
943 |
|
|
944 |
|
if [[ ! -z $(typeset -f postremove) ]] |
945 |
|
then |
946 |
|
# rename the old one |
947 |
|
local saved_postremove |
948 |
|
saved_postremove=SAVED_$(typeset -f postremove) |
949 |
|
eval "${saved_postremove}" |
950 |
|
export -f SAVED_postremove |
951 |
|
fi |
952 |
|
} |
953 |
|
|
954 |
|
split_restore_variables() |
955 |
|
{ |
956 |
|
export PNAME="${SAVED_PNAME}" |
957 |
|
export PVER="${SAVED_PVER}" |
958 |
|
export PBUILD="${SAVED_PBUILD}" |
959 |
|
export PCATEGORIE="${SAVED_PCATEGORIE}" |
960 |
|
export DESCRIPTION="${SAVED_DESCRIPTION}" |
961 |
|
export HOMEPAGE="${SAVED_HOMEPAGE}" |
962 |
|
export SPECIAL_VARS="${SAVED_SPECIAL_VARS}" |
963 |
|
export STATE="${SAVED_STATE}" |
964 |
|
export PKGTYPE="${SAVED_PKGTYPE}" |
965 |
|
export INHERITS="${SAVED_INHERITS}" |
966 |
|
export DEPEND="${SAVED_DEPEND}" |
967 |
|
export SDEPEND="${SAVED_SDEPEND}" |
968 |
|
export PROVIDE="${SAVED_PROVIDE}" |
969 |
|
export NOPKGBUILD="${SAVED_NOPKGBUILD}" |
970 |
|
|
971 |
|
# bindir too |
972 |
|
export BINDIR="${SAVED_BINDIR}" |
973 |
|
|
974 |
|
# functions |
975 |
|
if [[ ! -z $(typeset -f SAVED_preinstall) ]] |
976 |
|
then |
977 |
|
# rename the old one |
978 |
|
local saved_preinstall |
979 |
|
saved_preinstall=$(typeset -f SAVED_preinstall) |
980 |
|
eval "${saved_preinstall/SAVED_/}" |
981 |
|
export -f preinstall |
982 |
|
fi |
983 |
|
|
984 |
|
if [[ ! -z $(typeset -f SAVED_postinstall) ]] |
985 |
|
then |
986 |
|
# rename the old one |
987 |
|
local saved_postinstall |
988 |
|
saved_postinstall=$(typeset -f SAVED_postinstall) |
989 |
|
eval "${saved_postinstall/SAVED_/}" |
990 |
|
export -f postinstall |
991 |
|
fi |
992 |
|
|
993 |
|
if [[ ! -z $(typeset -f SAVED_preremove) ]] |
994 |
|
then |
995 |
|
# rename the old one |
996 |
|
local saved_preremove |
997 |
|
saved_preremove=$(typeset -f SAVED_preremove) |
998 |
|
eval "${saved_preremove/SAVED_/}" |
999 |
|
export -f preremove |
1000 |
|
fi |
1001 |
|
|
1002 |
|
if [[ ! -z $(typeset -f SAVED_postremove) ]] |
1003 |
|
then |
1004 |
|
# rename the old one |
1005 |
|
local saved_postremove |
1006 |
|
saved_postremove=$(typeset -f SAVED_postremove) |
1007 |
|
eval "${saved_postremove/SAVED_/}" |
1008 |
|
export -f postremove |
1009 |
|
fi |
1010 |
|
} |
1011 |
|
|
1012 |
|
split_unset_variables() |
1013 |
|
{ |
1014 |
|
# unset saved vars; not needed anymore |
1015 |
|
unset SAVED_PNAME |
1016 |
|
unset SAVED_PVER |
1017 |
|
unset SAVED_PBUILD |
1018 |
|
unset SAVED_PCATEGORIE |
1019 |
|
unset SAVED_DESCRIPTION |
1020 |
|
unset SAVED_HOMEPAGE |
1021 |
|
unset SAVED_SPECIAL_VARS |
1022 |
|
unset SAVED_STATE |
1023 |
|
unset SAVED_PKGTYPE |
1024 |
|
unset SAVED_INHERITS |
1025 |
|
unset SAVED_DEPEND |
1026 |
|
unset SAVED_SDEPEND |
1027 |
|
unset SAVED_PROVIDE |
1028 |
|
unset SAVED_BINDIR |
1029 |
|
unset SAVED_NOPKGBUILD |
1030 |
|
unset SPLIT_PACKAGE_BASE |
1031 |
|
unset -f SAVED_preinstall |
1032 |
|
unset -f SAVED_postinstall |
1033 |
|
unset -f SAVED_preremove |
1034 |
|
unset -f SAVED_postremove |
1035 |
|
} |
1036 |
|
|
1037 |
export_inherits() |
export_inherits() |
1038 |
{ |
{ |
1039 |
local include="$1" |
local include="$1" |
1095 |
# fix target as it may be empty ! |
# fix target as it may be empty ! |
1096 |
[ -n "${target}" ] && target="-${target}" |
[ -n "${target}" ] && target="-${target}" |
1097 |
|
|
1098 |
|
|
1099 |
# build pkgname |
# build pkgname |
1100 |
pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" |
pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" |
1101 |
|
|
1115 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
1116 |
|
|
1117 |
# setup md5 dir |
# setup md5 dir |
1118 |
dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5" |
dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5" |
1119 |
install -d ${dest} |
install -d ${dest} |
1120 |
|
|
1121 |
# gen md5sum |
# gen md5sum |
1157 |
{ |
{ |
1158 |
if [[ ${STEP_BY_STEP} = true ]] |
if [[ ${STEP_BY_STEP} = true ]] |
1159 |
then |
then |
1160 |
echo "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}" |
echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}" |
1161 |
echo "Press [enter] to continue" |
echo "Press [enter] to continue" |
1162 |
read |
read |
1163 |
fi |
fi |
1189 |
# creates md5sums for smages to given dir |
# creates md5sums for smages to given dir |
1190 |
if [[ $1 = calcmd5 ]] |
if [[ $1 = calcmd5 ]] |
1191 |
then |
then |
1192 |
if [ $# -ge 3 ] |
if [ $# -ge 2 ] |
1193 |
then |
then |
1194 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1195 |
MD5DIR="$3" |
MD5DIR="$3" |
1196 |
source ${SMAGENAME} || die "download source failed" |
[[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5" |
1197 |
|
|
1198 |
|
smagesource ${SMAGENAME} || die "download source failed" |
1199 |
|
|
1200 |
# overridable sourcedir; must be declared after source of the smage2 |
# overridable sourcedir; must be declared after source of the smage2 |
1201 |
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
1247 |
echo |
echo |
1248 |
else |
else |
1249 |
echo "Usage: Calculating MD5 Sums:" |
echo "Usage: Calculating MD5 Sums:" |
1250 |
echo " $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR" |
echo " $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]" |
1251 |
echo |
echo |
1252 |
echo |
echo |
1253 |
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
1269 |
# get smage |
# get smage |
1270 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1271 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1272 |
source ${SMAGENAME} || die "download source failed" |
smagesource ${SMAGENAME} || die "download source failed" |
1273 |
|
|
1274 |
download_sources |
download_sources |
1275 |
exit 0 |
exit 0 |
1281 |
# set correct SMAGENAME |
# set correct SMAGENAME |
1282 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1283 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1284 |
source ${SMAGENAME} || die "regen: smage2 not found" |
smagesource ${SMAGENAME} || die "regen: smage2 not found" |
1285 |
|
|
1286 |
regen_mage_tree |
regen_mage_tree |
1287 |
|
|
1288 |
# build md5sum for existing packages |
# build several targets |
1289 |
generate_package_md5sum \ |
if [[ -n ${MAGE_TARGETS} ]] |
1290 |
--pcat "${PCATEGORIE}" \ |
then |
1291 |
--pname "${PNAME}" \ |
for target in ${MAGE_TARGETS} |
1292 |
--pver "${PVER}" \ |
do |
1293 |
--pbuild "${PBUILD}" \ |
# build md5sum for existing packages |
1294 |
--parch "${ARCH}" \ |
generate_package_md5sum \ |
1295 |
--target "${target}" |
--pcat "${PCATEGORIE}" \ |
1296 |
|
--pname "${PNAME}" \ |
1297 |
|
--pver "${PVER}" \ |
1298 |
|
--pbuild "${PBUILD}" \ |
1299 |
|
--parch "${ARCH}" \ |
1300 |
|
--target "${target}" |
1301 |
|
done |
1302 |
|
|
1303 |
|
# build several subpackages |
1304 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
1305 |
|
then |
1306 |
|
split_save_variables |
1307 |
|
for subpackage in ${SPLIT_PACKAGES} |
1308 |
|
do |
1309 |
|
# get the right variables for the split |
1310 |
|
export PNAME="${subpackage}" |
1311 |
|
split_info_${subpackage} |
1312 |
|
# build md5sum for existing packages |
1313 |
|
generate_package_md5sum \ |
1314 |
|
--pcat "${PCATEGORIE}" \ |
1315 |
|
--pname "${PNAME}" \ |
1316 |
|
--pver "${PVER}" \ |
1317 |
|
--pbuild "${PBUILD}" \ |
1318 |
|
--parch "${ARCH}" |
1319 |
|
# restore smage environment |
1320 |
|
split_restore_variables |
1321 |
|
done |
1322 |
|
# unset all saved smage variables |
1323 |
|
split_unset_variables |
1324 |
|
|
1325 |
|
else |
1326 |
|
# build md5sum for existing packages |
1327 |
|
generate_package_md5sum \ |
1328 |
|
--pcat "${PCATEGORIE}" \ |
1329 |
|
--pname "${PNAME}" \ |
1330 |
|
--pver "${PVER}" \ |
1331 |
|
--pbuild "${PBUILD}" \ |
1332 |
|
--parch "${ARCH}" |
1333 |
|
fi |
1334 |
|
|
1335 |
exit 0 |
exit 0 |
1336 |
fi |
fi |
1343 |
|
|
1344 |
echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
1345 |
|
|
1346 |
source ${SMAGENAME} || die "regen: smage2 not found" |
smagesource ${SMAGENAME} || die "regen: smage2 not found" |
1347 |
|
|
1348 |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
1349 |
then |
then |
1392 |
[ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}" |
[ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}" |
1393 |
[ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}" |
[ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}" |
1394 |
|
|
1395 |
source ${SMAGENAME} || die "source failed" |
smagesource ${SMAGENAME} || die "source failed" |
1396 |
PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
1397 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1398 |
|
SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" |
1399 |
|
|
1400 |
xtitle "Compiling ${PKGNAME}" |
xtitle "Compiling ${PKGNAME}" |
1401 |
echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" |
echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" |
1474 |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
1475 |
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
1476 |
|
|
1477 |
src_prepare || die "src_prepare failed" | ${SMAGE_LOG_CMD} |
src_prepare | ${SMAGE_LOG_CMD} |
1478 |
step_by_step $_ |
die_pipestatus 0 "src_prepare failed" |
|
src_compile || die "src_compile failed" | ${SMAGE_LOG_CMD} |
|
|
step_by_step $_ |
|
|
src_install || die "src_install failed" | ${SMAGE_LOG_CMD} |
|
1479 |
step_by_step $_ |
step_by_step $_ |
1480 |
|
|
1481 |
|
src_compile | ${SMAGE_LOG_CMD} |
1482 |
|
die_pipestatus 0 "src_compile failed" |
1483 |
|
step_by_step $_ |
1484 |
|
|
1485 |
# compressing doc, info & man files |
# build several subpackages |
1486 |
if [ -d ${BUILDDIR}/builded/usr/share/man ] |
if [[ -n ${SPLIT_PACKAGES} ]] |
1487 |
then |
then |
1488 |
echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}" |
# save bindir & pname |
1489 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man |
split_save_variables |
1490 |
|
export SAVED_BINDIR="${BINDIR}" |
1491 |
|
for subpackage in ${SPLIT_PACKAGES} |
1492 |
|
do |
1493 |
|
if typeset -f src_install_${subpackage} > /dev/null |
1494 |
|
then |
1495 |
|
# export subpackage bindir |
1496 |
|
export BINDIR="${SAVED_BINDIR}_${subpackage}" |
1497 |
|
# export PNAME, several internal function and include |
1498 |
|
# rely on this variable |
1499 |
|
export PNAME="${subpackage}" |
1500 |
|
|
1501 |
|
echo |
1502 |
|
echo -en "${COLBLUE}*** ${COLDEFAULT}" |
1503 |
|
echo -en " Running ${COLGREEN}split src_install()${COLDEFAULT}" |
1504 |
|
echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}" |
1505 |
|
echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..." |
1506 |
|
|
1507 |
|
src_install_${subpackage} | ${SMAGE_LOG_CMD} |
1508 |
|
die_pipestatus 0 "src_install_${subpackage} failed" |
1509 |
|
step_by_step $_ |
1510 |
|
fi |
1511 |
|
done |
1512 |
|
# restore bindir & pname |
1513 |
|
split_restore_variables |
1514 |
|
# unset all saved smage variables |
1515 |
|
split_unset_variables |
1516 |
|
else |
1517 |
|
src_install | ${SMAGE_LOG_CMD} |
1518 |
|
die_pipestatus 0 "src_install failed" |
1519 |
|
step_by_step $_ |
1520 |
fi |
fi |
1521 |
|
|
1522 |
if [ -d ${BUILDDIR}/builded/usr/share/info ] |
# compressing doc, info & man files |
1523 |
|
if [[ -n ${SPLIT_PACKAGES} ]] |
1524 |
then |
then |
1525 |
echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}" |
for subpackage in ${SPLIT_PACKAGES} |
1526 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info |
do |
1527 |
|
mcompressdocs ${BINDIR}_${subpackage} |
1528 |
|
done |
1529 |
|
else |
1530 |
|
mcompressdocs ${BINDIR} |
1531 |
fi |
fi |
1532 |
|
|
1533 |
|
|
1534 |
# stripping all bins and libs |
# stripping all bins and libs |
1535 |
case ${NOSTRIP} in |
case ${NOSTRIP} in |
1536 |
true|TRUE|yes|y) |
true|TRUE|yes|y) |
1537 |
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
1538 |
;; |
;; |
1539 |
*) |
*) |
1540 |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
if [[ -n ${SPLIT_PACKAGES} ]] |
1541 |
mstripbins ${BINDIR} |
then |
1542 |
echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}" |
for subpackage in ${SPLIT_PACKAGES} |
1543 |
mstriplibs ${BINDIR} |
do |
1544 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" |
1545 |
|
mstripbins ${BINDIR}_${subpackage} |
1546 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping libraries for '${subpackage}' ...${COLDEFAULT}" |
1547 |
|
mstriplibs ${BINDIR}_${subpackage} |
1548 |
|
done |
1549 |
|
else |
1550 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
1551 |
|
mstripbins ${BINDIR} |
1552 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}" |
1553 |
|
mstriplibs ${BINDIR} |
1554 |
|
fi |
1555 |
;; |
;; |
1556 |
esac |
esac |
1557 |
|
|
1562 |
;; |
;; |
1563 |
*) |
*) |
1564 |
# build several targets |
# build several targets |
1565 |
if [ -n "${MAGE_TARGETS}" ] |
if [[ -n ${MAGE_TARGETS} ]] |
1566 |
then |
then |
1567 |
for target in ${MAGE_TARGETS} |
for target in ${MAGE_TARGETS} |
1568 |
do |
do |
1588 |
|
|
1589 |
echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
1590 |
done |
done |
1591 |
|
|
1592 |
|
# build several subpackages |
1593 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
1594 |
|
then |
1595 |
|
split_save_variables |
1596 |
|
for subpackage in ${SPLIT_PACKAGES} |
1597 |
|
do |
1598 |
|
# get the right variables for the split |
1599 |
|
export PNAME="${subpackage}" |
1600 |
|
split_info_${PNAME} |
1601 |
|
|
1602 |
|
# jump to next one if NOPKGBUILD is set in split_info |
1603 |
|
case ${NOPKGBUILD} in |
1604 |
|
true|TRUE|yes|y) continue ;; |
1605 |
|
esac |
1606 |
|
|
1607 |
|
# check if an special subpackage_pkgbuild exists |
1608 |
|
if typeset -f ${PNAME}_pkgbuild > /dev/null |
1609 |
|
then |
1610 |
|
# run it |
1611 |
|
${PNAME}_pkgbuild |
1612 |
|
fi |
1613 |
|
# now create the target package |
1614 |
|
${MLIBDIR}/pkgbuild_dir.sh \ |
1615 |
|
"${PNAME}-${PVER}-${ARCH}-${PBUILD}" \ |
1616 |
|
"${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed" |
1617 |
|
|
1618 |
|
# build pkg-md5-sum if requested |
1619 |
|
generate_package_md5sum \ |
1620 |
|
--pcat "${PCATEGORIE}" \ |
1621 |
|
--pname "${PNAME}" \ |
1622 |
|
--pver "${PVER}" \ |
1623 |
|
--pbuild "${PBUILD}" \ |
1624 |
|
--parch "${ARCH}" |
1625 |
|
|
1626 |
|
echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
1627 |
|
|
1628 |
|
# restore smage environment |
1629 |
|
split_restore_variables |
1630 |
|
done |
1631 |
|
# unset all saved smage variables |
1632 |
|
split_unset_variables |
1633 |
|
|
1634 |
else |
else |
1635 |
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
1636 |
|
|