webbuild-cgi, webbuild-functions-private: support for "no prep" with checkbox

webbuild-sudo: parse %setup macro to retrieve build dir with rpm 5.20
This commit is contained in:
Silvan Calarco 2025-01-05 10:29:50 +01:00
parent 3a0c8532e0
commit 95ea4067be
3 changed files with 23 additions and 11 deletions

View File

@ -1292,7 +1292,8 @@ if [ "$MAINTAINERMODE" != "true" ]; then
done
echo -n "</select>"
echo -n "&nbsp;<label style=\"background-color:red;padding:1px;\"><input type=checkbox id=\"rpmforce\" value=\"force\">force&nbsp;</label>"
echo -n "&nbsp;<label style=\"padding:1px;\"><input type=checkbox id=\"debug\" value=\"debug\">debug&nbsp;</label>"
echo -n "&nbsp;<label style=\"padding:1px;\"><input type=checkbox id=\"noprep\" value=\"noprep\">no prep</label>"
echo -n "&nbsp;<label style=\"padding:1px;\"><input type=checkbox id=\"debug\" value=\"debug\">debug</label>"
# destination repository select
echo -n "<br>Send to:"
echo -n "<select id=sendrepository>"
@ -1423,6 +1424,7 @@ if [ "$MAINTAINERMODE" != "true" ]; then
echo -n "<input type=button value=\"build\" onclick="
echo -n "p=getCheckedValuesByName('autodistpkgscheckbox');ajax_getvalues(\""
echo -n "AUTODISTFORCE=\"+getElementById('rpmforce').checked+\"&"
echo -n "AUTODISTNOPREP=\"+getElementById('noprep').checked+\"&"
echo -n "AUTODISTARCH=\"+getSelectedValueById('rpmbuildarch')+\"&"
echo -n "AUTODISTJOB=\"+getSelectedValueById('autodistjobs')+\"&"
echo -n "AUTODISTPKGS=\"+encodeURIComponent(p)+\"&"
@ -1490,6 +1492,7 @@ if [ "$MAINTAINERMODE" != "true" ]; then
echo -n "p=getSelectedValueById('sendrepository');"
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&"
echo -n "AUTODISTFORCE=\"+getElementById('rpmforce').checked+\"&"
echo -n "AUTODISTNOPREP=\"+getElementById('noprep').checked+\"&"
echo -n "SENDREPOSITORY=\"+p+\"&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&"
echo -n "PACKAGE=$PACKAGEENCODED&REQUEST=autoportnp\""
@ -1729,6 +1732,7 @@ case $REQUEST in
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"unscheduled autodist job <b>$AUTODISTJOB</b>\" STIME=`date +%s`"
fi ;;
"autodistbuild") [ "$AUTODISTFORCE" = "true" ] && AUTODISTADD="--force" || AUTODISTADD=
[ "$AUTODISTNOPREP" = "true" ] && AUTOSPEC="--noprep" || AUTOSPECADD=
autodistjobs=
if [ "$AUTODISTPKGS" ]; then
for p in $AUTODISTPKGS; do
@ -1737,7 +1741,7 @@ case $REQUEST in
else
autodistjobs="$AUTODISTJOB"
fi
$SUDO_WRAPPER background $ENVIRONMENT "$USER" "$PACKAGE" "autodist -v -b $autodistjobs --repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]} --arch $AUTODISTARCH --user $USER $AUTODISTADD -- --colors web" &>/dev/null
$SUDO_WRAPPER background $ENVIRONMENT "$USER" "$PACKAGE" "autodist -v -b $autodistjobs --repository ${AUTOPORT_BASE_REPOSITORY[$ENVIRONMENT]} --arch $AUTODISTARCH --user $USER $AUTODISTADD -- $AUTOSPECADD --colors web" &>/dev/null
[ $? -ne 0 ] && RET=$? || {
RET=-1
echo "Autodist build start. You may see the output in the <b>Webbuild jobs</b> box above."
@ -1803,10 +1807,12 @@ case $REQUEST in
$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" $PACKAGE "rpmbuild -bp $PACKAGE.spec $RPMARCHADD --nodeps --define=\"_topdir $SPECVAR_WORKINGHOME/RPM\""
RET=$?
;;
"rpmbuild") [ "$RPMFORCE" = "true" ] && RPMFORCEADD="--force-build"
"rpmbuild") AUTOSPECADD=""
[ "$RPMFORCE" = "true" ] && AUTOSPECADD="--force-build"
[ "$NOPREP" = "true" ] && AUTOSPECADD="${AUTOSPECADD} --noprep"
[ "$RPMBUILDARCH" -a "$RPMBUILDARCH" != "${AUTOPORT_ARCH[$ENVIRONMENT]}" ] && \
RPMARCHADD="-A $RPMBUILDARCH --define \"cross_target_cpu=$RPMBUILDARCH\""
$SUDO_WRAPPER background $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a5,6 -b $RPMFORCEADD $RPMARCHADD" &>/dev/null
$SUDO_WRAPPER background $ENVIRONMENT "$USER" $PACKAGE "$AUTOSPEC_CMD -u $PACKAGE -a5,6 -b $AUTOSPECADD $RPMARCHADD" &>/dev/null
# && echo \"Webbuild HINT: now you may want to click on 'build requirements', add build requirements in .spec file and then 'recreate SRPMS'\""
[ $? -ne 0 ] && RET=$? || {
RET=-1

View File

@ -1,6 +1,6 @@
#
# webbuild functions-private include file
# Copyright (c) 2012-2014 by Silvan Calarco <silvan.calarco@mambasoft.it>
# Copyright (c) 2012-2024 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
repository_list() {
@ -152,6 +152,7 @@ function print_showlogcontrols() {
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
echo -n "REQUEST=consolecmd&CONSOLECMD=\"+getElementById('consolecmd').value+\"&"
echo -n "RPMFORCE=\"+getElementById('rpmforce').checked+\"&"
echo -n "NOPREP=\"+getElementById('noprep').checked+\"&"
echo -n "DEBUG=\"+getElementById('debug').checked+\"&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue()));>"
# close tag
@ -192,7 +193,9 @@ function print_editorcontrols() {
echo -n "<input type=button value=\"build\" onclick="
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=rpmbuild&"
echo -n "RPMBUILDARCH=\"+getSelectedValueById('rpmbuildarch')+\"&"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&RPMFORCE=\"+getElementById('rpmforce').checked); class=boldbutton>"
echo -n "SPECTEXT=\"+encodeURIComponent(editor.getValue())+\"&"
echo -n "NOPREP=\"+getElementById('noprep').checked+\"&"
echo -n "RPMFORCE=\"+getElementById('rpmforce').checked); class=boldbutton>"
# unpackaged files
echo -n "<input type=button value=\"unpackaged list\" onclick="
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&REQUEST=autospeclistcheck&"

View File

@ -88,12 +88,15 @@ if [ "$MODE" = "specinfo" ]; then
done < ${ENVPREFIX}${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec
[ "$AUTOBUILDREQ_BEGIN" -a "$AUTOBUILDREQ_END" -a ! "$AUTOBUILDREQ_UNDONE" ] || \
echo "SPECVAR_CHECK_NOAUTOBUILDREQ=1"
# _setup: prevent %setup macro expansion
$SUCMDPREFIX "rpmspec -P ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec --define \"%setup _setup\" > ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec.tmp 2>/dev/null"
$SUCMDPREFIX "rpmspec -P ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec > ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec.tmp 2>/dev/null"
if [ -e $SPECFILE.tmp ]; then
echo "SPECVAR_Specfile=\"$SPECFILE\""
BUILDDIR=`grep -m1 "^_setup.*-n " $SPECFILE.tmp | sed "s|.*-n \([^[:space:]]*\).*|\1|"`
PACKAGE_VERSION=`rpmspec -q --srpm --queryformat \"%{VERSION}\" ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec`
# Resolve builddir by parsing %setup macro or use default
BUILDDIR_UNPARSED=`grep "^%setup" ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec | sed "s|.*-n \([^[:space:]]*\).*|\1|"`
if [ ! "$BUILDDIR_UNPARSED" ]; then
BUILDDIR_UNPARSED="$PACKAGE-%{version}"
fi
BUILDDIR=`rpmspec -q --srpm --queryformat \"${BUILDDIR_UNPARSED}\" ${WORKINGHOME}/RPM/SPECS/$PACKAGE.spec`
while read line; do
set -- $line
[ "$1" = "%package" -o "$1" = "%description" ] && break
@ -105,7 +108,7 @@ if [ "$MODE" = "specinfo" ]; then
[ "$specvar" = "$lastspecvar" ] && varidx=$(($varidx + 1)) || varidx=0
echo "$specvar[$varidx]=\"${line//\"/}\""
[ "$specvaridx" != "" ] && echo "${specvar}_idx[$varidx]=$specvaridx"
[ "$specvar" = "SPECVAR_Version" -a ! "$BUILDDIR" ] && BUILDDIR="$PACKAGE-${line}"
[ "$specvar" = "SPECVAR_Version" ] && PACKAGE_VERSION="${line}"
fi
lastspecvar=$specvar
done < $SPECFILE.tmp