summaryrefslogtreecommitdiff
path: root/bin/prioritize-build-list
blob: 20b11ae46f0bccfd2e9f83b0b14afd0147119460 (plain)
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
#!/bin/sh

. "${0%/*}/../conf/default.conf"

if [ $# -ne 1 ]; then
  echo 'Usage: prioritize-build-list pkg-regex'
  echo ' moves packages matching pkg-regex to front of build list'
  exit 2
fi

# Create a lock file for build list.

exec 9> "${build_list_lock_file}"
if ! flock -n 9; then
  >&2 echo 'come back (shortly) later - I cannot lock build list.'
  exit 1
fi

(
  sed -n "/^$1/p" "${work_dir}/build-list"
  sed "/^$1/d" "${work_dir}/build-list"
) | \
  sponge "${work_dir}/build-list"

# Remove the lock file

rm -f "${build_list_lock_file}"