MozillaFirefox/create-tar.sh
branchfirefox71
changeset 1117 d6a688186de0
parent 1114 572ec48f3fe8
child 1119 4c5d44d40a03
equal deleted inserted replaced
1116:52b1745787cf 1117:d6a688186de0
    40 FTP_URL="https://ftp.mozilla.org/pub/$PRODUCT/releases/$VERSION$VERSION_SUFFIX/source"
    40 FTP_URL="https://ftp.mozilla.org/pub/$PRODUCT/releases/$VERSION$VERSION_SUFFIX/source"
    41 FTP_CANDIDATES_BASE_URL="https://ftp.mozilla.org/pub/$PRODUCT/candidates"
    41 FTP_CANDIDATES_BASE_URL="https://ftp.mozilla.org/pub/$PRODUCT/candidates"
    42 # Make first letter of PRODCUT upper case
    42 # Make first letter of PRODCUT upper case
    43 PRODUCT_CAP="${PRODUCT^}"
    43 PRODUCT_CAP="${PRODUCT^}"
    44 LOCALES_URL="https://product-details.mozilla.org/1.0/l10n/$PRODUCT_CAP"
    44 LOCALES_URL="https://product-details.mozilla.org/1.0/l10n/$PRODUCT_CAP"
       
    45 PRODUCT_URL="https://product-details.mozilla.org/1.0/$PRODUCT.json"
    45 # Exit script on CTRL+C
    46 # Exit script on CTRL+C
    46 trap "exit" INT
    47 trap "exit" INT
    47 
    48 
    48 function get_ftp_candidates_url() {
    49 function get_ftp_candidates_url() {
    49   VERSION_WITH_SUFFIX="$1"
    50   VERSION_WITH_SUFFIX="$1"
    81 }
    82 }
    82 
    83 
    83 function get_source_stamp() {
    84 function get_source_stamp() {
    84   BUILD_ID="$1"
    85   BUILD_ID="$1"
    85   FTP_CANDIDATES_BASE_URL=$(get_ftp_candidates_url $VERSION$VERSION_SUFFIX)
    86   FTP_CANDIDATES_BASE_URL=$(get_ftp_candidates_url $VERSION$VERSION_SUFFIX)
    86   FTP_CANDIDATES_JSON_SUFFIX="${BUILD_ID}/linux-x86_64/en-US/firefox-$VERSION$VERSION_SUFFIX.json"
    87   FTP_CANDIDATES_JSON_SUFFIX="${BUILD_ID}/linux-x86_64/en-US/$PRODUCT-$VERSION$VERSION_SUFFIX.json"
    87   BUILD_JSON=$(curl --silent --fail "$FTP_CANDIDATES_BASE_URL/$FTP_CANDIDATES_JSON_SUFFIX") || return 1;
    88   BUILD_JSON=$(curl --silent --fail "$FTP_CANDIDATES_BASE_URL/$FTP_CANDIDATES_JSON_SUFFIX") || return 1;
    88   REV=$(echo "$BUILD_JSON" | jq .moz_source_stamp)
    89   REV=$(echo "$BUILD_JSON" | jq .moz_source_stamp)
    89   SOURCE_REPO=$(echo "$BUILD_JSON" | jq .moz_source_repo)
    90   SOURCE_REPO=$(echo "$BUILD_JSON" | jq .moz_source_repo)
    90   TIMESTAMP=$(echo "$BUILD_JSON" | jq .buildid)
    91   TIMESTAMP=$(echo "$BUILD_JSON" | jq .buildid)
    91   echo "Extending $TAR_STAMP with:"
    92   echo "Extending $TAR_STAMP with:"
   102 }
   103 }
   103 
   104 
   104 function get_build_number() {
   105 function get_build_number() {
   105   LAST_FOUND=""
   106   LAST_FOUND=""
   106   VERSION_WITH_SUFFIX="$1"
   107   VERSION_WITH_SUFFIX="$1"
   107   FTP_CANDIDATES_BASE_URL=$(get_ftp_candidates_url $VERSION_WITH_SUFFIX)
   108 
   108   # Unfortunately, locales-files are not associated to releases, but to builds.
   109   BUILD_ID=$(curl --silent "$PRODUCT_URL" | jq -e '.["releases"] | .["'$PRODUCT-$VERSION_WITH_SUFFIX'"] | .["build_number"]')
   109   # And since we don't know which build was the final build, we grep them all from
   110 
   110   # the candidates-page, sort them and take the last one which should be the oldest
   111   # Slow fall-back
   111   # Error only if not even the first one exists
   112   if [ $? -ne 0 ]; then
   112   LAST_FOUND=$(curl --silent --fail "$FTP_CANDIDATES_BASE_URL/" | grep -o "build[0-9]*/" | sort | uniq | tail -n 1 | cut -d "/" -f 1)
   113       echo "Build number not found in product URL, falling back to slow FTP-parsing." 1>&2
       
   114       FTP_CANDIDATES_BASE_URL=$(get_ftp_candidates_url $VERSION_WITH_SUFFIX)
       
   115       # Unfortunately, locales-files are not associated to releases, but to builds.
       
   116       # And since we don't know which build was the final build, we grep them all from
       
   117       # the candidates-page, sort them and take the last one which should be the oldest
       
   118       # Error only if not even the first one exists
       
   119       LAST_FOUND=$(curl --silent --fail "$FTP_CANDIDATES_BASE_URL/" | grep -o "build[0-9]*/" | sort | uniq | tail -n 1 | cut -d "/" -f 1)
       
   120   else
       
   121       LAST_FOUND="build$BUILD_ID"
       
   122   fi
   113 
   123 
   114   if [ "$LAST_FOUND" != "" ]; then
   124   if [ "$LAST_FOUND" != "" ]; then
   115     echo "$LAST_FOUND"
   125     echo "$LAST_FOUND"
   116     return 0
   126     return 0
   117   else
   127   else
   248   fi
   258   fi
   249 
   259 
   250   hg update --check $FF_RELEASE_TAG
   260   hg update --check $FF_RELEASE_TAG
   251   [ "$FF_RELEASE_TAG" == "default" ] || hg update -r $FF_RELEASE_TAG
   261   [ "$FF_RELEASE_TAG" == "default" ] || hg update -r $FF_RELEASE_TAG
   252   # get repo and source stamp
   262   # get repo and source stamp
   253   echo -n "REV=" > ../source-stamp.txt
   263   REV=$(hg -R . parent --template="{node|short}\n")
   254   hg -R . parent --template="{node|short}\n" >> ../source-stamp.txt
   264   SOURCE_REPO=$(hg showconfig paths.default 2>/dev/null | head -n1 | sed -e "s/^ssh:/http:/")
   255   echo -n "REPO=" >> ../source-stamp.txt
   265   TIMESTAMP=$(date +%Y%m%d%H%M%S)
   256   hg showconfig paths.default 2>/dev/null | head -n1 | sed -e "s/^ssh:/http:/" >> ../source-stamp.txt
       
   257 
   266 
   258   if [ "$PRODUCT" = "thunderbird" ]; then
   267   if [ "$PRODUCT" = "thunderbird" ]; then
   259     pushd comm || exit 1
   268     pushd comm || exit 1
   260     hg update --check $RELEASE_TAG
   269     hg update --check $RELEASE_TAG
   261     popd || exit 1
   270     popd || exit 1
   262     rm -rf thunderbird-${VERSION}/{,comm/}other-licenses/7zstub
   271     rm -rf thunderbird-${VERSION}/{,comm/}other-licenses/7zstub
   263   fi
   272   fi
   264   popd || exit 1
   273   popd || exit 1
       
   274 
       
   275   echo "Extending $TAR_STAMP with:"
       
   276   echo "RELEASE_REPO=${SOURCE_REPO}"
       
   277   echo "RELEASE_TAG=${REV}"
       
   278   echo "RELEASE_TIMESTAMP=${TIMESTAMP}"
       
   279 
       
   280   # We "remove and add" instead of "replace" in case the entries are not there yet
       
   281   # Removing the old RELEASE_-tags
       
   282   sed -i "/RELEASE_\(TAG\|REPO\|TIMESTAMP\)=.*/d" "$TAR_STAMP"
       
   283   # Appending the new 
       
   284   echo "RELEASE_REPO=$SOURCE_REPO" >> "$TAR_STAMP"
       
   285   echo "RELEASE_TAG=$REV" >> "$TAR_STAMP"
       
   286   echo "RELEASE_TIMESTAMP=$TIMESTAMP" >> "$TAR_STAMP"
   265 
   287 
   266   echo "creating archive..."
   288   echo "creating archive..."
   267   tar $compression -cf $PRODUCT-$VERSION$VERSION_SUFFIX.source.tar.xz --exclude=.hgtags --exclude=.hgignore --exclude=.hg --exclude=CVS $PRODUCT-$VERSION
   289   tar $compression -cf $PRODUCT-$VERSION$VERSION_SUFFIX.source.tar.xz --exclude=.hgtags --exclude=.hgignore --exclude=.hg --exclude=CVS $PRODUCT-$VERSION
   268 fi
   290 fi
   269 
   291