1*5e7646d2SAndroid Build Coastguard Worker#!/bin/sh 2*5e7646d2SAndroid Build Coastguard Worker# 3*5e7646d2SAndroid Build Coastguard Worker# Script to wait for jobs to complete. 4*5e7646d2SAndroid Build Coastguard Worker# 5*5e7646d2SAndroid Build Coastguard Worker# Copyright © 2008-2019 by Apple Inc. 6*5e7646d2SAndroid Build Coastguard Worker# 7*5e7646d2SAndroid Build Coastguard Worker# Licensed under Apache License v2.0. See the file "LICENSE" for more 8*5e7646d2SAndroid Build Coastguard Worker# information. 9*5e7646d2SAndroid Build Coastguard Worker# 10*5e7646d2SAndroid Build Coastguard Worker 11*5e7646d2SAndroid Build Coastguard Worker# 12*5e7646d2SAndroid Build Coastguard Worker# Get timeout from command-line 13*5e7646d2SAndroid Build Coastguard Worker# 14*5e7646d2SAndroid Build Coastguard Worker 15*5e7646d2SAndroid Build Coastguard Workerif test $# = 1; then 16*5e7646d2SAndroid Build Coastguard Worker timeout=$1 17*5e7646d2SAndroid Build Coastguard Workerelse 18*5e7646d2SAndroid Build Coastguard Worker timeout=360 19*5e7646d2SAndroid Build Coastguard Workerfi 20*5e7646d2SAndroid Build Coastguard Worker 21*5e7646d2SAndroid Build Coastguard Worker# 22*5e7646d2SAndroid Build Coastguard Worker# Figure out the proper echo options... 23*5e7646d2SAndroid Build Coastguard Worker# 24*5e7646d2SAndroid Build Coastguard Worker 25*5e7646d2SAndroid Build Coastguard Workerif (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then 26*5e7646d2SAndroid Build Coastguard Worker ac_n=-n 27*5e7646d2SAndroid Build Coastguard Worker ac_c= 28*5e7646d2SAndroid Build Coastguard Workerelse 29*5e7646d2SAndroid Build Coastguard Worker ac_n= 30*5e7646d2SAndroid Build Coastguard Worker ac_c='\c' 31*5e7646d2SAndroid Build Coastguard Workerfi 32*5e7646d2SAndroid Build Coastguard Worker 33*5e7646d2SAndroid Build Coastguard Workerecho $ac_n "Waiting for jobs to complete...$ac_c" 34*5e7646d2SAndroid Build Coastguard Workeroldjobs=0 35*5e7646d2SAndroid Build Coastguard Worker 36*5e7646d2SAndroid Build Coastguard Workerwhile test $timeout -gt 0; do 37*5e7646d2SAndroid Build Coastguard Worker jobs=`$runcups ../systemv/lpstat 2>/dev/null | wc -l | tr -d ' '` 38*5e7646d2SAndroid Build Coastguard Worker if test $jobs = 0; then 39*5e7646d2SAndroid Build Coastguard Worker break 40*5e7646d2SAndroid Build Coastguard Worker fi 41*5e7646d2SAndroid Build Coastguard Worker 42*5e7646d2SAndroid Build Coastguard Worker if test $jobs != $oldjobs; then 43*5e7646d2SAndroid Build Coastguard Worker echo $ac_n "$jobs...$ac_c" 44*5e7646d2SAndroid Build Coastguard Worker oldjobs=$jobs 45*5e7646d2SAndroid Build Coastguard Worker fi 46*5e7646d2SAndroid Build Coastguard Worker 47*5e7646d2SAndroid Build Coastguard Worker sleep 5 48*5e7646d2SAndroid Build Coastguard Worker timeout=`expr $timeout - 5` 49*5e7646d2SAndroid Build Coastguard Workerdone 50*5e7646d2SAndroid Build Coastguard Worker 51*5e7646d2SAndroid Build Coastguard Workerecho "" 52