config 6.87 KB
Newer Older
1
#!/bin/bash
2 3
#
#    Copyright (C) 2008-2010  Rubén Rodríguez <ruben@trisquel.info>
Santiago Rodriguez committed
4
#    Copyright (C)      2014  Santiago Rodriguez <santi@trisquel.info>
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
#

set -e
Santiago Rodriguez committed
22
export LANG=C LC_TIME=C
23
PACKAGE=$(echo $0 |/bin/sed s/make-//g)
24 25 26

export DATE=$(date +'%a, %d %b %Y %T %z')

27 28 29 30
export DATA=$PWD/DATA/$PACKAGE
if ! [ 1$COMPONENT = "1main" ]
then
    COMPONENT=${COMPONENT:-universe}
31
    export NO_PKG_MANGLE=1
32 33 34 35 36 37 38
fi

[ -d PACKAGES ] || mkdir PACKAGES

export DEBIAN_FRONTEND=noninteractive
export DEBEMAIL=trisquel-devel@listas.trisquel.info
export DEBFULLNAME="Trisquel GNU/Linux developers"
39 40
export CODENAME=belenos
export REVISION=7.0
41 42
export RELEASE=trisquel
export DOMAIN=trisquel.info
43 44
export UPSTREAM=trusty
export UPSTREAMRELEASE=14.04
45
MIRROR=http://archive.ubuntu.com/ubuntu
Ruben Rodriguez committed
46
DEVELMIRROR=http://devel.trisquel.info/trisquel/$CODENAME
47
LOCALMIRROR=http://archive.trisquel.info/trisquel
48
LOCAL_APT=`mktemp -d` 
49

Legimet committed
50 51 52
pkgversion(){
	dpkg-parsechangelog --show-field Version
}
53
replace(){
54
find $3 -type f -not -iregex '.*changelog.*' -not -iregex '.*copyright.*' -execdir /bin/sed --follow-symlinks -i s^"$1"^"$2"^g {} \;
55 56
}
changelog(){
57
head -n 1 debian/changelog | grep -q $UPSTREAM-security && REPO=$CODENAME-security || REPO=$CODENAME
58
echo | dch -D $REPO -v `pkgversion`+${REVISION}trisquel${VERSION} "$1"
59 60 61

# Make sure the changelog file is identical between archs
/bin/sed "/-- Trisquel/s/.*/ -- Trisquel GNU\/Linux developers <trisquel-devel@listas.trisquel.info>  $DATE/" -i debian/changelog
62 63
}

64 65 66 67 68 69 70 71 72 73

#Setup local apt

trap "rm -rf ${LOCAL_APT}" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM

mkdir -p ${LOCAL_APT}/var/lib/apt/partial
mkdir -p ${LOCAL_APT}/var/cache/apt/archives/partial
mkdir -p ${LOCAL_APT}/etc/
mkdir -p ${LOCAL_APT}/var/lib/dpkg
touch ${LOCAL_APT}/var/lib/dpkg/status
74
touch ${LOCAL_APT}/etc/trusted.gpg
75 76 77 78 79 80 81 82 83 84

cat << EOF > ${LOCAL_APT}/etc/apt.conf
Dir::State "${LOCAL_APT}/var/lib/apt";
Dir::State::status "${LOCAL_APT}/var/lib/dpkg/status";
Dir::Etc::SourceList "${LOCAL_APT}/etc/apt.sources.list";
Dir::Cache "${LOCAL_APT}/var/cache/apt";
pkgCacheGen::Essential "none";
Dir::Etc::Trusted "${LOCAL_APT}/etc/trusted.gpg";
EOF

85 86 87 88
if [ -f trusted.local.gpg ]
then
cp trusted.local.gpg "${LOCAL_APT}/etc/trusted.gpg"
else
89 90 91 92 93 94 95 96
# Trisquel key
apt-key --keyring ${LOCAL_APT}/etc/trusted.gpg adv --keyserver keyserver.ubuntu.com --recv-keys B4EFB9F38D8AEBF1 > /dev/null
# Ubuntu gpg keys
apt-key --keyring ${LOCAL_APT}/etc/trusted.gpg adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 > /dev/null
apt-key --keyring ${LOCAL_APT}/etc/trusted.gpg adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 > /dev/null
# Debian gpg keys
apt-key --keyring ${LOCAL_APT}/etc/trusted.gpg adv --keyserver keyserver.ubuntu.com --recv-keys 9D6D8F6BC857C906 > /dev/null
apt-key --keyring ${LOCAL_APT}/etc/trusted.gpg adv --keyserver keyserver.ubuntu.com --recv-keys 8B48AD6246925553 > /dev/null
97 98
fi

99 100
# Also import the repository key optionally listed in the helper
[ "1$REPOKEY" != "1" ] && apt-key --keyring ${LOCAL_APT}/etc/trusted.gpg adv --recv-keys --keyserver keyserver.ubuntu.com $REPOKEY
101 102

cat << EOF > ${LOCAL_APT}/etc/apt.sources.list
103 104 105
deb-src $MIRROR $UPSTREAM main universe
deb-src $MIRROR $UPSTREAM-updates main universe
deb-src $MIRROR $UPSTREAM-security main universe
106

107 108
EOF

109 110
[ "1$EXTERNAL" != "1" ] && eval echo "$EXTERNAL" >> ${LOCAL_APT}/etc/apt.sources.list

111 112 113 114
#Cleanup
rm -rf PACKAGES/$PACKAGE
mkdir PACKAGES/$PACKAGE
cd PACKAGES/$PACKAGE
115

116
#Get package and uncompress it
117
apt-get update -c $LOCAL_APT/etc/apt.conf
118
apt-get source $PACKAGE --download-only -c ${LOCAL_APT}/etc/apt.conf
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
# Verify it first
#   Import the key for the package uploader
#   Use the one listed in the helper if available, otherwise download the one listed in the dsc
if [ "1$SIGNKEY" != "1" ] ; then
  apt-key --keyring ${LOCAL_APT}/etc/trusted.gpg adv --recv-keys --keyserver keyserver.ubuntu.com $SIGNKEY > /dev/null
  gpgv --keyring ${LOCAL_APT}/etc/trusted.gpg *.dsc
else
  if grep -q "BEGIN PGP SIGNATURE" *.dsc; then
    KEY=$(gpgv --keyring ${LOCAL_APT}/etc/trusted.gpg *.dsc 2>&1 | grep "key ID" | sed 's/.*key ID //' || true)
    apt-key --keyring ${LOCAL_APT}/etc/trusted.gpg adv --recv-keys --keyserver keyserver.ubuntu.com $KEY > /dev/null
    gpgv --keyring ${LOCAL_APT}/etc/trusted.gpg *.dsc
  else
    echo WARNING! The dsc file is not gpg signed!
    [ -z "$EXTERNAL" ] && exit 1
  fi
fi

mtsio committed
136
dpkg-source --no-check -x --skip-patches *.dsc source
137 138 139 140 141 142 143 144

find -maxdepth 1 -type f | xargs rm
cd source

#disable 3.0 deb source format
[ -f debian/source/format ] && rm debian/source/format
[ -f debian/source/options ] && rm debian/source/options

145 146 147 148
#for i in debian.master/control.stub.in debian.master/control.stub debian.master/control debian/control.stub.in debian/control.stub debian/control
#do
#    [ -f $i ] && /bin/sed "s_^Maintainer.*_Maintainer: $DEBFULLNAME <$DEBEMAIL>_g" -i $i
#done
149 150

compile(){
151

152 153

PROCESSORS=1
154
if [ 1$PARALLEL != "1false" ]
155 156 157 158
then
    PROCESSORS=$(grep processor /proc/cpuinfo | wc -l)
fi

159

160 161
if [ 1$QUILT != 1skip ]; then
export QUILT_PATCHES=debian/patches
162
grep -qv '^#' debian/patches/series 2>/dev/null && quilt push -a
163 164
fi

165 166
cd ..
dpkg-source -b source
167 168
rm -rf ${LOCAL_APT}
echo "Trisquel source package built!"
169 170

}
171

Ruben Rodriguez committed
172
sedhelper2(){
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
  FILE="$1"
  EXPR="$2"";"

  while [ 1"$EXPR" != 1 ];do
    SUBEXPR=$(cut -d\; -f 1 <<< "$EXPR")
    MD5=$(md5sum "$FILE")
    echo Running modification-aware sed: sed "$SUBEXPR" -i "$FILE"
    /bin/sed "$SUBEXPR" -i "$FILE"
    if [ "$MD5" = "$(md5sum "$FILE")" ]; then
      echo File "$FILE" was not modified, stopping.
      exit 1
    fi
    EXPR=$(cut -d\; -f 2- <<< "$EXPR" )
    echo $EXPR | egrep ';' -q || break
  done
}

Ruben Rodriguez committed
190 191 192 193 194 195 196 197 198 199 200 201 202
sedhelper(){
  FILE="$1"
  EXPR="$2"

  MD5=$(md5sum "$FILE")
  echo Running modification-aware sed: sed "$EXPR" -i "$FILE"
  /bin/sed "$EXPR" -i "$FILE"
  if [ "$MD5" = "$(md5sum "$FILE")" ]; then
    echo File "$FILE" was not modified, stopping.
    exit 1
  fi
}

203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
sed (){
if ! echo $@ | grep -qw '\-i'; then
  echo Running fallback sed: /bin/sed "$@"
  /bin/sed "$@"
else

[ 1"$1" = "1-i" ] && shift

  SEDEXPR="$1"
  shift
  for FILE in "$@"; do
  [ 1"$FILE" = "1-i" ] && continue
  if [ -f "$FILE" ]; then
    sedhelper "$FILE" "$SEDEXPR"
  else
    echo File "$FILE" does not exist, stopping.
    exit 1
  fi
  done
fi
}