Added autodist-repository tool, further fixes to support a central sociallog and more fixes

This commit is contained in:
Silvan Calarco 2014-05-23 21:17:27 +02:00
parent 2979f8d61b
commit 6fc6b0bda6
7 changed files with 1084 additions and 56 deletions

View File

@ -71,6 +71,7 @@ install-programs:
@$(INSTALL_SCRIPT) autoport $(DESTDIR)$(bindir)/autoport @$(INSTALL_SCRIPT) autoport $(DESTDIR)$(bindir)/autoport
@$(INSTALL_SCRIPT) automaint $(DESTDIR)$(sbindir)/automaint @$(INSTALL_SCRIPT) automaint $(DESTDIR)$(sbindir)/automaint
@$(INSTALL_SCRIPT) autoport-chroot $(DESTDIR)$(sbindir)/autoport-chroot @$(INSTALL_SCRIPT) autoport-chroot $(DESTDIR)$(sbindir)/autoport-chroot
@$(INSTALL_SCRIPT) autodist-repository $(DESTDIR)$(sbindir)/autodist-repository
@$(INSTALL_SCRIPT) autodist-upstream-updates $(DESTDIR)$(sbindir)/autodist-upstream-updates @$(INSTALL_SCRIPT) autodist-upstream-updates $(DESTDIR)$(sbindir)/autodist-upstream-updates
@$(INSTALL_SCRIPT) autoport-fix-environment $(DESTDIR)$(bindir)/autoport-fix-environment @$(INSTALL_SCRIPT) autoport-fix-environment $(DESTDIR)$(bindir)/autoport-fix-environment
@$(INSTALL_SCRIPT) etc/autodist/scripts/* $(DESTDIR)$(configdir)/scripts/ @$(INSTALL_SCRIPT) etc/autodist/scripts/* $(DESTDIR)$(configdir)/scripts/

1011
autodist-repository Executable file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# automaint -- batch automatic maintainance tool of the autodist suite # automaint -- batch automatic maintainance tool of the autodist suite
# Copyright (C) 2013 by Silvan Calarco <silvan.calarco@mambasoft.it> # Copyright (C) 2013-2014 by Silvan Calarco <silvan.calarco@mambasoft.it>
# #
# Released under the terms of the GNU GPL release 3 license # Released under the terms of the GNU GPL release 3 license
# #
@ -212,7 +212,7 @@ for p in ${pkglist[0]}; do
if [ "$needsport" ]; then if [ "$needsport" ]; then
echo "$p: importing from $SOURCE_REPOSITORY to $PORT_REPOSITORY ($spkg_version-$spkg_release -> $pkg_version-$pkg_release)" echo "$p: importing from $SOURCE_REPOSITORY to $PORT_REPOSITORY ($spkg_version-$spkg_release -> $pkg_version-$pkg_release)"
if [ ! "$TESTMODE" ]; then if [ ! "$TESTMODE" ]; then
openmamba-repository import $SOURCE_REPOSITORY $p -d $PORT_REPOSITORY -y >/dev/null autodist-repository import $SOURCE_REPOSITORY $p -d $PORT_REPOSITORY -y >/dev/null
if [ $? -eq 0 -a "$WEBBUILD_URL" -a "$WEBBUILD_USER" ]; then if [ $? -eq 0 -a "$WEBBUILD_URL" -a "$WEBBUILD_USER" ]; then
curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=${WEBBUILD_SECRET}&USER_EMAIL=$WEBBUILD_EMAIL&\ curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=${WEBBUILD_SECRET}&USER_EMAIL=$WEBBUILD_EMAIL&\
MESSAGE=`cgi_encodevar \"imported <b>$p</b> from <b>$SOURCE_REPOSITORY</b> to <b>$PORT_REPOSITORY</b> for porting\"`" >/dev/null MESSAGE=`cgi_encodevar \"imported <b>$p</b> from <b>$SOURCE_REPOSITORY</b> to <b>$PORT_REPOSITORY</b> for porting\"`" >/dev/null
@ -221,7 +221,7 @@ MESSAGE=`cgi_encodevar \"imported <b>$p</b> from <b>$SOURCE_REPOSITORY</b> to <b
else else
echo "$p: importing from $SOURCE_REPOSITORY to $DEST_REPOSITORY ($spkg_version-$spkg_release -> $pkg_version-$pkg_release; update type: $update_type)" echo "$p: importing from $SOURCE_REPOSITORY to $DEST_REPOSITORY ($spkg_version-$spkg_release -> $pkg_version-$pkg_release; update type: $update_type)"
if [ ! "$TESTMODE" ]; then if [ ! "$TESTMODE" ]; then
openmamba-repository import $SOURCE_REPOSITORY $p -d $DEST_REPOSITORY -y >/dev/null autodist-repository import $SOURCE_REPOSITORY $p -d $DEST_REPOSITORY -y >/dev/null
if [ $? -eq 0 -a "$WEBBUILD_URL" -a "$WEBBUILD_USER" ]; then if [ $? -eq 0 -a "$WEBBUILD_URL" -a "$WEBBUILD_USER" ]; then
curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=${WEBBUILD_SECRET}&USER_EMAIL=$WEBBUILD_EMAIL&\ curl -s "$WEBBUILD_URL?REQUEST=message&USER=$WEBBUILD_USER&SECRET=${WEBBUILD_SECRET}&USER_EMAIL=$WEBBUILD_EMAIL&\
MESSAGE=`cgi_encodevar \"imported <b>$p</b> from <b>$SOURCE_REPOSITORY</b> to <b>$DEST_REPOSITORY</b>\"`" >/dev/null MESSAGE=`cgi_encodevar \"imported <b>$p</b> from <b>$SOURCE_REPOSITORY</b> to <b>$DEST_REPOSITORY</b>\"`" >/dev/null

View File

@ -47,7 +47,6 @@ var socialbox_reloadtime = 15000;
function ajax_getvalues_refresh(request,user,user_email,secret) { function ajax_getvalues_refresh(request,user,user_email,secret) {
var fromid = 0; var fromid = 0;
//alert("refresh");
if (socialbox_interval != null) { if (socialbox_interval != null) {
clearInterval(socialbox_interval); clearInterval(socialbox_interval);
} }

View File

@ -14,7 +14,7 @@ cgi_getvars BOTH ALL
[ "$PACKAGE" ] && PACKAGEENCODED=`cgi_encodevar "$PACKAGE"` || PACKAGEENCODED= [ "$PACKAGE" ] && PACKAGEENCODED=`cgi_encodevar "$PACKAGE"` || PACKAGEENCODED=
#cgi_getvars POST #cgi_getvars POST
if [ "$REQUEST" != "refresh" ]; then if [ "${REQUEST:0:7}" != "refresh" ]; then
echo "`date` - USER=$USER&REQUEST=$REQUEST&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&MAINTAINERMODE=$MAINTAINERMODE" >> $LOG echo "`date` - USER=$USER&REQUEST=$REQUEST&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&MAINTAINERMODE=$MAINTAINERMODE" >> $LOG
fi fi
@ -65,7 +65,7 @@ if [ "$USER" ]; then
else else
USER_ENABLED= USER_ENABLED=
fi fi
elif [ "$REQUEST" != "refresh" ]; then elif [ "${REQUEST:0:7}" != "refresh" ]; then
# no "$USER_SECRET" set; require password # no "$USER_SECRET" set; require password
echo -n "<output><![CDATA[Please enter your password: <input type=password id=password " echo -n "<output><![CDATA[Please enter your password: <input type=password id=password "
echo -n "onkeypress=if(checkEnter(event))" echo -n "onkeypress=if(checkEnter(event))"
@ -88,7 +88,7 @@ if [ "$USER" ]; then
exit exit
fi fi
fi fi
elif [ "$REQUEST" != "refresh" ]; then elif [ "${REQUEST:0:7}" != "refresh" ]; then
echo -n "<output><![CDATA[Please enter your username: <input type=text id=username " echo -n "<output><![CDATA[Please enter your username: <input type=text id=username "
echo -n "onkeypress=if(checkEnter(event)){" echo -n "onkeypress=if(checkEnter(event)){"
echo -n "user=encodeURIComponent(getElementById('username').value);" echo -n "user=encodeURIComponent(getElementById('username').value);"
@ -110,7 +110,7 @@ elif [ "$REQUEST" != "refresh" ]; then
exit exit
fi fi
if [ "$USER_ENABLED" != "1" -a "$REQUEST" != "refresh" ]; then if [ "$USER_ENABLED" != "1" -a "${REQUEST:0:7}" != "refresh" ]; then
echo -n "<environments> </environments>" echo -n "<environments> </environments>"
echo -n "<speccreate> </speccreate>" echo -n "<speccreate> </speccreate>"
echo -n "<specedit> </specedit>" echo -n "<specedit> </specedit>"
@ -210,48 +210,53 @@ fi
# #
# Public requests # Public requests
# #
if [ "$REQUEST" = "refresh" -o ! "$USER" ]; then if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshsocial" -o ! "$USER" ]; then
[ -e "$WEBBUILD_STATEDIR/social_log" ] || exit if [ "$WEBBUILD_URL" -a "$USER" ]; then
# social box curl -s "$WEBBUILD_URL?REQUEST=refreshsocial&USER=$USER&SECRET=`cgi_encodevar \"$USER_SECRET\"`&USER_EMAIL=$USER_EMAIL&FROMID=$FROMID"
echo -n "<socialbox>" else
count=0 [ -e "$WEBBUILD_STATEDIR/social_log" ] || exit
if [ ! "$FROMID" -o "$FROMID" = "0" -o "$FROMID" = "NaN" ]; then # social box
if [ "$USER" ]; then echo -n "<socialbox>"
line=`tail -n 500 $WEBBUILD_STATEDIR/social_log | grep -v " SUSER=$USER " 2>/dev/null | tail -n 25 | head -n 1` count=0
else SID=0
line=`tail -n 500 $WEBBUILD_STATEDIR/social_log | grep -v " STARGET=developers " 2>/dev/null | tail -n 25 | head -n 1` if [ ! "$FROMID" -o "$FROMID" = "0" -o "$FROMID" = "NaN" ]; then
if [ "$USER" ]; then
line=`tail -n 500 $WEBBUILD_STATEDIR/social_log | grep -v " SUSER=$USER " 2>/dev/null | tail -n 25 | head -n 1`
else
line=`tail -n 500 $WEBBUILD_STATEDIR/social_log | grep -v " STARGET=developers " 2>/dev/null | tail -n 25 | head -n 1`
fi
eval $line
FROMID=$SID
fi fi
eval $line tail -n 100 $WEBBUILD_STATEDIR/social_log | while read line; do
FROMID=$SID STYPE=
SPRIVACY=
SUSER=
STARGET=
SID=
eval $line
[ "$SID" ] || continue
[ $SID -ge $FROMID ] || continue
[ "$STARGET" = "developers" -a ! "$USER" ] && continue
[ "$SUSER" = "$USER" -a "$STARGET" == "developers" ] && continue
if [ "$SPRIVACY" -a ! "$USER" ]; then
USER_GRAVATAR=
else
USER_GRAVATAR=`echo -n $SEMAIL | md5sum | sed "s| .*||"`
fi
echo -n "<add id=\"$SID\"><![CDATA[<div style=\"margin:0;padding:0;\"><div style=\"vertical-align:middle;position:relative;float:left;height:24px;width:24px;margin-right:2px;\">"
echo -n "<img src=\"http://www.gravatar.com/avatar/$USER_GRAVATAR?s=24&d=http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=24\" /></div>"
if [ "$SPRIVACY" -a ! "$USER" ]; then
SUSER="a developer"
elif [ "$USER" = "$SUSER" ]; then
SUSER="you"
fi
echo -n "<div style=\"position:relative;margin-left:24px;height:auto;padding:0;\"><b>$SUSER</b> $STEXT <i><span name=socialtime time=$STIME></span></i></div>"
echo -n "</div><div style=\"clear:both;\"><hr></div>]]></add>"
count=$(($count + 1))
done
echo -n "</socialbox>"
fi fi
tail -n 100 $WEBBUILD_STATEDIR/social_log | while read line; do
STYPE=
SPRIVACY=
SUSER=
STARGET=
SID=
eval $line
[ "$SID" ] || continue
[ $SID -ge $FROMID ] || continue
[ "$STARGET" = "developers" -a ! "$USER" ] && continue
[ "$SUSER" = "$USER" -a "$STARGET" == "developers" ] && continue
if [ "$SPRIVACY" -a ! "$USER" ]; then
USER_GRAVATAR=
else
USER_GRAVATAR=`echo -n $SEMAIL | md5sum | sed "s| .*||"`
fi
echo -n "<add id=\"$SID\"><![CDATA[<div style=\"margin:0;padding:0;\"><div style=\"vertical-align:middle;position:relative;float:left;height:24px;width:24px;margin-right:2px;\">"
echo -n "<img src=\"http://www.gravatar.com/avatar/$USER_GRAVATAR?s=24&d=http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=24\" /></div>"
if [ "$SPRIVACY" -a ! "$USER" ]; then
SUSER="a developer"
elif [ "$USER" = "$SUSER" ]; then
SUSER="you"
fi
echo -n "<div style=\"position:relative;margin-left:24px;height:auto;padding:0;\"><b>$SUSER</b> $STEXT <i><span name=socialtime time=$STIME></span></i></div>"
echo -n "</div><div style=\"clear:both;\"><hr></div>]]></add>"
count=$(($count + 1))
done
echo -n "</socialbox>"
fi fi
if [ "$USER_ENABLED" != "1" ]; then if [ "$USER_ENABLED" != "1" ]; then
@ -463,7 +468,7 @@ if [ "$REQUEST" = "repsearch" ]; then
# echo -n "<pre><!-- SCROLL -->" # echo -n "<pre><!-- SCROLL -->"
curl -s "${WEBBUILD_DISTROQUERY_URL}?query=$REPSEARCHTEXT&search_milestone2=true&search_devel=true\ curl -s "${WEBBUILD_DISTROQUERY_URL}?query=$REPSEARCHTEXT&search_milestone2=true&search_devel=true\
&search_i586=true&search_x86_64=true&search_arm=true&search_sources=true&query_compact=true&replyplain=true" &search_i586=true&search_x86_64=true&search_arm=true&search_sources=true&query_compact=true&replyplain=true"
# $SUDO_WRAPPER 0 local "$USER" "" "openmamba-repository search -i ${REPSEARCHTEXT/-/\-}" | \ # $SUDO_WRAPPER 0 local "$USER" "" "autodist-repository search -i ${REPSEARCHTEXT/-/\-}" | \
# parse_search_output ${AUTOPORT_ARCH[$ENVIRONMENT]} # parse_search_output ${AUTOPORT_ARCH[$ENVIRONMENT]}
# sed "s|\(.*(source).*\)|<font color=white><b>\1</b></font>|; # sed "s|\(.*(source).*\)|<font color=white><b>\1</b></font>|;
# s|\(.*(${AUTOPORT_ARCH[$ENVIRONMENT]}).*\)|<font color=lightgreen>\1</font>|" # s|\(.*(${AUTOPORT_ARCH[$ENVIRONMENT]}).*\)|<font color=lightgreen>\1</font>|"
@ -1873,7 +1878,7 @@ case $REQUEST in
for p in $PACKAGES; do for p in $PACKAGES; do
[ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD= [ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD=
[ "$REPOSITORYFORCE" = "true" ] && FORCEADD="-f" [ "$REPOSITORYFORCE" = "true" ] && FORCEADD="-f"
$SUDO_WRAPPER 0 local "$USER" "$PACKAGE" "openmamba-repository import $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO $SIMULATEADD $FORCEADD -y" $SUDO_WRAPPER 0 local "$USER" "$PACKAGE" "autodist-repository import $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO $SIMULATEADD $FORCEADD -y"
RET=$? RET=$?
if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"imported <b>$p</b> from <b>$SENDREPOSITORY</b> to <b>$REPOSITORYIMPORTTO</b>\" STIME=`date +%s`" social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"imported <b>$p</b> from <b>$SENDREPOSITORY</b> to <b>$REPOSITORYIMPORTTO</b>\" STIME=`date +%s`"
@ -1890,7 +1895,7 @@ case $REQUEST in
for p in $PACKAGES; do for p in $PACKAGES; do
[ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD= [ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD=
[ "$REPOSITORYFORCE" = "true" ] && SIMULATEADD="$SIMULATEADD -f" [ "$REPOSITORYFORCE" = "true" ] && SIMULATEADD="$SIMULATEADD -f"
$SUDO_WRAPPER 0 local "$USER" "$PACKAGE" "openmamba-repository release $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO $SIMULATEADD -y" $SUDO_WRAPPER 0 local "$USER" "$PACKAGE" "autodist-repository release $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO $SIMULATEADD -y"
RET=$? RET=$?
if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"released <b>$p</b> from <b>$SENDREPOSITORY</b> to <b>$REPOSITORYIMPORTTO</b>\" STIME=`date +%s`" social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"released <b>$p</b> from <b>$SENDREPOSITORY</b> to <b>$REPOSITORYIMPORTTO</b>\" STIME=`date +%s`"
@ -1905,7 +1910,7 @@ case $REQUEST in
break break
} }
for p in $PACKAGES; do for p in $PACKAGES; do
$SUDO_WRAPPER 0 local "$USER" "" "openmamba-repository diff $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO" $SUDO_WRAPPER 0 local "$USER" "" "autodist-repository diff $SENDREPOSITORY $p -d $REPOSITORYIMPORTTO"
RET=$? RET=$?
[ $RET -eq 0 ] || break [ $RET -eq 0 ] || break
done done
@ -1918,7 +1923,7 @@ case $REQUEST in
} }
for p in $PACKAGES; do for p in $PACKAGES; do
[ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD= [ "$REPOSITORYSIMULATE" = "true" -o ! "$USER_CANMAINTAIN" ] && SIMULATEADD="-s" || SIMULATEADD=
$SUDO_WRAPPER 0 local "$USER" "$PACKAGE" "openmamba-repository archive $SENDREPOSITORY $p -y" $SUDO_WRAPPER 0 local "$USER" "$PACKAGE" "autodist-repository archive $SENDREPOSITORY $p -y"
RET=$? RET=$?
if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then if [ ! "$SIMULATEADD" -a $RET -eq 0 ]; then
social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"archived <b>$p</b> from <b>$SENDREPOSITORY</b>\" STIME=`date +%s`" social_log "SUSER=$USER SEMAIL=$USER_EMAIL STEXT=\"archived <b>$p</b> from <b>$SENDREPOSITORY</b>\" STIME=`date +%s`"

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# webbuild functions # webbuild functions
# Copyright (c) 2012 by Silvan Calarco <silvan.calarco@mambasoft.it> # Copyright (c) 2012-2014 by Silvan Calarco <silvan.calarco@mambasoft.it>
# #
. /etc/autodist/config . /etc/autodist/config
@ -36,6 +36,13 @@ function social_log() {
STATE_SOCIALLOG_ID=$(($STATE_SOCIALLOG_ID + 1)) STATE_SOCIALLOG_ID=$(($STATE_SOCIALLOG_ID + 1))
set_user_state_var STATE_SOCIALLOG_ID $STATE_SOCIALLOG_ID webbuild set_user_state_var STATE_SOCIALLOG_ID $STATE_SOCIALLOG_ID webbuild
echo "SID=$STATE_SOCIALLOG_ID SPRIVACY=$STATE_PRIVACYMODE $line" >> $WEBBUILD_STATEDIR/social_log echo "SID=$STATE_SOCIALLOG_ID SPRIVACY=$STATE_PRIVACYMODE $line" >> $WEBBUILD_STATEDIR/social_log
if [ "$WEBBUILD_URL" ]; then
eval $line
USER_SECRET_FIXED=`echo $USER_SECRET | sed "s|\$|\\$|"`
curl -s "$WEBBUILD_URL?REQUEST=message&USER=$USER&SECRET=`cgi_encodevar \"$USER_SECRET\"`&USER_EMAIL=$USER_EMAIL&\
MESSAGE=`cgi_encodevar \"$STEXT\"`" >/dev/null
fi
fi fi
} }
@ -205,7 +212,7 @@ function parse_search_output() {
echo -n "<a class=searchlink href=\"/distribution/distromatic.html?tag=$REPOSITORY&pkg=$PKG.$ARCH\" target=_new>$2</a><br>" echo -n "<a class=searchlink href=\"/distribution/distromatic.html?tag=$REPOSITORY&pkg=$PKG.$ARCH\" target=_new>$2</a><br>"
echo -n "</font>" echo -n "</font>"
# if [ "$ARCH" ] # if [ "$ARCH" ]
# $SUDO_WRAPPER 0 local "$USER" "" "openmamba-repository search -i $REPSEARCHTEXT" | \ # $SUDO_WRAPPER 0 local "$USER" "" "autodist-repository search -i $REPSEARCHTEXT" | \
# sed "s|\(.*(source).*\)|<font color=white><b>\1</b></font>|; # sed "s|\(.*(source).*\)|<font color=white><b>\1</b></font>|;
# s|\(.*(${AUTOPORT_ARCH[$ENVIRONMENT]}).*\)|<font color=lightgreen>\1</font>|" # s|\(.*(${AUTOPORT_ARCH[$ENVIRONMENT]}).*\)|<font color=lightgreen>\1</font>|"
done done

View File

@ -1,8 +1,13 @@
#
# webbuild functions-private include file
# Copyright (c) 2012-2014 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
repository_list() { repository_list() {
if [ "$WEBBUILD_REPOSITORIES" ]; then if [ "$WEBBUILD_REPOSITORIES" ]; then
echo "${WEBBUILD_REPOSITORIES[*]}" echo "${WEBBUILD_REPOSITORIES[*]}"
else else
$SUDO_WRAPPER 0 local "$USER" "" "/usr/sbin/openmamba-repository list" $SUDO_WRAPPER 0 local "$USER" "" "/usr/sbin/autodist-repository list"
fi fi
} }