Line 325: |
Line 325: |
| echo "###################################" | | echo "###################################" |
| fi | | fi |
| + | ===build_srpm=== |
| + | a script to build srpm, create the git repository, and export all files to github |
| + | |
| + | it creates automatically the new repository in github with your credentials (adjust 'stephdl' with your login account and replace 'xxxxxxxxxxxxxx' with your password) |
| + | |
| + | * usage |
| + | you must give arguments on the git branch (master, sme9 or anything else) and the package name : build_srpm package_name master |
| + | give the real name without number of version |
| + | |
| + | ###a bit of tests to see if we will not do a mess |
| + | if [[ -z $1 || -z $2 ]]; then |
| + | echo "################################################################################################################################" |
| + | echo "you must give arguments on the git branch (master, sme9 or anything else) and the package name : build_srpm package_name master" |
| + | echo "################################################################################################################################" |
| + | exit |
| + | fi |
| + | |
| + | if [[ -d ~/git_work/$1 && -d ~/git_work/$1-sdl ]]; then |
| + | echo"" |
| + | echo "###################################" |
| + | echo "the git directories ~/git_work/$1 and ~/git_work/$1-sdl are already created." |
| + | echo "please remove it before to play with the script" |
| + | echo "think also if you have a github project called stephdl/$1 and stephdl/$1-sdl" |
| + | echo "###################################" |
| + | exit |
| + | fi |
| + | # Create needed dirs on the build box |
| + | |
| + | mkdir -p ~/rpmbuild/{RPMS,SRPMS,SPECS,SOURCES,BUILD} |
| + | mkdir -p ~/exchange |
| + | |
| + | rpm -ivh $1*.src.rpm |
| + | cd ~/rpmbuild/SPECS |
| + | rpmbuild -bp --nodeps $1*.spec |
| + | |
| + | ##we remove all patch from the spec file |
| + | sed '/Patch/d' $1*.spec > $1.bis.spec |
| + | sed '/%patch/d' $1.bis.spec > $1.ter.spec |
| + | mv -f $1.ter.spec $1.spec |
| + | rm -f $1.bis.spec |
| + | |
| + | |
| + | ###test to see if the directory already exists in ~/git_work, if yes we use ~/git_work/package_name-sdl |
| + | if [[ ! -d ~/git_work/$1 ]]; then |
| + | |
| + | gitexist=0 |
| + | mkdir -p ~/git_work/$1 |
| + | NameGitHub=$1 |
| + | curl -u 'stephdl:xxxxxxxxxx' https://api.github.com/user/repos -d '{"name": "'"$NameGitHub"'" , "description": "A RPM for SME Server", "homepage": "http://wiki.contribs.org", "private": false, "has_issues": true, "has_wiki": true, "has_downloads": true}' |
| + | |
| + | cp -R ~/rpmbuild/BUILD/$1*/* ~/git_work/$1 |
| + | cp ~/rpmbuild/SPECS/$1.spec ~/git_work/$1 |
| + | cd ~/git_work/$1 |
| + | |
| + | |
| + | elif [[ -d ~/git_work/$1 ]]; then |
| + | |
| + | gitexist=1 |
| + | mkdir -p ~/git_work/$1-sdl |
| + | NameGitHub=$1-sdl |
| + | curl -u 'stephdl:xxxxxxxxx' https://api.github.com/user/repos -d '{"name": "'"$NameGitHub"'" , "description": "A RPM for SME Server", "homepage": "http://wiki.contribs.org", "private": false, "has_issues": true, "has_wiki": true, "has_downloads": true}' |
| + | |
| + | cp -R ~/rpmbuild/BUILD/$1*/* ~/git_work/$1-sdl |
| + | cp ~/rpmbuild/SPECS/$1.spec ~/git_work/$1-sdl |
| + | cd ~/git_work/$1-sdl |
| + | |
| + | fi |
| + | |
| + | |
| + | ###git work |
| + | |
| + | if [ ! -e README.md ]; then |
| + | touch README.md |
| + | echo "$1 is a RPM for SME Server, a Linux distro oriented server. see http://wiki.contribs.org" > README.md |
| + | fi |
| + | |
| + | ##fill empty directories |
| + | find * -type d -empty -exec touch {}/.gitignore \; |
| + | |
| + | git init |
| + | git add . |
| + | git commit -m "first commit to SME Server" |
| + | |
| + | if [[ $2 != 'master' ]]; then |
| + | git co -b $2 |
| + | fi |
| + | |
| + | if [[ $gitexist = "0" ]]; then |
| + | git remote add origin git@github.com:stephdl/$1 |
| + | git push -u -f origin $2 |
| + | |
| + | elif [[ $gitexist = "1" ]]; then |
| + | git remote add origin git@github.com:stephdl/$1-sdl |
| + | git push -u -f origin $2 |
| + | |
| + | fi |
| + | |
| + | |
| + | ##find the apache authentication |
| + | echo "" |
| + | echo "" |
| + | echo "we are looking if we need to modify the apache authentication" |
| + | testapache=$(grep -srni 'AuthType Basic' .) |
| + | if [[ $testapache =~ "AuthType Basic" ]]; then |
| + | echo "$testapache, go to work" |
| + | echo 'Only for SME9, you must add before $OUT .= " AuthBasicProvider external\n";' |
| + | |
| + | else |
| + | echo "no apache authentication" |
| + | fi |
| + | |
| + | ## help to write the changelog |
| + | myDate=$(LC_ALL=C date +"%a %b %d %Y") |
| + | echo "" |
| + | echo "* $myDate stephane de Labrusse <stephdl@de-labrusse.fr>" |
| + | echo "- Initial release to SME Server" |
| + | |
| + | # a bit of clean |
| + | |
| + | rm -rf ~/rpmbuild/SPECS/* ~/rpmbuild/SOURCES/* ~/rpmbuild/SRPMS/* ~/rpmbuild/BUILD/* |
| + | |
| + | ## say where we record the source code |
| + | if [[ $gitexist = "0" ]]; then |
| + | echo "" |
| + | echo " packages are in ~/git_work/$1" |
| + | elif [[ $gitexist = "1" ]]; then |
| + | echo "" |
| + | echo " packages are in ~/git_work/$1-sdl" |
| + | fi |