summaryrefslogtreecommitdiffstats
path: root/redhat/buildenv.sh
blob: 029f29afa42c3e2192d52ebf6f8c248c12d62493 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash

# This file can be sourced in your .bashrc

TDE_BASEDIR=~/tde
[ -z "${TDE_VERSION}" ] && TDE_VERSION="14.0.5"
TDE_GITBASESRC=${TDE_BASEDIR}/tde.master
TDE_GITBASEPKG=${TDE_BASEDIR}/tde-packaging.master/redhat
TDE_TARBALLS=${TDE_BASEDIR}/tde-tarballs/${TDE_VERSION}

[ -d "${TDE_PACKAGING_DIR}" ] || export TDE_PACKAGING_DIR=~/tde/tde-packaging.master

export PATH="${PATH}:${TDE_GITBASEPKG}/build"

# Distribution suffix (e.g: .el6 , .mga3 ...)
export DIST="$( "${TDE_GITBASEPKG}/build/rpmdist.sh" --dist )"

# Go to the RPMS folder
alias cdrpm='cd ~/rpmbuild/RPMS/RPMS${DIST}'

# Build a single tarball (execute from GIT directory)
alias tdp4='TARGET=${TDE_VERSION} SUFFIX=0 TARBALL_DIR=${TDE_TARBALLS}/main COMPRESS=gzip ${TDE_GITBASESRC}/scripts/create_tarball'

# Rebuild all tarballs
if [ -x /usr/bin/pigz ]; then
  export TDE_COMPRESS=pigz
else
  export TDE_COMPRESS=gzip
fi
alias tdep3='(rm -rf ~/tde/tde-tarballs/3.5.13.2; cd ~/tde/tde_v3.5.13-sru; export SUFFIX=0; export COMPRESS=${TDE_COMPRESS:-gzip}; export TDE_REBRAND=1; ./scripts/create_all_tarballs)'
alias tdep4='(cd ${TDE_GITBASESRC}; export SUFFIX=0; export COMPRESS=${TDE_COMPRESS:-gzip}; export TDE_REBRAND=1; ./scripts/create_all_tarballs)'

# Build a single package
alias cdp='cd ~/tde/tde-packaging/redhat'

grp3() {
  build_rpm_package.sh "${1}" "3.5.13.2"
}

grp4() {
  build_rpm_package.sh "${1}" "${TDE_VERSION}"
}

# Check if tarballs are more recent than installed packages
checknew() {
  find ~/tde/tde-tarballs/${TDE_VERSION} -name "trinity-*.tar.gz" | while read f; do
    TAR="${f##*/}"
    NAME="${TAR%-*}"
    
    if rpm -q "${NAME}" &>/dev/null; then
      set $(rpm -q --qf "%{name} ${TDE_VERSION} %{release}" ${NAME} )
      B="$1-$2~${3#*_}"
      A=${TAR%.tar.gz}
      B=${B%.opt}
      B=${B%${DIST}}
      if [[ "$A" > "$B" ]]; then
        echo "Installed: $B"
        echo "Available: $A"
        echo
      fi
    fi
  done
}


do_optimizegraphics() {
  if ! (which optipng && which advdef && which pngout) ; then
    echo "Missing utility ! Check that 'optipng', 'advdef' and 'pngout' utilities are available !"
    return 1
  fi
  
  while read m; do
    if [ -d "${m}" ]; then
      pushd "${m}"
      if [ -r .optimizegraphics ]; then
        echo "Graphics are already optimized !"
      else
        optimizegraphics
        touch .optimizegraphics
      fi
      popd
    fi
  done < submodules
}

alias rr='rpm -qa --qf "%{name}|%{buildhost}|%{packager}\n" | grep -e "\(\.vtf\|andriot\)"|cut -d"|" -f1 | sort'

# Update main repository
alias tdu='(export GIT_ASKPASS=/bin/true; cd ~/tde/tde_master; ./scripts/switch_all_submodules_to_head_and_clean)'

# Build local repository metadata (Mageia)
alias cru='(cdrpm; genhdlist2 --allow-empty-media noarch; genhdlist2 $(uname -i); sudo urpmi.update rpmbuild.$(uname -i) rpmbuild.noarch)'
alias cruc='(cdrpm; genhdlist2 --clean --allow-empty-media  noarch; genhdlist2 --clean $(uname -i); sudo urpmi.update rpmbuild.$(uname -i) rpmbuild.noarch)'

# Build local repository (RHEL)
alias cry='(cdrpm; createrepo $(uname -i); createrepo noarch; sudo yum clean all --disablerepo="*" --enablerepo="rpmbuild*")'
alias sy='sudo yum localinstall -y --nogpgcheck'

# Build local repository (openSUSE)
alias crz='(cdrpm; createrepo $(uname -i); createrepo noarch; sudo zypper refresh)'

# Build local repository (PCLOS)
alias cra='(cdrpm; genpkglist $PWD noarch; genpkglist $PWD i586; genpkglist $PWD x86_64; genbasedir $PWD i586 x86_64 noarch; sudo apt-get update)'
alias crac='(cdrpm; for i in i586 noarch x86_64; do cd $i; tdesortrpm.sh; cd -; done; rpmsign --addsign */RPMS.*/*.rpm; for i in i586 noarch x86_64; do for j in 3rdparty applications dependencies extras libraries main; do genpkglist $PWD/$i $j; done; done; for i in i586 noarch x86_64; do genbasedir $PWD/$i 3rdparty applications dependencies extras libraries main; done; sudo apt-get update)'
alias cras='(cdrpm; cd $(uname -i); rm -rf base; mkdir base; for i in 3rdparty applications dependencies extras libraries main; do genpkglist $PWD $i; done; genbasedir $PWD 3rdparty applications dependencies extras libraries main; cd ../noarch; rm -rf base; mkdir base; for i in applications dependencies extras main; do genpkglist $PWD $i; done; genbasedir $PWD applications dependencies extras main )'

# Reinstall packages (Mageia)
getrpmfromsrpm() {
  rpm -qa --qf "%{name} %{sourcerpm}\n"|grep "$1"|awk '{print $1}'
}
reinst() {
  sudo urpmi --replacepkgs --allow-force $(getrpmfromsrpm $1)
}