Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 90e5fe36d89c8f73dfba20a695623401eec098f8 (plain) (blame)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#!/bin/bash

if [[ "$GIT" == "" ]]; then
  GIT=$WORKSPACE/git
fi

if [[ "$PACK_AND_SIGN" == "" ]]; then
  PACK_AND_SIGN=false
fi

set -o nounset
set -o errexit

###########################################################################
echo ""

rm -rf $WORKSPACE/updates
mkdir $WORKSPACE/updates
cp -a $GIT/sites/org.eclipse.oomph.site/target/repository/* $WORKSPACE/updates

cd $WORKSPACE/updates
echo "Zipping update site"
zip -r -9 -qq org.eclipse.oomph.site.zip * -x plugins/*.pack.gz

PRODUCTS=$WORKSPACE/products
rm -rf $PRODUCTS
mkdir $PRODUCTS

TMP=$WORKSPACE/eclipse-installer

# DISABLE THIS WHOLE PART!

if [[ false == true ]]; then
SOURCE=$GIT/products/org.eclipse.oomph.setup.installer.product/target/products
cd $SOURCE

for f in *.zip *.tar.gz; do
  echo "Repackaging $f"

  rm -rf $TMP
  mkdir $TMP
  cd $TMP

  if [[ $f == *x86_64* ]]; then
    bitness=64
  else
    bitness=32
  fi

  unzip -qq $SOURCE/$f

  inifile=eclipse-inst.ini
  if [[ $f == *macosx* ]]; then
    inifile="Eclipse Installer.app/Contents/Eclipse/$inifile"
  fi

  sed -e 's/^Eclipse.*Installer$/Eclipse Installer/' "$inifile" > "$inifile.tmp"
  mv "$inifile.tmp" "$inifile"

  if [[ "$BUILD_TYPE" == "" || "$BUILD_TYPE" == none || "$BUILD_TYPE" == nightly ]]; then
    echo "-Doomph.installer.update.url=https://download.eclipse.org/oomph/products/latest/repository" >> "$inifile"
    echo "-Doomph.update.url=https://download.eclipse.org/oomph/updates/latest" >> "$inifile"
  fi

  if [[ $f == *macosx* ]]; then
    if [[ "$PACK_AND_SIGN" == true ]]; then
      echo "  Signing Eclipse Installer.app"
      chmod -R a-st "Eclipse Installer.app"
      zip -r -q unsigned.zip "Eclipse Installer.app"
      rm -rf "Eclipse Installer.app"
      #curl -o signed.zip -F file=@unsigned.zip -F entitlements=@$GIT/releng/org.eclipse.oomph.releng/hudson/installer.entitlements http://172.30.206.146:8282/macosx-signing-service/1.0.1-SNAPSHOT
      curl -o signed.zip -F file=@unsigned.zip -F entitlements=@$GIT/releng/org.eclipse.oomph.releng/hudson/installer.entitlements https://cbi.eclipse.org/macos/codesign/sign

      actualSize=$(wc -c signed.zip | cut -f 1 -d ' ')
      if [ $actualSize -lt 40000000 ]; then
        echo "signed.zip is just $actualSize bytes large!"
        echo ""
        cat signed.zip
        echo ""
        exit 1
      fi

      unzip -qq signed.zip
      rm -f unsigned.zip signed.zip
    fi

    chmod -R a-st "Eclipse Installer.app"
    chmod a+x "Eclipse Installer.app/Contents/MacOS/eclipse-inst"
    echo "  Building eclipse-inst-mac$bitness.tar.gz"
    tar -czf $PRODUCTS/eclipse-inst-mac$bitness.tar.gz "Eclipse Installer.app"

    if [[ "$PACK_AND_SIGN" == true ]]; then
      echo "  Building eclipse-inst-mac$bitness.dmg"

      TIMESTAMP=$(date +%s%N)
      UNNOTARIZED_DMG=$PRODUCTS/eclipse-inst-mac$bitness.$TIMESTAMP.dmg
      curl -o $UNNOTARIZED_DMG --write-out '%{http_code}\n' -F sign=true -F source=@$PRODUCTS/eclipse-inst-mac$bitness.tar.gz https://cbi.eclipse.org/macos/packager/dmg/create

      echo "  Notarizing eclipse-inst-mac$bitness.$TIMESTAMP.dmg"
      RESPONSE=$(curl -X POST -F file=@$UNNOTARIZED_DMG -F 'options={"primaryBundleId": "app-bundle", "staple": true};type=application/json' https://cbi.eclipse.org/macos/xcrun/notarize)
      UUID=$(echo $RESPONSE | grep -Po '"uuid"\s*:\s*"\K[^"]+')
      STATUS=$(echo $RESPONSE | grep -Po '"status"\s*:\s*"\K[^"]+')
      echo "  Progress: $RESPONSE"

      while [[ $STATUS == 'IN_PROGRESS' ]]; do
        sleep 1m
        RESPONSE=$(curl -s https://cbi.eclipse.org/macos/xcrun/$UUID/status)
        STATUS=$(echo $RESPONSE | grep -Po '"status"\s*:\s*"\K[^"]+')
        echo "  Progress: $RESPONSE"
      done

      if [[ $STATUS != 'COMPLETE' ]]; then
        echo "Notarization failed: $RESPONSE"
        exit 1
      fi

      mv $UNNOTARIZED_DMG $UNNOTARIZED_DMG.unnotarized

      echo "  Downloading stapled result"

      curl -JO https://cbi.eclipse.org/macos/xcrun/$UUID/download

      echo "  Moving stapled notarized result"

      mv eclipse-inst-mac$bitness.$TIMESTAMP.dmg $PRODUCTS/eclipse-inst-mac$bitness.dmg
    fi

  elif [[ $f == *win32* ]]; then
    rm -f eclipsec.exe

    if [[ "$PACK_AND_SIGN" == true ]]; then
      echo "  Signing eclipse-inst.exe"
      curl -o signed.exe -F filedata=@eclipse-inst.exe https://cbi.eclipse.org/authenticode/sign
      mv signed.exe eclipse-inst.exe

      actualSize=$(wc -c eclipse-inst.exe | cut -f 1 -d ' ')
      if [ $actualSize -lt 200000 ]; then
        echo "eclipse-inst.exe is just $actualSize bytes large!"
        echo ""
        cat eclipse-inst.exe
        echo ""
        exit 1
      fi
    fi

    if [[ $OSTYPE == cygwin ||  $OSTYPE = msys ]]; then
      ZIP_OPTIONS="-r -9 -qq"
    else
      ZIP_OPTIONS="-r -9 -qq --symlinks"
    fi

    zip $ZIP_OPTIONS $PRODUCTS/$f *

    extractor=eclipse-inst-win$bitness.exe
    marker=$GIT/plugins/org.eclipse.oomph.extractor/marker.txt

    cp -a $GIT/plugins/org.eclipse.oomph.extractor/extractor-$bitness.exe extractor.exe

    echo "  Creating $extractor"
    cat extractor.exe \
      $marker \
      $GIT/plugins/org.eclipse.oomph.extractor.lib/target/org.eclipse.oomph.extractor.lib-*-SNAPSHOT.jar \
      $marker \
      $GIT/plugins/org.eclipse.oomph.extractor/Concat/descriptor-$bitness.txt \
      $marker \
      $PRODUCTS/$f \
      $marker > $PRODUCTS/$extractor

    rm -f $PRODUCTS/$f

    if [[ "$PACK_AND_SIGN" == true ]]; then
      echo "  Signing $extractor"
      curl -o $PRODUCTS/$extractor-signed -F filedata=@$PRODUCTS/$extractor https://cbi.eclipse.org/authenticode/sign
      cp -a $PRODUCTS/$extractor $WORKSPACE
      mv $PRODUCTS/$extractor-signed $PRODUCTS/$extractor

      actualSize=$(wc -c "$PRODUCTS/$extractor" | cut -f 1 -d ' ')
      if [ $actualSize -lt 40000000 ]; then
        echo "$PRODUCTS/$extractor is just $actualSize bytes large!"
        echo ""
        cat "$PRODUCTS/$extractor"
        echo ""
        exit 1
      fi
    fi

  elif [[ $f == *linux* ]]; then
    cd ..
    tar -czf $PRODUCTS/eclipse-inst-linux$bitness.tar.gz eclipse-installer
    cd $TMP
  fi
done

rm -rf $TMP
# DISABLE THIS WHOLE PART!
else
  TIMESTAMP=$(date +%s%N)
  echo "Copying repackaged-products"
  cd $GIT/products/org.eclipse.oomph.setup.installer.product/target/repackaged-products/
  for f in eclipse-inst*; do
    echo "Copying $f"
    if [[ $f == *.dmg ]]; then
      echo "Notarizing $f"
      UNNOTARIZED_DMG=${f/.dmg/}.$TIMESTAMP.dmg
      mkdir -p $TMP
      cp -a $f $TMP/$UNNOTARIZED_DMG
      cd $TMP

      RESPONSE=$(curl -X POST -F file=@$UNNOTARIZED_DMG -F 'options={"primaryBundleId": "app-bundle", "staple": true};type=application/json' https://cbi.eclipse.org/macos/xcrun/notarize)
      UUID=$(echo $RESPONSE | grep -Po '"uuid"\s*:\s*"\K[^"]+')
      STATUS=$(echo $RESPONSE | grep -Po '"status"\s*:\s*"\K[^"]+')
      echo "  Progress: $RESPONSE"

      while [[ $STATUS == 'IN_PROGRESS' ]]; do
        sleep 1m
        RESPONSE=$(curl -s https://cbi.eclipse.org/macos/xcrun/$UUID/status)
        STATUS=$(echo $RESPONSE | grep -Po '"status"\s*:\s*"\K[^"]+')
        echo "  Progress: $RESPONSE"
      done

      if [[ $STATUS != 'COMPLETE' ]]; then
        echo "Notarization failed: $RESPONSE"
        exit 1
      else
        mv $UNNOTARIZED_DMG $UNNOTARIZED_DMG.unnotarized
        echo "  Downloading stapled result"
        curl -JO https://cbi.eclipse.org/macos/xcrun/$UUID/download
        ls -sail
        echo "  Copying stapled notarized result"
        cp -a $UNNOTARIZED_DMG $PRODUCTS/$f
      fi

      cd -
      rm -rf $TMP
    else
      cp -a $f $PRODUCTS
    fi
  done
fi

cp -a $GIT/products/org.eclipse.oomph.setup.installer.product/target/repository $PRODUCTS

rm -rf $WORKSPACE/help
mkdir $WORKSPACE/help

cd $GIT
cp releng/org.eclipse.oomph.releng.helpcenter/html/* $WORKSPACE/help
cp releng/org.eclipse.oomph.releng.helpcenter/docs.txt $WORKSPACE/help/.docs

for i in $( cat releng/org.eclipse.oomph.releng.helpcenter/docs.txt | sed 's/\r//' ); do
  echo "Unzipping $i"
  unzip -qq plugins/$i/target/$i-*-SNAPSHOT.jar \
    "javadoc/*" \
    "schemadoc/*" \
    "html/*" \
    "images/*" \
    "about.html" \
    "plugin.properties" \
    -d $WORKSPACE/help/$i || echo "Ok"

  for j in $( find $WORKSPACE/help/$i/html -name "*.html" ); do
    sed -e 's/<!-- \(<div class="help_breadcrumbs.*\) -->/\1/g' $j > $j.tmp
    mv $j.tmp $j
  done
done

echo ""

Back to the top