• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# This script takes a checksum file and merges it into the packages
8# checksum file in ../packages/packages.checksum.
9
10# This script is thread-safe.
11
12set -e
13
14function main () {
15  local merge_file="$1"
16  local packages_dir="$(dirname $0)/../packages"
17  local checksum_file="${packages_dir}/packages.checksum"
18
19  # Preparatory work.
20  mkdir -p "${packages_dir}"
21  touch ${checksum_file}
22
23  if [ ! -f "${merge_file}" ]; then
24    return
25  fi
26
27  # This operation is performed using an flock on the packages dir
28  # to allow it to run concurrently.
29  flock "${packages_dir}" \
30    -c "sort -k2,2 -u ${merge_file} ${checksum_file} -o ${checksum_file}"
31}
32
33if [ $# != 1 ]; then
34  echo "Not enough arguments."
35  exit 1
36fi
37
38main $1
39