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} ]] |
74 |
exit 1 |
exit 1 |
75 |
} |
} |
76 |
|
|
77 |
|
die_pipestatus() |
78 |
|
{ |
79 |
|
# the status change if we do any parameter declarations!! |
80 |
|
# dont do this anymore, keep this in mind! |
81 |
|
# |
82 |
|
# local pos="$1" |
83 |
|
# local comment="$2" |
84 |
|
# |
85 |
|
# [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}" |
86 |
|
# |
87 |
|
[ ${PIPESTATUS[$1]} -ne 0 ] && die "$2" |
88 |
|
} |
89 |
|
|
90 |
xtitle() |
xtitle() |
91 |
{ |
{ |
92 |
if [[ ${TERM} = xterm ]] |
if [[ ${TERM} = xterm ]] |
154 |
local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
155 |
local FETCHING |
local FETCHING |
156 |
local i mirror |
local i mirror |
157 |
|
local wget_opts |
158 |
|
|
159 |
|
# filter wget command if busybox was found |
160 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
161 |
|
|
162 |
# install SRCDIR/PNAME if not exist |
# install SRCDIR/PNAME if not exist |
163 |
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
164 |
|
|
165 |
# check if FETCHING is needed |
# check if FETCHING is needed |
166 |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null ) |
( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} &> /dev/null ) |
167 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
168 |
then |
then |
169 |
# md5's ok, no fetching needed |
# md5's ok, no fetching needed |
188 |
my_SOURCEDIR="${SOURCEDIR}/${PNAME}" |
my_SOURCEDIR="${SOURCEDIR}/${PNAME}" |
189 |
fi |
fi |
190 |
|
|
191 |
|
# create the SOURCEDIR |
192 |
|
install -d ${my_SOURCEDIR} |
193 |
|
|
194 |
# if an mirrored file than replace first the mirror uri |
# if an mirrored file than replace first the mirror uri |
195 |
if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]] |
if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]] |
196 |
then |
then |
202 |
then |
then |
203 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
204 |
wget \ |
wget \ |
205 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
206 |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
207 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
208 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
223 |
then |
then |
224 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
225 |
wget \ |
wget \ |
226 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
227 |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
228 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
229 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
244 |
then |
then |
245 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
246 |
wget \ |
wget \ |
247 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
248 |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
249 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
250 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
265 |
then |
then |
266 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
267 |
wget \ |
wget \ |
268 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
269 |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
270 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
271 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
286 |
then |
then |
287 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
288 |
wget \ |
wget \ |
289 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
290 |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
291 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
292 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
302 |
then |
then |
303 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}" |
304 |
wget \ |
wget \ |
305 |
--passive-ftp \ |
${wget_opts} \ |
|
--tries 3 \ |
|
|
--continue \ |
|
|
--progress bar \ |
|
306 |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \ |
307 |
"${my_SRC_URI}" |
"${my_SRC_URI}" |
308 |
fi |
fi |
318 |
# recheck md5 sums |
# recheck md5 sums |
319 |
echo |
echo |
320 |
echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}" |
321 |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
322 |
echo |
echo |
323 |
|
|
324 |
# not needed anymore |
# not needed anymore |
516 |
install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." |
install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." |
517 |
fi |
fi |
518 |
|
|
519 |
|
local i |
520 |
for i in ${docfiles} |
for i in ${docfiles} |
521 |
do |
do |
522 |
cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs." |
if [ -f ${i} ] |
523 |
install -m 0644 ${SRCDIR}/${i}.gz \ |
then |
524 |
${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs." |
cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs." |
525 |
|
install -m 0644 ${SRCDIR}/${i}.gz \ |
526 |
|
${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs." |
527 |
|
fi |
528 |
done |
done |
529 |
} |
} |
530 |
|
|
544 |
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 |
545 |
} |
} |
546 |
|
|
547 |
|
mcompressdocs() |
548 |
|
{ |
549 |
|
local bindir="$@" |
550 |
|
|
551 |
|
if [ -d ${bindir}/usr/share/man ] |
552 |
|
then |
553 |
|
echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}" |
554 |
|
${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man |
555 |
|
fi |
556 |
|
|
557 |
|
if [ -d ${bindir}/usr/share/info ] |
558 |
|
then |
559 |
|
echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}" |
560 |
|
${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info |
561 |
|
fi |
562 |
|
} |
563 |
|
|
564 |
sminclude() |
sminclude() |
565 |
{ |
{ |
566 |
local i |
local i |
676 |
# INHERITS which functions get included |
# INHERITS which functions get included |
677 |
# SPECIAL_FUNCTIONS special functions which should also be added |
# SPECIAL_FUNCTIONS special functions which should also be added |
678 |
# warning: they get killed before the build starts ! |
# warning: they get killed before the build starts ! |
679 |
|
# SPLIT_PACKAGES names of all subpackages which are splitted from parent |
680 |
|
# SPLIT_PACKAGE_BASE base package name for splitpackages |
681 |
|
# (only in the resulting magefile} |
682 |
# |
# |
683 |
# MAGE_TREE_DEST target destination of the generated tree |
# MAGE_TREE_DEST target destination of the generated tree |
684 |
# REGEN_MAGE_TREE set to 'true' to enable this |
# REGEN_MAGE_TREE set to 'true' to enable this |
689 |
local magefile |
local magefile |
690 |
local dest |
local dest |
691 |
local target |
local target |
692 |
|
local split_pkg_base |
693 |
local sym |
local sym |
694 |
local depname |
local depname |
695 |
|
|
697 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
698 |
|
|
699 |
# determinate which suffix this mage file should get, if any |
# determinate which suffix this mage file should get, if any |
700 |
[ -n "$1" ] && target="-$1" |
[[ $1 = --target ]] && shift && target="-$1" |
701 |
|
|
702 |
|
# mark package as splitpackage |
703 |
|
[[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1" |
704 |
|
|
705 |
# name of magefile |
# name of magefile |
706 |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
737 |
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
738 |
echo >> ${dest} |
echo >> ${dest} |
739 |
|
|
740 |
|
# split package base |
741 |
|
echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest} |
742 |
|
echo >> ${dest} |
743 |
|
|
744 |
# add special vars |
# add special vars |
745 |
if [ -n "${SPECIAL_VARS}" ] |
if [ -n "${SPECIAL_VARS}" ] |
746 |
then |
then |
808 |
if [[ ${REGEN_MAGE_TREE} = true ]] |
if [[ ${REGEN_MAGE_TREE} = true ]] |
809 |
then |
then |
810 |
# run it without targets |
# run it without targets |
811 |
if [ -z "${MAGE_TARGETS}" ] |
if [[ -n ${MAGE_TARGETS} ]] |
812 |
then |
then |
813 |
|
# build for each target a mage file |
814 |
|
# run it with several targets |
815 |
echo |
echo |
816 |
build_mage_script |
for i in ${MAGE_TARGETS} |
817 |
|
do |
818 |
|
build_mage_script --target "${i}" |
819 |
|
done |
820 |
echo |
echo |
|
else |
|
821 |
|
|
822 |
# build for each target an mage file |
# run it for splitpackages |
823 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
824 |
|
then |
825 |
|
local split_pkg_base="${PNAME}" |
826 |
|
# save smage environment |
827 |
|
split_save_variables |
828 |
|
# build for each subpackage a mage file |
829 |
# run it with several targets |
# run it with several targets |
830 |
for i in ${MAGE_TARGETS} |
echo |
831 |
|
for i in ${SPLIT_PACKAGES} |
832 |
do |
do |
833 |
echo |
# get the right variables for the split |
834 |
build_mage_script "${i}" |
export PNAME="${i}" |
835 |
echo |
split_info_${i} |
836 |
|
build_mage_script --split-pkg-base "${split_pkg_base}" |
837 |
|
# restore smage environment |
838 |
|
split_restore_variables |
839 |
done |
done |
840 |
|
echo |
841 |
|
# unset all saved smage variables |
842 |
|
split_unset_variables |
843 |
|
|
844 |
|
else |
845 |
|
echo |
846 |
|
build_mage_script |
847 |
|
echo |
848 |
fi |
fi |
849 |
fi |
fi |
850 |
|
|
875 |
unset postremove |
unset postremove |
876 |
} |
} |
877 |
|
|
878 |
|
split_save_variables() |
879 |
|
{ |
880 |
|
export SAVED_PNAME="${PNAME}" |
881 |
|
export SAVED_PVER="${PVER}" |
882 |
|
export SAVED_PBUILD="${PBUILD}" |
883 |
|
export SAVED_PCATEGORIE="${PCATEGORIE}" |
884 |
|
export SAVED_DESCRIPTION="${DESCRIPTION}" |
885 |
|
export SAVED_HOMEPAGE="${HOMEPAGE}" |
886 |
|
export SAVED_SPECIAL_VARS="${SPECIAL_VARS}" |
887 |
|
export SAVED_STATE="${STATE}" |
888 |
|
export SAVED_PKGTYPE="${PKGTYPE}" |
889 |
|
export SAVED_INHERITS="${INHERITS}" |
890 |
|
export SAVED_DEPEND="${DEPEND}" |
891 |
|
export SAVED_SDEPEND="${SDEPEND}" |
892 |
|
export SAVED_PROVIDE="${PROVIDE}" |
893 |
|
export SAVED_NOPKGBUILD="${NOPKGBUILD}" |
894 |
|
|
895 |
|
# bindir too |
896 |
|
export SAVED_BINDIR="${BINDIR}" |
897 |
|
|
898 |
|
# export the SPLIT_PACKAGE_BASE |
899 |
|
export SPLIT_PACKAGE_BASE="${SAVED_PNAME}" |
900 |
|
|
901 |
|
# functions |
902 |
|
if [[ ! -z $(typeset -f preinstall) ]] |
903 |
|
then |
904 |
|
# rename the old one |
905 |
|
local saved_preinstall |
906 |
|
saved_preinstall=SAVED_$(typeset -f preinstall) |
907 |
|
eval "${saved_preinstall}" |
908 |
|
export -f SAVED_preinstall |
909 |
|
fi |
910 |
|
|
911 |
|
if [[ ! -z $(typeset -f postinstall) ]] |
912 |
|
then |
913 |
|
# rename the old one |
914 |
|
local saved_postinstall |
915 |
|
saved_postinstall=SAVED_$(typeset -f postinstall) |
916 |
|
eval "${saved_postinstall}" |
917 |
|
export -f SAVED_postinstall |
918 |
|
fi |
919 |
|
|
920 |
|
if [[ ! -z $(typeset -f preremove) ]] |
921 |
|
then |
922 |
|
# rename the old one |
923 |
|
local saved_preremove |
924 |
|
saved_preremove=SAVED_$(typeset -f preremove) |
925 |
|
eval "${saved_preremove}" |
926 |
|
export -f SAVED_preremove |
927 |
|
fi |
928 |
|
|
929 |
|
if [[ ! -z $(typeset -f postremove) ]] |
930 |
|
then |
931 |
|
# rename the old one |
932 |
|
local saved_postremove |
933 |
|
saved_postremove=SAVED_$(typeset -f postremove) |
934 |
|
eval "${saved_postremove}" |
935 |
|
export -f SAVED_postremove |
936 |
|
fi |
937 |
|
} |
938 |
|
|
939 |
|
split_restore_variables() |
940 |
|
{ |
941 |
|
export PNAME="${SAVED_PNAME}" |
942 |
|
export PVER="${SAVED_PVER}" |
943 |
|
export PBUILD="${SAVED_PBUILD}" |
944 |
|
export PCATEGORIE="${SAVED_PCATEGORIE}" |
945 |
|
export DESCRIPTION="${SAVED_DESCRIPTION}" |
946 |
|
export HOMEPAGE="${SAVED_HOMEPAGE}" |
947 |
|
export SPECIAL_VARS="${SAVED_SPECIAL_VARS}" |
948 |
|
export STATE="${SAVED_STATE}" |
949 |
|
export PKGTYPE="${SAVED_PKGTYPE}" |
950 |
|
export INHERITS="${SAVED_INHERITS}" |
951 |
|
export DEPEND="${SAVED_DEPEND}" |
952 |
|
export SDEPEND="${SAVED_SDEPEND}" |
953 |
|
export PROVIDE="${SAVED_PROVIDE}" |
954 |
|
export NOPKGBUILD="${SAVED_NOPKGBUILD}" |
955 |
|
|
956 |
|
# bindir too |
957 |
|
export BINDIR="${SAVED_BINDIR}" |
958 |
|
|
959 |
|
# functions |
960 |
|
if [[ ! -z $(typeset -f SAVED_preinstall) ]] |
961 |
|
then |
962 |
|
# rename the old one |
963 |
|
local saved_preinstall |
964 |
|
saved_preinstall=$(typeset -f SAVED_preinstall) |
965 |
|
eval "${saved_preinstall/SAVED_/}" |
966 |
|
export -f preinstall |
967 |
|
fi |
968 |
|
|
969 |
|
if [[ ! -z $(typeset -f SAVED_postinstall) ]] |
970 |
|
then |
971 |
|
# rename the old one |
972 |
|
local saved_postinstall |
973 |
|
saved_postinstall=$(typeset -f SAVED_postinstall) |
974 |
|
eval "${saved_postinstall/SAVED_/}" |
975 |
|
export -f postinstall |
976 |
|
fi |
977 |
|
|
978 |
|
if [[ ! -z $(typeset -f SAVED_preremove) ]] |
979 |
|
then |
980 |
|
# rename the old one |
981 |
|
local saved_preremove |
982 |
|
saved_preremove=$(typeset -f SAVED_preremove) |
983 |
|
eval "${saved_preremove/SAVED_/}" |
984 |
|
export -f preremove |
985 |
|
fi |
986 |
|
|
987 |
|
if [[ ! -z $(typeset -f SAVED_postremove) ]] |
988 |
|
then |
989 |
|
# rename the old one |
990 |
|
local saved_postremove |
991 |
|
saved_postremove=$(typeset -f SAVED_postremove) |
992 |
|
eval "${saved_postremove/SAVED_/}" |
993 |
|
export -f postremove |
994 |
|
fi |
995 |
|
} |
996 |
|
|
997 |
|
split_unset_variables() |
998 |
|
{ |
999 |
|
# unset saved vars; not needed anymore |
1000 |
|
unset SAVED_PNAME |
1001 |
|
unset SAVED_PVER |
1002 |
|
unset SAVED_PBUILD |
1003 |
|
unset SAVED_PCATEGORIE |
1004 |
|
unset SAVED_DESCRIPTION |
1005 |
|
unset SAVED_HOMEPAGE |
1006 |
|
unset SAVED_SPECIAL_VARS |
1007 |
|
unset SAVED_STATE |
1008 |
|
unset SAVED_PKGTYPE |
1009 |
|
unset SAVED_INHERITS |
1010 |
|
unset SAVED_DEPEND |
1011 |
|
unset SAVED_SDEPEND |
1012 |
|
unset SAVED_PROVIDE |
1013 |
|
unset SAVED_BINDIR |
1014 |
|
unset SAVED_NOPKGBUILD |
1015 |
|
unset SPLIT_PACKAGE_BASE |
1016 |
|
unset -f SAVED_preinstall |
1017 |
|
unset -f SAVED_postinstall |
1018 |
|
unset -f SAVED_preremove |
1019 |
|
unset -f SAVED_postremove |
1020 |
|
} |
1021 |
|
|
1022 |
export_inherits() |
export_inherits() |
1023 |
{ |
{ |
1024 |
local include="$1" |
local include="$1" |
1080 |
# fix target as it may be empty ! |
# fix target as it may be empty ! |
1081 |
[ -n "${target}" ] && target="-${target}" |
[ -n "${target}" ] && target="-${target}" |
1082 |
|
|
1083 |
|
|
1084 |
# build pkgname |
# build pkgname |
1085 |
pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" |
pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" |
1086 |
|
|
1100 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
1101 |
|
|
1102 |
# setup md5 dir |
# setup md5 dir |
1103 |
dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5" |
dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5" |
1104 |
install -d ${dest} |
install -d ${dest} |
1105 |
|
|
1106 |
# gen md5sum |
# gen md5sum |
1142 |
{ |
{ |
1143 |
if [[ ${STEP_BY_STEP} = true ]] |
if [[ ${STEP_BY_STEP} = true ]] |
1144 |
then |
then |
1145 |
echo "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}" |
echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}" |
1146 |
echo "Press [enter] to continue" |
echo "Press [enter] to continue" |
1147 |
read |
read |
1148 |
fi |
fi |
1174 |
# creates md5sums for smages to given dir |
# creates md5sums for smages to given dir |
1175 |
if [[ $1 = calcmd5 ]] |
if [[ $1 = calcmd5 ]] |
1176 |
then |
then |
1177 |
if [ $# -ge 3 ] |
if [ $# -ge 2 ] |
1178 |
then |
then |
1179 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1180 |
MD5DIR="$3" |
MD5DIR="$3" |
1181 |
|
[[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5" |
1182 |
|
|
1183 |
source ${SMAGENAME} || die "download source failed" |
source ${SMAGENAME} || die "download source failed" |
1184 |
|
|
1185 |
# overridable sourcedir; must be declared after source of the smage2 |
# overridable sourcedir; must be declared after source of the smage2 |
1232 |
echo |
echo |
1233 |
else |
else |
1234 |
echo "Usage: Calculating MD5 Sums:" |
echo "Usage: Calculating MD5 Sums:" |
1235 |
echo " $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR" |
echo " $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]" |
1236 |
echo |
echo |
1237 |
echo |
echo |
1238 |
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
1270 |
|
|
1271 |
regen_mage_tree |
regen_mage_tree |
1272 |
|
|
1273 |
# build md5sum for existing packages |
# build several targets |
1274 |
generate_package_md5sum \ |
if [[ -n ${MAGE_TARGETS} ]] |
1275 |
--pcat "${PCATEGORIE}" \ |
then |
1276 |
--pname "${PNAME}" \ |
for target in ${MAGE_TARGETS} |
1277 |
--pver "${PVER}" \ |
do |
1278 |
--pbuild "${PBUILD}" \ |
# build md5sum for existing packages |
1279 |
--parch "${ARCH}" \ |
generate_package_md5sum \ |
1280 |
--target "${target}" |
--pcat "${PCATEGORIE}" \ |
1281 |
|
--pname "${PNAME}" \ |
1282 |
|
--pver "${PVER}" \ |
1283 |
|
--pbuild "${PBUILD}" \ |
1284 |
|
--parch "${ARCH}" \ |
1285 |
|
--target "${target}" |
1286 |
|
done |
1287 |
|
|
1288 |
|
# build several subpackages |
1289 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
1290 |
|
then |
1291 |
|
split_save_variables |
1292 |
|
for subpackage in ${SPLIT_PACKAGES} |
1293 |
|
do |
1294 |
|
# get the right variables for the split |
1295 |
|
export PNAME="${subpackage}" |
1296 |
|
split_info_${subpackage} |
1297 |
|
# build md5sum for existing packages |
1298 |
|
generate_package_md5sum \ |
1299 |
|
--pcat "${PCATEGORIE}" \ |
1300 |
|
--pname "${PNAME}" \ |
1301 |
|
--pver "${PVER}" \ |
1302 |
|
--pbuild "${PBUILD}" \ |
1303 |
|
--parch "${ARCH}" |
1304 |
|
# restore smage environment |
1305 |
|
split_restore_variables |
1306 |
|
done |
1307 |
|
# unset all saved smage variables |
1308 |
|
split_unset_variables |
1309 |
|
|
1310 |
|
else |
1311 |
|
# build md5sum for existing packages |
1312 |
|
generate_package_md5sum \ |
1313 |
|
--pcat "${PCATEGORIE}" \ |
1314 |
|
--pname "${PNAME}" \ |
1315 |
|
--pver "${PVER}" \ |
1316 |
|
--pbuild "${PBUILD}" \ |
1317 |
|
--parch "${ARCH}" |
1318 |
|
fi |
1319 |
|
|
1320 |
exit 0 |
exit 0 |
1321 |
fi |
fi |
1380 |
source ${SMAGENAME} || die "source failed" |
source ${SMAGENAME} || die "source failed" |
1381 |
PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
1382 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1383 |
|
SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" |
1384 |
|
|
1385 |
xtitle "Compiling ${PKGNAME}" |
xtitle "Compiling ${PKGNAME}" |
1386 |
echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" |
echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" |
1459 |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
1460 |
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
1461 |
|
|
1462 |
src_prepare || die "src_prepare failed" | ${SMAGE_LOG_CMD} |
src_prepare | ${SMAGE_LOG_CMD} |
1463 |
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} |
|
1464 |
step_by_step $_ |
step_by_step $_ |
1465 |
|
|
1466 |
|
src_compile | ${SMAGE_LOG_CMD} |
1467 |
|
die_pipestatus 0 "src_compile failed" |
1468 |
|
step_by_step $_ |
1469 |
|
|
1470 |
# compressing doc, info & man files |
# build several subpackages |
1471 |
if [ -d ${BUILDDIR}/builded/usr/share/man ] |
if [[ -n ${SPLIT_PACKAGES} ]] |
1472 |
then |
then |
1473 |
echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}" |
# save bindir & pname |
1474 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man |
split_save_variables |
1475 |
|
export SAVED_BINDIR="${BINDIR}" |
1476 |
|
for subpackage in ${SPLIT_PACKAGES} |
1477 |
|
do |
1478 |
|
if typeset -f src_install_${subpackage} > /dev/null |
1479 |
|
then |
1480 |
|
# export subpackage bindir |
1481 |
|
export BINDIR="${SAVED_BINDIR}_${subpackage}" |
1482 |
|
# export PNAME, several internal function and include |
1483 |
|
# rely on this variable |
1484 |
|
export PNAME="${subpackage}" |
1485 |
|
|
1486 |
|
echo |
1487 |
|
echo -en "${COLBLUE}*** ${COLDEFAULT}" |
1488 |
|
echo -en " Running ${COLGREEN}split src_install()${COLDEFAULT}" |
1489 |
|
echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}" |
1490 |
|
echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..." |
1491 |
|
|
1492 |
|
src_install_${subpackage} | ${SMAGE_LOG_CMD} |
1493 |
|
die_pipestatus 0 "src_install_${subpackage} failed" |
1494 |
|
step_by_step $_ |
1495 |
|
fi |
1496 |
|
done |
1497 |
|
# restore bindir & pname |
1498 |
|
split_restore_variables |
1499 |
|
# unset all saved smage variables |
1500 |
|
split_unset_variables |
1501 |
|
else |
1502 |
|
src_install | ${SMAGE_LOG_CMD} |
1503 |
|
die_pipestatus 0 "src_install failed" |
1504 |
|
step_by_step $_ |
1505 |
fi |
fi |
1506 |
|
|
1507 |
if [ -d ${BUILDDIR}/builded/usr/share/info ] |
# compressing doc, info & man files |
1508 |
|
if [[ -n ${SPLIT_PACKAGES} ]] |
1509 |
then |
then |
1510 |
echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}" |
for subpackage in ${SPLIT_PACKAGES} |
1511 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info |
do |
1512 |
|
mcompressdocs ${BINDIR}_${subpackage} |
1513 |
|
done |
1514 |
|
else |
1515 |
|
mcompressdocs ${BINDIR} |
1516 |
fi |
fi |
1517 |
|
|
1518 |
|
|
1519 |
# stripping all bins and libs |
# stripping all bins and libs |
1520 |
case ${NOSTRIP} in |
case ${NOSTRIP} in |
1521 |
true|TRUE|yes|y) |
true|TRUE|yes|y) |
1522 |
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
1523 |
;; |
;; |
1524 |
*) |
*) |
1525 |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
if [[ -n ${SPLIT_PACKAGES} ]] |
1526 |
mstripbins ${BINDIR} |
then |
1527 |
echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}" |
for subpackage in ${SPLIT_PACKAGES} |
1528 |
mstriplibs ${BINDIR} |
do |
1529 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" |
1530 |
|
mstripbins ${BINDIR}_${subpackage} |
1531 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping libraries for '${subpackage}' ...${COLDEFAULT}" |
1532 |
|
mstriplibs ${BINDIR}_${subpackage} |
1533 |
|
done |
1534 |
|
else |
1535 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
1536 |
|
mstripbins ${BINDIR} |
1537 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}" |
1538 |
|
mstriplibs ${BINDIR} |
1539 |
|
fi |
1540 |
;; |
;; |
1541 |
esac |
esac |
1542 |
|
|
1547 |
;; |
;; |
1548 |
*) |
*) |
1549 |
# build several targets |
# build several targets |
1550 |
if [ -n "${MAGE_TARGETS}" ] |
if [[ -n ${MAGE_TARGETS} ]] |
1551 |
then |
then |
1552 |
for target in ${MAGE_TARGETS} |
for target in ${MAGE_TARGETS} |
1553 |
do |
do |
1573 |
|
|
1574 |
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}" |
1575 |
done |
done |
1576 |
|
|
1577 |
|
# build several subpackages |
1578 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
1579 |
|
then |
1580 |
|
split_save_variables |
1581 |
|
for subpackage in ${SPLIT_PACKAGES} |
1582 |
|
do |
1583 |
|
# get the right variables for the split |
1584 |
|
export PNAME="${subpackage}" |
1585 |
|
split_info_${PNAME} |
1586 |
|
|
1587 |
|
# jump to next one if NOPKGBUILD is set in split_info |
1588 |
|
case ${NOPKGBUILD} in |
1589 |
|
true|TRUE|yes|y) continue ;; |
1590 |
|
esac |
1591 |
|
|
1592 |
|
# check if an special subpackage_pkgbuild exists |
1593 |
|
if typeset -f ${PNAME}_pkgbuild > /dev/null |
1594 |
|
then |
1595 |
|
# run it |
1596 |
|
${PNAME}_pkgbuild |
1597 |
|
fi |
1598 |
|
# now create the target package |
1599 |
|
${MLIBDIR}/pkgbuild_dir.sh \ |
1600 |
|
"${PNAME}-${PVER}-${ARCH}-${PBUILD}" \ |
1601 |
|
"${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed" |
1602 |
|
|
1603 |
|
# build pkg-md5-sum if requested |
1604 |
|
generate_package_md5sum \ |
1605 |
|
--pcat "${PCATEGORIE}" \ |
1606 |
|
--pname "${PNAME}" \ |
1607 |
|
--pver "${PVER}" \ |
1608 |
|
--pbuild "${PBUILD}" \ |
1609 |
|
--parch "${ARCH}" |
1610 |
|
|
1611 |
|
echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
1612 |
|
|
1613 |
|
# restore smage environment |
1614 |
|
split_restore_variables |
1615 |
|
done |
1616 |
|
# unset all saved smage variables |
1617 |
|
split_unset_variables |
1618 |
|
|
1619 |
else |
else |
1620 |
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
1621 |
|
|