# 100 - Unknown error (should not happen)
# Notes (todo/bugs):
-# - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
# - when Icon: field is present, -5 and -a5 doesn't work
# - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
# - does not respect NoSource: X, and tries to cvs up such files [ example: VirtualBox-bin.spec and its Source0 ]
# Try `basename --help' for more information.
# -- and the normal usage info --
-
-RCSID='$Id$'
-r=${RCSID#* * }
-rev=${r%% *}
+PROGRAM=${0##*/}
+APPDIR=$(d=$0; [ -L "$d" ] && d=$(readlink -f "$d"); dirname "$d")
+RCSID='$Id$' r=${RCSID#* * } rev=${r%% *}
VERSION="v0.35/$rev"
VERSIONSTRING="\
Build package utility from PLD Linux CVS repository
RPMBUILD="rpmbuild"
fi
+#
+# sanity checks
+#
+if [ -d $HOME/rpm/SOURCES ]; then
+ echo "ERROR: ~/rpm/{SPECS,SOURCES} structure is obsolete" >&2
+ echo "ERROR: get rid of your ~/rpm/SOURCES" >&2
+ exit 1
+fi
+
#
# are we using cvs-nserver ?
#
%x8664 x86_64 amd64 ia32e
%alt_kernel %{nil}
%_alt_kernel %{nil}
+%bootstrap_release() %{1}
%requires_releq_kernel_up(s:n:) %{nil}
%requires_releq_kernel_smp(s:n:) %{nil}
%requires_releq_kernel(s:n:) %{nil}
%pyrequires_eq() %{nil}
%requires_eq() %{nil}
%requires_eq_to() %{nil}
+%requires_ge() %{nil}
%releq_kernel_up(n:) ERROR
%releq_kernel_smp(n:) ERROR
%releq_kernel(n:) ERROR
%remove_etc_shells(p) %{p:<lua>}
%lua_add_etc_shells() %{nil}
%lua_remove_etc_shells() %{nil}
+%required_jdk %{nil}
+%buildrequires_jdk %{nil}
EOF
if [ "$NOINIT" = "yes" ] ; then
cat >> $BUILDER_MACROS <<'EOF'
get_icons() {
update_shell_title "get icons"
- ICONS=$(awk '/^Icon:/ {print $2}' ${ASSUMED_NAME}/${SPECFILE})
+ ICONS=$(awk '/^Icon:/ {print $2}' $PACKAGE_DIR/${SPECFILE})
if [ -z "$ICONS" ]; then
return
fi
# create symlinks for tools
if [ "$SYMLINK_TOOLS" != "no" ]; then
- for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh; do
+ for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh pldnotify.awk; do
[ -f $a ] || continue
ln -s ../$a $ASSUMED_NAME
cvsignore_df $a
fi
}
-build_package() {
- update_shell_title "build_package"
- if [ -n "$DEBUG" ]; then
- set -x
- set -v
- fi
+# from relup.sh
+set_release() {
+ local specfile="$1"
+ local rel="$2"
+ local newrel="$3"
+ sed -i -e "
+ s/^\(%define[ \t]\+_\?rel[ \t]\+\)$rel\$/\1$newrel/
+ s/^\(Release:[ \t]\+\)$rel\$/\1$newrel/
+ " $specfile
+}
- cd "$PACKAGE_DIR"
+set_version() {
+ local specfile="$1"
+ local ver="$2"
+ local newver="$3"
+ sed -i -e "
+ s/^\(%define[ \t]\+_\?ver[ \t]\+\)$ver\$/\1$newver/
+ s/^\(Version:[ \t]\+\)$ver\$/\1$newver/
+ " $specfile
+}
+try_upgrade() {
if [ -n "$TRY_UPGRADE" ]; then
+ local TNOTIFY TNEWVER TOLDVER
update_shell_title "build_package: try_upgrade"
+
+ cd "$PACKAGE_DIR"
+
if [ -n "$FLOAT_VERSION" ]; then
- TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
+ TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
else
- TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
+ TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
fi
TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
if [ -n "$TNEWVER" ]; then
TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
- echo "New version found, updating spec file to version " $TNEWVER
+ echo "New version found, updating spec file from $TOLDVER to version $TNEWVER"
if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
cp -f $SPECFILE $SPECFILE.bak
fi
chmod +w $SPECFILE
- eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
- eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
+ set_release $SPECFILE $PACKAGE_RELEASE 1
+ set_version $SPECFILE $PACKAGE_VERSION $TNEWVER
parse_spec
- NODIST="yes" get_files $SOURCES $PATCHES
- update_md5 $SOURCES
-
- unset TOLDVER TNEWVER TNOTIFY
+ return 1
fi
fi
+ return 0
+}
+
+build_package() {
+ update_shell_title "build_package"
+ if [ -n "$DEBUG" ]; then
+ set -x
+ set -v
+ fi
+
cd "$PACKAGE_DIR"
case "$COMMAND" in
fi
if [ "$RETVAL" -ne "0" ]; then
if [ -n "$TRY_UPGRADE" ]; then
- echo "\n!!! Package with new version cannot be built automagically\n"
+ echo "\nUpgrade package to new version failed."
if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
+ echo "Restoring old spec file."
mv -f $SPECFILE.bak $SPECFILE
fi
+ echo ""
fi
Exit_error err_build_fail
fi
if [ -n "$NOSOURCE0" ] ; then
SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
fi
- get_files $SOURCES $PATCHES
- check_md5 $SOURCES
+ try_upgrade
+ case $? in
+ 0)
+ get_files $SOURCES $PATCHES
+ check_md5 $SOURCES
+ ;;
+ *)
+ NODIST="yes" get_files $SOURCES $PATCHES
+ update_md5 $SOURCES
+ ;;
+ esac
build_package
if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz