annotate sources/toys/unique-port.sh @ 972:cfa6262528f3

Genericize native build. Break out dropbear and strace packages from download.sh (and clean up what remains, mirror list is now in include.sh). New script setup-native.build.sh downloads, extracts, and creates a system image with "here document" build script to build dropbear and strace. New native-build.sh script works on arbitrary hdc image, providing FTP upload to a directory. The setup/fork logic to build all architectures is now in buildall.sh for this, just like everything else. Update buildall.sh to take optional list of architectures to build on command line. Factor out unique-port.sh (in embeddable manner) so distcc (in run-emulator.sh) and ftp server (in native-build.sh) can both use it. Upgrade to new busybox version while we're there. HGi removed sources/more/setup-native-static-build.sh
author Rob Landley <rob@landley.net>
date Fri, 05 Feb 2010 10:33:06 -0600
parents
children 94b0b4ef1157
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
972
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 #!/bin/bash
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
2
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 unique_port()
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
4 {
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 # Try to find a unique port number for each running instance of the program.
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
6
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 # To reduce the chance of the port already being in use by another program,
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 # we use a range either before or after that used by normal programs, but
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 # beyond that allocated to most persistent demons. There's a small chance
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
10 # even these ports are already in use, but this at least prevents
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 # simultaneous run-emulator instances for different targets from
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
12 # trivially interfering with each other.
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
13
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 START=8192
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
15 RANGE=$[$(awk '{print $1}' /proc/sys/net/ipv4/ip_local_port_range)-$START]
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 if [ $RANGE -lt 1 ]
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 then
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 START=$[$(awk '{print $2}' /proc/sys/net/ipv4/ip_local_port_range)]
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 RANGE=$[65535-$START]
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 fi
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 echo $[($$%$RANGE)+$START]
cfa6262528f3 Genericize native build.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 }