initial commit of file from CVS for smeserver-mock on Thu 26 Oct 11:20:16 BST 2023

This commit is contained in:
2023-10-26 11:20:16 +01:00
parent 0fb71cc6e5
commit 00b6cc6808
21 changed files with 1655 additions and 2 deletions

76
root/usr/bin/BogusDateBot.sh Executable file
View File

@@ -0,0 +1,76 @@
#!/bin/bash
# Copyright 2014 Edward J Huff ejhuff at gmail.com, not a work for hire.
# License: any GPL or BSD or MIT or any free software license.
# bash script to fix bogus weekdays in rpm spec files.
# This script automatically corrects bogus weekdays in spec files, generating a
# changelog entry and adding a line after the bogus date noting the original date.
# (The weekday might have been correct and the day of the month wrong).
# The input file is copied to a backup file, and a diff is printed.
# JP PIALASSE : added ? to handle date with one digit
[[ $# > 0 ]] || { echo "Usage: $0 packagename.spec ..."; exit 1; }
export LC_ALL=C
Www='[A-Z][a-z][a-z]'
Mmm='[A-Z][a-z][a-z]'
DD1='[0-9]'
DD0='[0-9]{1,2}'
DD='[0-9][0-9]'
YYYY='[12][90][0-9][0-9]'
WwwMmmDDYYYY="\($Www\) \($Mmm\) \($DD\) \($YYYY\)"
WwwMmmDD1YYYY="\($Www\) \($Mmm\) \($DD1\) \($YYYY\)"
WwwMmmDD0YYYY="\($Www\) \($Mmm\) \($DD0\) \($YYYY\)"
while [[ $# > 0 ]]; do
[[ -f "$1" ]] || { echo "$0: $1: no such file."; exit 1; }
changelog=$(mktemp --tmpdir=. changelog-XXXXXXXXX.txt)
sedscript=$(mktemp --tmpdir=. sedscript-XXXXXXXXX.sed)
printf "%s\n" \
"* $(date +'%a %b %d %Y') BogusDateBot" \
'- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday,' \
" by assuming the date is correct and changing the weekday." \
> "$changelog"
cat "$1" | \
grep -P "^\* $Www $Mmm $DD0 $YYYY" | \
grep -v '^echo' | \
sed 's/^\* '"$WwwMmmDDYYYY"'.*$/echo "$(date --date="\2 \3 \4" +"%a \1 %b %d %Y")"/' | \
sed 's/^\* '"$WwwMmmDD1YYYY"'.*$/echo "$(date --date="\2 0\3 \4" +"%a \1 %b %d %Y")"/' | \
grep '^echo' | \
bash | \
egrep -v "Mon Mon|Tue Tue|Wed Wed|Thu Thu|Fri Fri|Sat Sat|Sun Sun" | \
sort -u --key=5,5n --key=3,3M --key=4,4n | \
while read correct wrong Month Day Year; do
date="$Month $Day $Year"
alternatives="$wrong $Month $Day $Year --> "$(
for ((i = -6; i < 7; i++ )); do
date --date "$date $i day" +"%a %b %d %Y or ";
done | egrep "$date|$wrong" | tr -d \\n;
printf "%s" "....")
printf " %s\n" "$alternatives" >> "$changelog"
# re='^\* '"$wrong $Month $Day $Year"'\(.*\)$'
# subs='* '"$correct $Month $Day $Year"'\1\n '"$alternatives"
# printf "%s\n" "s:$re:$subs:" >> "$sedscript"
# if $Day only one digit
if [[ "$Day" =~ ^0([0-9])$ ]];
then echo "${BASH_REMATCH[1]}";
re='^\* '"$wrong $Month ${BASH_REMATCH[1]} $Year"'\(.*\)$'
subs='* '"$correct $Month $Day $Year"'\1\n '"$alternatives"
else
re='^\* '"$wrong $Month $Day $Year"'\(.*\)$'
subs='* '"$correct $Month $Day $Year"'\1\n '"$alternatives"
fi
printf "%s\n" "s:$re:$subs:" >> "$sedscript"
done
printf "\n" >> "$changelog"
backup="$1"-$(date --utc --ref="$1" +"%Y-%m-%d-%H-%M-%S-%NZ")
cp -vpf "$1" "$backup"
cat "$backup" | sed -f "$sedscript" -e '/^%changelog *$/ r '"$changelog" > "$1"
rm -f "$changelog" "$sedscript"
diff -u "$backup" "$1"
shift
done

65
root/usr/bin/change-log Executable file
View File

@@ -0,0 +1,65 @@
#!/bin/bash
LANG="en_us_8859_1";
dateJ=`date "+%Y-%m-%d"`;
dateH=`date "+%a %b %d %Y"`;
#if [[ $1 ]] && [ -f $1 ] && [ ${1: -4} == ".spec" ]
if [[ $1 ]] && [ ${1##*.} == "spec" ]
then
specfile=$1
else
specfile=`grep '\.spec' ./CVS/Entries|cut -d'/' -f2`
fi
echo "search for release in $specfile";
# could be
#%define main_release 12.6
#%define release 2
#%define release 2%{?dist}
#Release: 24
#Release: 24%{?dist}
rele=0;
release=`cat $specfile|egrep '^%define\s+(main_)?release'|sed -r 's/\s+/ /g'|cut -d " " -f3|cut -d% -f1`;
if [[ ! $release ]]; then
release=`cat $specfile|egrep '^Release:'|cut -d ":" -f2| tr -d "[:space:]"|cut -d% -f1`;
rele=1;
fi
echo "search for version in $specfile";
#%define version 23
#Version: 23
version=`cat $specfile|egrep -i '%define\s+version'|sed -r 's/\s+/ /g' |cut -d " " -f3|cut -d% -f1`;
echo "version : $version"
if [[ ! $version ]]; then
version=`cat $specfile|egrep '^Version:'|cut -d ":" -f2| tr -d "[:space:]"`;
fi
echo "version : $version"
echo "update release";
oldrelease=$release;
#release=$(($release + 1));# do not handle float
#release=`echo "$release + 1"|bc`; # not always available
addme=1;
if [[ "$release" =~ ^[0-9]+\.[0-9]+$ ]]
then
addme=0.1;
fi
release=`lua -e "print( $release + $addme)"`;
echo "update release $oldrelease ==> $release";
if [ "$rele" -eq "0" ]; then
cat $specfile |sed -r "s/(^%define\s+(main_)?release) *$oldrelease/\1 $release/">$specfile.tmp;
else
cat $specfile |sed -r "s/(^Release:\s+)$oldrelease/\1$release/">$specfile.tmp;
fi
cat $specfile.tmp > $specfile;
echo "updating changelog $specfile";
entete="* $dateH ME MYSELF <myemail@koozali.org> $version-$release.sme"
changelog="- fix [SME: ]"
cat $specfile |sed "/^%changelog/a $entete\n$changelog\n" >$specfile.tmp;
cat $specfile.tmp>$specfile;
rm -f $specfile.tmp
echo "vim $specfile"

13
root/usr/bin/cleantree Normal file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
#find . -regex .*patch|cut -f2 -d/>~filetoremove
for f in `find . -regex .*patch |cut -f2 -d/`
do
echo "Processing $f"
# do something on $f
rm -f $f
cvs remove $f
done
cvs commit -m "cleaning tree from patchs"

3
root/usr/bin/clog Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
rm -f clog
cvs commit -m "$(make clog)"

View File

@@ -0,0 +1,6 @@
#!/bin/sh
mkdir ~/rpmbuild
for i in BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
do
mkdir ~/rpmbuild/$i
done

221
root/usr/bin/importNew Normal file
View File

@@ -0,0 +1,221 @@
#!/bin/bash
if [ $# -eq 0 ]
then
echo "No arguments supplied"
fi
if [ $# -lt 3 ]
then
echo "Usage:
importNew type version pkgname [rpmpath]
examples:
# importNew contribs 10 smeserver-mycontrib [~/smeserver-mycontribs-1.0-1.src.rpm]
# importNew sme 10 smeserver-package [~/smeserver-package-1.0-1.src.rpm]
This script is intended to create a new tree, if needed,and a new branch to import a provided srpm.
It will then run cvs-import.sh script for you if you provided a srpm location. If not provided you can populate the branch
with what you want. If you only intend to copy the content of a branch to another, you might search for newbranch script.
"
exit
fi
sme=$1
if [[ "$sme" != "sme" && "$sme" != "contribs" ]]
then
echo "wrong first parameter should be either 'sme' or 'contribs'"
exit
fi
re='^[0-9]+$'
if ! [[ $2 =~ $re ]] ; then
echo "Error: Second argument should be a version number (e.g.: 10) for the branch ((e.g.: contribs10) where you want to put the SRPM content if provided." >&2; exit 1
fi
ver=$2
pkgname=$3
rpmpath=$4
curpwd=`pwd`
packageroot='smecontribs'
CVSROOT=":ext:shell.koozali.org:/cvs/smecontribs"
if [[ "$sme" == "sme" ]]
then
packageroot='smeserver'
CVSROOT=":ext:shell.koozali.org:/cvs/smeserver"
fi
#this one is directly from commons/Makefile.common
CreateBranchMakefile() {
cat >Makefile <<EOF
# Makefile for source rpm: $NAME
# \$Id\$
NAME := $NAME
SPECFILE = \$(firstword \$(wildcard *.spec))
define find-makefile-common
for d in common ../common ../../common ; do if [ -f \$\$d/Makefile.common ] ; then if [ -f \$\$d/CVS/Root -a -w \$\$/Makefile.common ] ; then cd \$\$d ; cvs -Q update ; fi ; echo "\$\$d/Makefile.common" ; break ; fi ; done
endef
MAKEFILE_COMMON := \$(shell \$(find-makefile-common))
ifeq (\$(MAKEFILE_COMMON),)
# attept a checkout
define checkout-makefile-common
test -f CVS/Root && { cvs -Q -d \$\$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
endef
MAKEFILE_COMMON := \$(shell \$(checkout-makefile-common))
endif
include \$(MAKEFILE_COMMON)
EOF
}
# update modules files
cd ~/$packageroot/CVSROOT
cvs -Q update -dPA 1>/dev/null
if [ -d ~/$packageroot/rpms ]
then
# update current tree
cd ~/$packageroot/rpms
cvs -Q update -dPA $pkgname common 1>/dev/null
else
# checkout rpms
cd ~/$packageroot
cvs -Q -z3 -d:ext:shell.koozali.org:/cvs/$packageroot co -P rpms 1>/dev/null
fi
newmodule=true;
# better test would be to actually grep module file!
#if [ -d ~/$packageroot/rpms/$pkgname ]
cd ~/$packageroot/CVSROOT
cvs -Q update -dPA 1>/dev/null
grep -Eq "^$pkgname\s+rpms/$pkgnames.*" ~/$packageroot/CVSROOT/modules
if (( $? == 0 ))
then
echo "package exists already"
newmodule=false;
fi
change=0
cd ~/$packageroot/rpms
#if [ -d ~/$packageroot/rpms/$pkgname ]
if ( cvs status -l $pkgname 2>/dev/null|grep -q 'Unknown' )
then
echo "creating $pkgname tree ..."
mkdir -p $pkgname
cvs add $pkgname
change=1
fi
#if [ -d ~/$packageroot/rpms/$pkgname/$sme$ver ]
if ( cvs status -l $pkgname/$sme$ver 2>/dev/null|grep -q 'Unknown' )
then
echo "creating $pkgname/$sme$ver branch with content..."
mkdir -p $pkgname/$sme$ver
cvs add $pkgname/$sme$ver
change=1
fi
#if [ -f ~/$packageroot/rpms/$pkgname/$sme$ver/.cvsignore ]
if ( cvs status $pkgname/$sme$ver/.cvsignore 2>/dev/null|grep -q 'Unknown' )
then
touch $pkgname/$sme$ver/.cvsignore
cvs add $pkgname/$sme$ver/.cvsignore
change=1
fi
#if [ -f ~/$packageroot/rpms/$pkgname/$sme$ver/import.log ]
if ( cvs status $pkgname/$sme$ver/import.log 2>/dev/null|grep -q 'Unknown' )
then
touch $pkgname/$sme$ver/import.log
cvs add $pkgname/$sme$ver/import.log
change=1
fi
#create Makefile here
pushd $pkgname/$sme$ver >/dev/null
#if [ ! -f Makefile ]
if ( cvs status Makefile 2>/dev/null|grep -q 'Unknown' )
then
NAME=$pkgname
CreateBranchMakefile
cvs -Q add Makefile
change=1
fi
popd >/dev/null
if [ "$change" == "1" ]
then
echo "commit..."
cvs -Q commit -m "Prep for $pkgname import" $pkgname
fi
if ( $newmodule )
then
cd ~/$packageroot/CVSROOT
cvs -Q update -dPA 1>/dev/null
echo "$pkgname rpms/$pkgname &common" >> modules
linenumb=`cat modules |grep -n "#Start Auto-Maintenance" | grep -Eo '^[^:]+'`
# "#Start Auto-Maintenance"
#(head -n $linenumb; sort -nk$linenumb) < sample.txt 1<> sample.txt
(head -n $linenumb; sort) < modules 1<> modules
#echo "cvs commit -m \"adding $pkgname to modules\""
cvs commit -m "adding $pkgname to modules"
fi
if [[ "$HOSTNAME" == "shell.koozali.org" ]]
then
if [ $# -eq 3 ]
then
echo "importing the srpm for you"
cd ~/$packageroot;
cd CVSROOT/;
cvs -Q update -dPA 1>/dev/null;
cd ../rpms/;
cvs -Q update -dPA common $pkgname 1>/dev/null ;
cd ~/$packageroot;
./common/cvs-import.sh -b $sme$ver -m 'Initial import' /tmp/$(basename $rpmpath)
else
echo "no srpm provided"
fi
else
echo "##########################"
if [[ $rpmpath != "" ]]
then
echo "sending $rpmpath to shell.koozali.org ..."
echo "scp $rpmpath shell.koozali.org:/tmp/"
cd $curpwd
scp $rpmpath shell.koozali.org:~
echo "now trying to push this on shell.koozali.org and run ./common/cvs-import.sh"
echo "this could fails if your srpm was not initially on ~/smecontrib/ and if you have not ForwardAgent yes and user set in your .ss/config file for shell.koozali.org"
# ssh shell.koozali.org "cd ~/$packageroot;cd CVSROOT/; echo 'updating CVSROOT/modules...'; cvs -Q update -dPA modules; cd ../rpms/;echo 'checkout $pkgname ...' cvs co $pkgname 1>/dev/null ;cd ~/$packageroot; if [[ -f ~/$(basename $rpmpath) ]]; then ./common/cvs-import.sh -b $sme$ver -m 'Initial import' ~/$(basename $rpmpath); fi "
ssh shell.koozali.org "cd ~/$packageroot;cd CVSROOT/; echo 'updating CVSROOT/modules...'; cvs -Q update -dPA modules && cd ../rpms/ && echo 'checkout $pkgname ...' && cvs co $pkgname 1>/dev/null && cd ~/$packageroot && if [[ -f ~/$(basename $rpmpath) ]]; then echo './common/cvs-import.sh -b $sme$ver -m Initial import ~/$(basename $rpmpath)'; ./common/cvs-import.sh -b $sme$ver -m 'Initial import' ~/$(basename $rpmpath); fi "
echo "in case of failure do:"
echo "scp $rpmpath shell.koozali.org:/tmp/"
echo "ssh shell.koozali.org"
echo "cd ~/$packageroot"
if [ $# -eq 3 ]
then
echo "./common/cvs-import.sh -b $sme$ver -m 'Initial import' /tmp/$(basename $rpmpath)"
else
echo "./common/cvs-import.sh -b $sme$ver -m 'Initial import' YOURSRPM "
fi
echo "exit"
fi
cd ~/$packageroot/rpms/$pkgname/$sme$ver
if [ -f $pkgname}.spec ]
then
### if there is no spec file this will fail : make prep
cvs update -dPA; make prep
else
echo "# now do:"
echo "cd ~/$packageroot/rpms/$pkgname/$sme$ver ; cvs update -dPA;"
echo "then create your own spec file and cvs add it."
echo "then create your own archive and import it to lookaside cache if needed"
fi
fi
echo "##########################"
echo "now you can:"
echo "cd ~/$packageroot/rpms/$pkgname/$sme$ver"
unset CVSROOT

105
root/usr/bin/newbranch Normal file
View File

@@ -0,0 +1,105 @@
#!/bin/bash
if [ $# -eq 0 ]
then
echo "No arguments supplied"
fi
if [ $# -lt 4 ]
then
echo "Usage:
newbranch type versionOri versionDest pkgname
examples:
# newbranch contribs 9 10 smeserver-mycontrib
# newbranch sme 9 10 smeserver-package
This script is intended to create a new branch of an existing tree by copying the content of another branch in it. You can then alter the new branch content as you want.
If you need to create the tree for the package then you should use importNew script. It will also allow you to import a srpm content.
"
exit
fi
sme=$1
if [[ "$sme" != "sme" && "$sme" != "contribs" ]]
then
echo "wrong first parameter should be either 'sme' or 'contribs'"
exit
fi
re='^[0-9]+$'
if ! [[ $2 =~ $re ]] ; then
echo "Error: Second argument should be a version number (e.g.: 9) with an existing branch (e.g.: sme9)." >&2; exit 1
fi
if ! [[ $3 =~ $re ]] ; then
echo "Error: Third argument should be a version number (e.g.: 10) needing a new branch (e.g.: sme10)." >&2; exit 1
fi
#verd=$(($2 + 1));# rem we might want to go down too
vero=$2
verd=$3
pkgname=$4
curpwd=`pwd`
packageroot='smecontribs'
if [[ "$sme" == "sme" ]]
then
packageroot='smeserver'
fi
cd ~/$packageroot/CVSROOT
cvs -Q update -dPA 1>/dev/null
grep -Eq "^$pkgname\s+rpms/$pkgnames.*" ~/$packageroot/CVSROOT/modules
if (( $? != 0 ))
then
echo "Package $pkgname does not exists in modules, please create the proper tree in cvs and add it to modules. You might consider using importNew script."
exit
fi
# if does not exist we test if it is in cvs
# if not we fail
if [ ! -d ~/$packageroot/rpms/$pkgname ]
then
cd ~/$packageroot/rpms
# rem to test
cvs -Q -z3 -d:ext:shell.koozali.org:/cvs/$packageroot co -P $pkgname #1>/dev/null
if [ ! -d ~/$packageroot/rpms/$pkgname ]
then
echo "no such module $pkgname"
exho "use instead importNew script"
exit;
fi
fi
cd ~/$packageroot/rpms;
cvs update -dPA $pkgname >/dev/null
if [ ! -d ~/$packageroot/rpms/$pkgname/$sme$vero ]
then
echo "Branch $sme$vero does not exist. Nothing to do.";
exit;
fi
if [ -d ~/$packageroot/rpms/$pkgname/$sme$verd ]
then
echo "Branch $sme$verd exists. Nothing to do.";
else
cd ~/$packageroot/rpms
rm -rf ~/$packageroot/rpms/$pkgname
cd ~/$packageroot/rpms
cvs -Q co $pkgname
cd $pkgname
# then you can copy
cp -a $sme$vero $sme$verd
rm -rf $sme$verd/CVS
cvs add $sme$verd
cd $sme$verd
find ./ -name CVS -prune -o -print | xargs cvs add
cvs commit -m 'Initial import'
echo "# then you have to do:"
echo "cd ~/$packageroot/rpms/$pkgname/$sme$verd/"
echo "make local"
echo "make tag ;make build"
echo "# Alternatively you can do:"
echo "# make mockbuild"
echo "# make tag ;make build"
fi

16
root/usr/bin/prepa Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
cvs update -dPA
make clean
make prep
if [ -f 'sources' ] ; then
folder=`sed -rn 's/^[a-z0-9]{32}\s+(.+)\.(tar|t)\.?(gz|xz|bz|bz2)*$/\1/p' sources`
oldy="$folder.old"
if [ -d "$folder" ] ; then
echo "$folder exist"
if [ -d $oldy ] ; then
rm -rf $oldy && echo "removing $oldy"
fi
cp -a $folder $oldy && echo "creating $oldy as fresh copy of $folder"
fi
fi

57
root/usr/bin/refresh Normal file
View File

@@ -0,0 +1,57 @@
#!/bin/bash
if [ $# -eq 0 ]
then
echo "No arguments supplied"
echo "Usage:
refresh [sme|contribs]
examples:
# refresh sme
This script will refresh or create the tree for smeserver (sme) or smecontribs (contribs).
"
exit
fi
sme=$1
if [[ "$sme" != "sme" && "$sme" != "contribs" ]]
then
echo "Wrong first parameter should be either 'sme' or 'contribs'"
exit
fi
packageroot='smecontribs'
if [[ "$sme" == "sme" ]]
then
packageroot='smeserver'
fi
#create if missing
if [ ! -d ~/$packageroot ]
then
"creating ~/$packageroot and populating..."
mkdir -p ~/$packageroot
cd ~/$packageroot
cvs -Q -z3 -d:ext:shell.koozali.org:/cvs/$packageroot co -P CVSROOT rpms common 1>/dev/null
exit
fi
if [[ "$2" == "force" ]]
then
"Forcing checkout for ~/$packageroot and populating with CVSROOT rpms common..."
mkdir -p ~/$packageroot
cvs -Q -z3 -d:ext:shell.koozali.org:/cvs/$packageroot co -P CVSROOT rpms common 1>/dev/null
exit
fi
# check if module rpms exist and populate it if necessary or update it
if [ -d ~/$packageroot/rpms ]
then
# update current tree
cd ~/$packageroot/rpms
cvs -Q update -dPA 1>/dev/null
else
# checkout rpms
cd ~/$packageroot
cvs -Q -z3 -d:ext:shell.koozali.org:/cvs/$packageroot co -P rpms 1>/dev/null
fi

5
root/usr/bin/tagbuild Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
make tag
make build
echo ''
grep .spec ./CVS/Entries|cut -d'/' -f2|xargs cat|grep -i '^%changelog' -A5