MozillaFirefox/create-tar.sh
branchfirefox101
changeset 1174 90e3d0cf8567
parent 1173 56ecd2ae6e61
child 1184 1c3d3217d679
equal deleted inserted replaced
1173:56ecd2ae6e61 1174:90e3d0cf8567
    35 else
    35 else
    36   LOCALE_FILE="thunderbird-$VERSION/comm/mail/locales/l10n-changesets.json"
    36   LOCALE_FILE="thunderbird-$VERSION/comm/mail/locales/l10n-changesets.json"
    37 fi
    37 fi
    38 
    38 
    39 SOURCE_TARBALL="$PRODUCT-$VERSION$VERSION_SUFFIX.source.tar.xz"
    39 SOURCE_TARBALL="$PRODUCT-$VERSION$VERSION_SUFFIX.source.tar.xz"
    40 PREV_SOURCE_TARBALL="$PRODUCT-$PREV_VERSION$PREV_VERSION_SUFFIX.source.tar.xz"
       
    41 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"
    42 FTP_CANDIDATES_BASE_URL="https://ftp.mozilla.org/pub/$PRODUCT/candidates"
    41 FTP_CANDIDATES_BASE_URL="https://ftp.mozilla.org/pub/$PRODUCT/candidates"
    43 # Make first letter of PRODCUT upper case
    42 # Make first letter of PRODCUT upper case
    44 PRODUCT_CAP="${PRODUCT^}"
    43 PRODUCT_CAP="${PRODUCT^}"
    45 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"
   144     echo "Error: Could not find locales-file (json) for Firefox $TMP_VERSION !"  1>&2
   143     echo "Error: Could not find locales-file (json) for Firefox $TMP_VERSION !"  1>&2
   145     return 1
   144     return 1
   146   fi
   145   fi
   147 }
   146 }
   148 
   147 
   149 function locales_parse_file() {
   148 function locales_parse() {
   150   FILE="$1"
       
   151   cat "$FILE" | python -c "import json; import sys; \
       
   152              print('\n'.join(['{} {}'.format(key, value['revision']) \
       
   153                 for key, value in sorted(json.load(sys.stdin).items())]));"
       
   154 }
       
   155 
       
   156 function locales_parse_url() {
       
   157   URL="$1"
   149   URL="$1"
   158   curl -s "$URL" | python -c "import json; import sys; \
   150   curl -s "$URL" | python -c "import json; import sys; \
   159              print('\n'.join(['{} {}'.format(key, value['changeset']) \
   151              print('\n'.join(['{} {}'.format(key, value['changeset']) \
   160                 for key, value in sorted(json.load(sys.stdin)['locales'].items())]));"
   152                 for key, value in sorted(json.load(sys.stdin)['locales'].items())]));"
   161 }
       
   162 
       
   163 function extract_locales_file() {
       
   164     # still need to extract the locale information from the archive
       
   165     echo "extract locale changesets"
       
   166     tar -xf $SOURCE_TARBALL $LOCALE_FILE
       
   167 }
   153 }
   168 
   154 
   169 function locales_unchanged() {
   155 function locales_unchanged() {
   170   BUILD_ID="$1"
   156   BUILD_ID="$1"
   171   PREV_BUILD_ID=$(get_build_number "$PREV_VERSION$PREV_VERSION_SUFFIX")
   157   PREV_BUILD_ID=$(get_build_number "$PREV_VERSION$PREV_VERSION_SUFFIX")
   172   # If no json-file for one of the versions can be found, we say "they changed"
   158   # If no json-file for one of the versions can be found, we say "they changed"
   173   prev_url=$(locales_get "$PREV_VERSION$PREV_VERSION_SUFFIX" "$PREV_BUILD_ID") || return 1
   159   prev_url=$(locales_get "$PREV_VERSION$PREV_VERSION_SUFFIX" "$PREV_BUILD_ID") || return 1
   174   prev_content=$(locales_parse_url "$prev_url") || exit 1
   160   curr_url=$(locales_get "$VERSION$VERSION_SUFFIX" "$BUILD_ID")           || return 1
   175 
   161 
   176   curr_url=$(locales_get "$VERSION$VERSION_SUFFIX" "$BUILD_ID")
   162   prev_content=$(locales_parse "$prev_url") || exit 1
   177   if [ $? -ne 0 ]; then
   163   curr_content=$(locales_parse "$curr_url") || exit 1
   178     # We did not find a locales file upstream on the servers
       
   179     if [ -e $SOURCE_TARBALL ]; then
       
   180         # We can find out what the locales are, by extracting the json-file from the tar-ball
       
   181         # instead of getting it from the server
       
   182         extract_locales_file || return 1
       
   183         curr_content=$(locales_parse_file "$LOCALE_FILE") || exit 1
       
   184       else 
       
   185         # We can't know what the locales are in the current version
       
   186         return 1
       
   187       fi
       
   188   else
       
   189     curr_content=$(locales_parse_url "$curr_url") || exit 1
       
   190   fi
       
   191 
   164 
   192   diff -y --suppress-common-lines -d <(echo "$prev_content") <(echo "$curr_content")
   165   diff -y --suppress-common-lines -d <(echo "$prev_content") <(echo "$curr_content")
   193 }
   166 }
   194 
   167 
   195 # check required tools
   168 # check required tools
   236 fi
   209 fi
   237 
   210 
   238 # we might have an upstream archive already and can skip the checkout
   211 # we might have an upstream archive already and can skip the checkout
   239 if [ -e $SOURCE_TARBALL ]; then
   212 if [ -e $SOURCE_TARBALL ]; then
   240   if [ -z ${SKIP_LOCALES+x} ] && [ $LOCALES_CHANGED -ne 0 ]; then
   213   if [ -z ${SKIP_LOCALES+x} ] && [ $LOCALES_CHANGED -ne 0 ]; then
   241     extract_locales_file
   214     # still need to extract the locale information from the archive
       
   215     echo "extract locale changesets"
       
   216     tar -xf $SOURCE_TARBALL $LOCALE_FILE
   242   fi
   217   fi
   243   get_source_stamp "$BUILD_ID"
   218   get_source_stamp "$BUILD_ID"
   244 else
   219 else
   245   # We are working on a version that is not yet published on the mozilla mirror
   220   # We are working on a version that is not yet published on the mozilla mirror
   246   # so we have to actually check out the repo
   221   # so we have to actually check out the repo
   351   # Locales did not change, but the old tar-ball is in this directory
   326   # Locales did not change, but the old tar-ball is in this directory
   352   # Simply rename it:
   327   # Simply rename it:
   353   echo "Moving l10n-$PREV_VERSION$PREV_VERSION_SUFFIX.tar.xz to l10n-$VERSION$VERSION_SUFFIX.tar.xz"
   328   echo "Moving l10n-$PREV_VERSION$PREV_VERSION_SUFFIX.tar.xz to l10n-$VERSION$VERSION_SUFFIX.tar.xz"
   354   mv "l10n-$PREV_VERSION$PREV_VERSION_SUFFIX.tar.xz" "l10n-$VERSION$VERSION_SUFFIX.tar.xz"
   329   mv "l10n-$PREV_VERSION$PREV_VERSION_SUFFIX.tar.xz" "l10n-$VERSION$VERSION_SUFFIX.tar.xz"
   355 fi
   330 fi
   356 
       
   357 if [ -e $PREV_SOURCE_TARBALL ]; then
       
   358     echo ""
       
   359     echo "Deleting old sources tarball $PREV_SOURCE_TARBALL"
       
   360     $(ask_cont_abort_question "Is this ok?") || exit 0
       
   361     rm "$PREV_SOURCE_TARBALL"
       
   362     rm "$PREV_SOURCE_TARBALL.asc"
       
   363 fi