mirror of
https://github.com/Interlisp/maiko.git
synced 2026-03-15 22:37:22 +00:00
Compare commits
22 Commits
sdl-textur
...
maiko-2206
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5f51d58f1 | ||
|
|
60af445afa | ||
|
|
a18f09d788 | ||
|
|
2bf7047709 | ||
|
|
90b967c8d3 | ||
|
|
b005501427 | ||
|
|
20046b265b | ||
|
|
e6a974a2a7 | ||
|
|
8ea2c76110 | ||
|
|
3e7c71c0c0 | ||
|
|
f2a3715930 | ||
|
|
f15d8eca09 | ||
|
|
008ce703e7 | ||
|
|
fa08a08648 | ||
|
|
bb0b011f90 | ||
|
|
6bccbfbcf3 | ||
|
|
e3af3b03b9 | ||
|
|
880747f2dc | ||
|
|
c7fd28a438 | ||
|
|
e1efc860c4 | ||
|
|
26fe840edf | ||
|
|
212a0fa9c6 |
84
.github/workflows/buildDocker.yml
vendored
84
.github/workflows/buildDocker.yml
vendored
@@ -1,84 +0,0 @@
|
||||
# based on https://blog.oddbit.com/post/2020-09-25-building-multi-architecture-im/
|
||||
---
|
||||
# Interlisp workflow to build a Docker Image that supports multiple architectures
|
||||
name: 'Build Maiko Docker image'
|
||||
|
||||
# Run this workflow on push to master
|
||||
# Other branches can be added it needed.
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
# Jobs that are run as part of this workflow.
|
||||
jobs:
|
||||
# Job to build the docker image
|
||||
# see: https://github.com/docker/build-push-action
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Checkout the branch
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Setup some environment variables
|
||||
- name: Prepare
|
||||
id: prep
|
||||
run: |
|
||||
# Name of the Docker Image.
|
||||
DOCKER_IMAGE=interlisp/${GITHUB_REPOSITORY#*/}
|
||||
VERSION=latest
|
||||
SHORTREF=${GITHUB_SHA::8}
|
||||
## Do we want to use tags and or versions
|
||||
# If this is git tag, use the tag name as a docker tag
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
VERSION=${GITHUB_REF#refs/tags/v}
|
||||
fi
|
||||
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}"
|
||||
# If the VERSION looks like a version number, assume that
|
||||
# this is the most recent version of the image and also
|
||||
# tag it 'latest'.
|
||||
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
||||
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
|
||||
fi
|
||||
# Set output parameters.
|
||||
echo ::set-output name=tags::${TAGS}
|
||||
echo ::set-output name=docker_image::${DOCKER_IMAGE}
|
||||
echo ::set-output name=build_time::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
# Setup the Docker Machine Emulation environment.
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@master
|
||||
with:
|
||||
platforms: all
|
||||
|
||||
# Setup the Docker Buildx funtion
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@master
|
||||
|
||||
# Login into DockerHub - required to store the created image
|
||||
- name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
# Start the Docker Build using the Dockerfile in the repository we
|
||||
# checked out.
|
||||
- name: Build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
build-args: BUILD_DATE=${{ steps.prep.outputs.build_time }}
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
# Platforms - Sepecify the platforms to include in the build
|
||||
# linux/amd64 -- Standard x86_64
|
||||
# linux/arm64 -- Apple M1
|
||||
# linux/arm/v7 -- Raspberry pi
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
# Push the result to DockerHub
|
||||
push: true
|
||||
# tags to assign to the Docker image
|
||||
tags: ${{ steps.prep.outputs.tags }}
|
||||
357
.github/workflows/buildReleaseInclDocker.yml
vendored
Normal file
357
.github/workflows/buildReleaseInclDocker.yml
vendored
Normal file
@@ -0,0 +1,357 @@
|
||||
#*******************************************************************************
|
||||
# buidReleaseInclDocker.yml
|
||||
#
|
||||
# Workflow to build a Maiko release that is pushed to github as well as
|
||||
# Docker images incorporating the release, which are pushed to Docker Hub.
|
||||
# For linux: release assets are built/pushed for X86_64, aarch64 and arm7vl and
|
||||
# a multiplatform Docker image is pushed.
|
||||
# For macOS: release assets are built/pushed for X86_64. (No aarch64 as yet.)
|
||||
# For Windows: not supported
|
||||
#
|
||||
# Note release pushed to github automatically includes source code assets
|
||||
# in tar and zip formats.
|
||||
#
|
||||
# 2022-01-16 by Frank Halasz based on earlier workflow called buildDocker.yml
|
||||
#
|
||||
# Copyright 2022 by Interlisp.org
|
||||
#
|
||||
#
|
||||
# ******************************************************************************
|
||||
|
||||
name: 'Build/Push Release & Docker Image'
|
||||
|
||||
env:
|
||||
workflow: 'buildReleaseInclDocker.yml'
|
||||
|
||||
# Run this workflow on ...
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
force:
|
||||
description: "Force build even if build already successfully completed for this commit"
|
||||
type: choice
|
||||
options:
|
||||
- 'false'
|
||||
- 'true'
|
||||
|
||||
workflow_call:
|
||||
secrets:
|
||||
DOCKER_USERNAME:
|
||||
required: true
|
||||
DOCKER_PASSWORD:
|
||||
required: true
|
||||
outputs:
|
||||
successful:
|
||||
description: "'True' if maiko build completed successully"
|
||||
value: ${{ jobs.complete.outputs.build_successful }}
|
||||
inputs:
|
||||
force:
|
||||
description: "Force build even if build already successfully completed for this commit"
|
||||
required: false
|
||||
type: string
|
||||
default: 'false'
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
# 2 separate jobs here that can run in parallel
|
||||
#
|
||||
# 1. Linux: Build/push a multiplatform Linux Docker image and use results to
|
||||
# build/push Linux release assets.
|
||||
#
|
||||
# 2. MacOs_x86_64: Build maiko for MacOS on X86_64 then create and push release assets.
|
||||
#
|
||||
|
||||
jobs:
|
||||
|
||||
######################################################################################
|
||||
|
||||
# Regularize the inputs so they can be referenced the same way whether they are
|
||||
# the result of a workflow_dispatch or a workflow_call
|
||||
|
||||
inputs:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
force: ${{ steps.force.outputs.force }}
|
||||
steps:
|
||||
- id: force
|
||||
run: >
|
||||
if [ '${{ toJSON(inputs) }}' = 'null' ];
|
||||
then echo ::set-output name=force::'${{ github.event.inputs.force }}'; echo "workflow_dispatch";
|
||||
else echo ::set-output name=force::'${{ inputs.force }}'; echo "workflow_call";
|
||||
fi
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
|
||||
# Use sentry-action to determine if this release has already been built
|
||||
# based on the latest commit to the repo
|
||||
|
||||
sentry:
|
||||
needs: inputs
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
release_not_built: ${{ steps.check.outputs.release_not_built }}
|
||||
|
||||
steps:
|
||||
# Checkout the actions for this repo owner
|
||||
- name: Checkout Actions
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: ${{ github.repository_owner }}/.github
|
||||
path: ./Actions_${{ github.sha }}
|
||||
- run: mv ./Actions_${{ github.sha }}/actions ../actions && rm -rf ./Actions_${{ github.sha }}
|
||||
|
||||
# Check if build already run for this commit
|
||||
- name: Build already completed?
|
||||
id: check
|
||||
continue-on-error: true
|
||||
uses: ./../actions/check-sentry-action
|
||||
with:
|
||||
tag: "release_docker"
|
||||
|
||||
######################################################################################
|
||||
|
||||
# Linux: build and push multi-platform docker image for Linux
|
||||
# Use docker images to create and push release assets to github
|
||||
|
||||
linux:
|
||||
|
||||
needs: [inputs, sentry]
|
||||
if: |
|
||||
needs.sentry.outputs.release_not_built == 'true'
|
||||
|| needs.inputs.outputs.force == 'true'
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Checkout the actions for this repo owner
|
||||
- name: Checkout Actions
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: ${{ github.repository_owner }}/.github
|
||||
path: ./Actions_${{ github.sha }}
|
||||
- run: mv ./Actions_${{ github.sha }}/actions ../actions && rm -rf ./Actions_${{ github.sha }}
|
||||
|
||||
# Checkout the branch
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Setup release tag
|
||||
- name: Setup Release Tag
|
||||
id: tag
|
||||
uses: ./../actions/release-tag-action
|
||||
|
||||
# Setup docker environment variables
|
||||
- name: Setup Docker Environment Variables
|
||||
id: docker_env
|
||||
run: |
|
||||
DOCKER_NAMESPACE=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
|
||||
echo "DOCKER_NAMESPACE=${DOCKER_NAMESPACE}" >> ${GITHUB_ENV}
|
||||
DOCKER_IMAGE=${DOCKER_NAMESPACE}/${{ steps.tag.outputs.repo_name }}
|
||||
DOCKER_TAGS="${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:${RELEASE_TAG#*-}"
|
||||
echo ::set-output name=build_time::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
echo ::set-output name=docker_tags::${DOCKER_TAGS}
|
||||
|
||||
# Setup the Docker Machine Emulation environment.
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@master
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
|
||||
# Setup the Docker Buildx funtion
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@master
|
||||
|
||||
# Login into DockerHub - required to store the created image
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
# Do the Docker Build using the Dockerfile in the repository we
|
||||
# checked out. Push the result to Docker Hub.
|
||||
#
|
||||
# NOTE: THE ACTUAL MAIKO BUILD (FOR LINUX) HAPPENS HERE - I.E., IN THE
|
||||
# DOCKER BUILD CALL. BUILD COMMANDS ARE SPECIFIED IN THE
|
||||
# Dockerfile, NOT HERE IN THE WORKFLOW.
|
||||
#
|
||||
- name: Build Docker Image for Push to Docker Hub
|
||||
if: ${{ true }}
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
build-args: |
|
||||
BUILD_DATE=${{ steps.docker_env.outputs.build_time }}
|
||||
RELEASE_TAG=${{ steps.tag.outputs.release_tag }}
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
# Push the result to DockerHub
|
||||
push: true
|
||||
tags: ${{ steps.docker_env.outputs.docker_tags }}
|
||||
|
||||
# Redo the Docker Build (hopefully mostly using the cache from the previous build).
|
||||
# But save the results in a directory under /tmp to be used for creating release tars.
|
||||
- name: Rebuild Docker Image For Saving Locally
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
build-args: |
|
||||
BUILD_DATE=${{ steps.docker_env.outputs.build_time }}
|
||||
RELEASE_TAG=${{ steps.tag.outputs.release_tag }}
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
# Put the results out to the local file system
|
||||
outputs: type=local,dest=/tmp/docker_images
|
||||
tags: ${{ steps.docker_env.outputs.docker_tags }}
|
||||
|
||||
# Use docker results to create releases for github.
|
||||
# Docker results are in /tmp/docker_images. One subdir for each platform.
|
||||
- name: Make release tars for each platform
|
||||
env:
|
||||
RELEASE_TAG: ${{ steps.tag.outputs.release_tag }}
|
||||
run: |
|
||||
mkdir -p /tmp/release_tars
|
||||
for OSARCH in "linux.x86_64:linux_amd64" "linux.aarch64:linux_arm64" "linux.armv7l:linux_arm_v7" ; \
|
||||
do \
|
||||
pushd /tmp/docker_images/${OSARCH##*:}/usr/local/interlisp >/dev/null ; \
|
||||
/usr/bin/tar -c -z \
|
||||
-f /tmp/release_tars/${RELEASE_TAG}-${OSARCH%%:*}.tgz \
|
||||
maiko/bin/osversion \
|
||||
maiko/bin/machinetype \
|
||||
maiko/bin/config.guess \
|
||||
maiko/bin/config.sub \
|
||||
maiko/${OSARCH%%:*}/lde* \
|
||||
; \
|
||||
popd >/dev/null ; \
|
||||
done
|
||||
|
||||
# Push Release to github
|
||||
- name: Push the release
|
||||
uses: ncipollo/release-action@v1.8.10
|
||||
with:
|
||||
allowUpdates: true
|
||||
artifacts:
|
||||
/tmp/release_tars/${{ steps.tag.outputs.release_tag }}-linux.x86_64.tgz,
|
||||
/tmp/release_tars/${{ steps.tag.outputs.release_tag }}-linux.aarch64.tgz,
|
||||
/tmp/release_tars/${{ steps.tag.outputs.release_tag }}-linux.armv7l.tgz
|
||||
tag: ${{ steps.tag.outputs.release_tag }}
|
||||
draft: true
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
|
||||
######################################################################################
|
||||
|
||||
# MacOS: build for MacOS (X86_64) and use results to
|
||||
# create and push release assets to github
|
||||
macos_x86_64:
|
||||
|
||||
needs: [inputs, sentry]
|
||||
if: |
|
||||
needs.sentry.outputs.release_not_built == 'true'
|
||||
|| needs.inputs.outputs.force == 'true'
|
||||
|
||||
runs-on: macos-10.15
|
||||
|
||||
steps:
|
||||
|
||||
# Checkout the branch
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Checkout the actions for this repo owner
|
||||
- name: Checkout Actions
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: ${{ github.repository_owner }}/.github
|
||||
path: ./Actions_${{ github.sha }}
|
||||
- run: mv ./Actions_${{ github.sha }}/actions ../actions && rm -rf ./Actions_${{ github.sha }}
|
||||
|
||||
# Setup release tag
|
||||
- name: Setup Release Tag
|
||||
id: tag
|
||||
uses: ./../actions/release-tag-action
|
||||
|
||||
# Install X11 dependencies
|
||||
- name: Install X11 dependencies on MacOS
|
||||
if: ${{ runner.os == 'macOS'}}
|
||||
run: brew install --cask xquartz
|
||||
|
||||
# Build maiko
|
||||
- name: Build
|
||||
working-directory: ./bin
|
||||
run: |
|
||||
./makeright x
|
||||
./makeright init
|
||||
|
||||
# Create release tar for github.
|
||||
- name: Make release tar(s)
|
||||
env:
|
||||
RELEASE_TAG: ${{ steps.tag.outputs.release_tag }}
|
||||
run: |
|
||||
mkdir -p /tmp/release_tars
|
||||
pushd ${GITHUB_WORKSPACE}/../ >/dev/null
|
||||
tar -c -z \
|
||||
-f /tmp/release_tars/${RELEASE_TAG}-darwin.x86_64.tgz \
|
||||
maiko/bin/osversion \
|
||||
maiko/bin/machinetype \
|
||||
maiko/bin/config.guess \
|
||||
maiko/bin/config.sub \
|
||||
maiko/darwin.x86_64/lde*
|
||||
popd >/dev/null
|
||||
|
||||
# Push Release
|
||||
- name: Push the release
|
||||
uses: ncipollo/release-action@v1.8.10
|
||||
with:
|
||||
allowUpdates: true
|
||||
artifacts:
|
||||
/tmp/release_tars/${{ steps.tag.outputs.release_tag }}-darwin.x86_64.tgz
|
||||
tag: ${{ steps.tag.outputs.release_tag }}
|
||||
draft: true
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
|
||||
# Use set-sentry-action to determine set the sentry that says this release has
|
||||
# been successfully built
|
||||
|
||||
complete:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
build_successful: ${{ steps.output.outputs.build_successful }}
|
||||
|
||||
needs: [inputs, sentry, linux, macos_x86_64]
|
||||
|
||||
steps:
|
||||
# Checkout the actions for this repo owner
|
||||
- name: Checkout Actions
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: ${{ github.repository_owner }}/.github
|
||||
path: ./Actions_${{ github.sha }}
|
||||
- run: mv ./Actions_${{ github.sha }}/actions ../actions && rm -rf ./Actions_${{ github.sha }}
|
||||
|
||||
# Set sentry
|
||||
- name: Is build for this commit already completed?
|
||||
id: set
|
||||
uses: ./../actions/set-sentry-action
|
||||
with:
|
||||
tag: "release_docker"
|
||||
|
||||
- name: Output
|
||||
id: output
|
||||
run: |
|
||||
echo ::set-output name=build_successful::'true'
|
||||
|
||||
######################################################################################
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,6 +6,8 @@
|
||||
.DS_Store
|
||||
# build directories
|
||||
build/**
|
||||
*.m68k-x/**
|
||||
*.m68k/**
|
||||
*.386-x/**
|
||||
*.386/**
|
||||
*.ppc-x/**
|
||||
|
||||
@@ -18,7 +18,7 @@ ENDIF()
|
||||
|
||||
find_program(
|
||||
CLANG_TIDY_EXE
|
||||
NAMES "clang-tidy" "clang-tidy12" "clang-tidy11" "clang-tidy10"
|
||||
NAMES "clang-tidy" "clang-tidy13" "clang-tidy12" "clang-tidy11" "clang-tidy10"
|
||||
DOC "Path to clang-tidy executable"
|
||||
)
|
||||
|
||||
@@ -390,7 +390,7 @@ SET(MAIKO_HDRS
|
||||
)
|
||||
|
||||
ADD_CUSTOM_TARGET(gen-vdate
|
||||
COMMAND mkvdate > vdate.c
|
||||
COMMAND ../bin/mkvdate > vdate.c
|
||||
BYPRODUCTS vdate.c
|
||||
)
|
||||
|
||||
@@ -422,10 +422,6 @@ IF(MAIKO_DISPLAY_X11)
|
||||
TARGET_LINK_LIBRARIES(ldex ${MAIKO_LIBRARIES} ${MAIKO_DISPLAY_X11_LIBRARIES})
|
||||
ENDIF()
|
||||
|
||||
ADD_EXECUTABLE(mkvdate src/mkvdate.c)
|
||||
TARGET_COMPILE_DEFINITIONS(mkvdate PUBLIC ${MAIKO_DEFINITIONS})
|
||||
TARGET_INCLUDE_DIRECTORIES(mkvdate PUBLIC inc)
|
||||
|
||||
ADD_EXECUTABLE(setsout src/setsout.c src/byteswap.c)
|
||||
TARGET_COMPILE_DEFINITIONS(setsout PUBLIC ${MAIKO_DEFINITIONS})
|
||||
TARGET_INCLUDE_DIRECTORIES(setsout PUBLIC inc)
|
||||
|
||||
63
Dockerfile
63
Dockerfile
@@ -1,18 +1,55 @@
|
||||
#*******************************************************************************
|
||||
#
|
||||
# Dockerfile to build Maiko (Stage 1) and create a Docker image and push it
|
||||
# to DockerHub (stage 2).
|
||||
#
|
||||
# Copyright 2022 by Interlisp.org
|
||||
#
|
||||
# ******************************************************************************
|
||||
|
||||
#
|
||||
# Build Maiko Stage
|
||||
#
|
||||
FROM ubuntu:focal AS builder
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
USER root:root
|
||||
# Install build tools
|
||||
RUN apt-get update && apt-get install -y make clang libx11-dev gcc x11vnc xvfb
|
||||
# Copy over / clean maiko repo
|
||||
COPY . /app/maiko
|
||||
RUN rm -rf /app/maiko/linux*
|
||||
# Build maiko
|
||||
WORKDIR /app/maiko/bin
|
||||
RUN ./makeright x
|
||||
RUN if [ "$(./osversion)" = "linux" ] && [ "$(./machinetype)" = "x86_64" ]; then ./makeright init; fi
|
||||
# Prep for Install Stage
|
||||
RUN mv ../$(./osversion).$(./machinetype) ../TRANSFER
|
||||
#
|
||||
# Install Maiko Stage
|
||||
#
|
||||
FROM ubuntu:focal
|
||||
ARG BUILD_DATE
|
||||
ARG BUILD_DATE="not_available"
|
||||
ARG RELEASE_TAG="not_available"
|
||||
LABEL name="Maiko"
|
||||
LABEL description="Virtual machine for Interlisp Medley"
|
||||
LABEL url="https://github.com/Interlisp/maiko"
|
||||
LABEL build-time=$BUILD_DATE
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
RUN apt-get update && apt-get install -y make clang libx11-dev gcc x11vnc xvfb
|
||||
|
||||
COPY --chown=nonroot:nonroot . /app/maiko
|
||||
RUN rm -rf /app/maiko/linux*
|
||||
|
||||
WORKDIR /app/maiko/bin
|
||||
RUN ./makeright x
|
||||
|
||||
RUN rm -rf /app/maiko/inc /app/maiko/include /app/maiko/src
|
||||
LABEL release_tag=$RELEASE_TAG
|
||||
ENV MAIKO_RELEASE=$RELEASE_TAG
|
||||
ENV MAIKO_BUILD_DATE=$BUILD_DATE
|
||||
ARG BUILD_LOCATION=/app/maiko
|
||||
ARG INSTALL_LOCATION=/usr/local/interlisp/maiko
|
||||
#
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
USER root:root
|
||||
# Copy release files into /usr/local/directories
|
||||
COPY --from=builder ${BUILD_LOCATION}/bin/osversion ${INSTALL_LOCATION}/bin/
|
||||
COPY --from=builder ${BUILD_LOCATION}/bin/machinetype ${INSTALL_LOCATION}/bin/
|
||||
COPY --from=builder ${BUILD_LOCATION}/bin/config.guess ${INSTALL_LOCATION}/bin/
|
||||
COPY --from=builder ${BUILD_LOCATION}/bin/config.sub ${INSTALL_LOCATION}/bin/
|
||||
COPY --from=builder ${BUILD_LOCATION}/TRANSFER/lde* ${INSTALL_LOCATION}/TRANSFER/
|
||||
RUN cd ${INSTALL_LOCATION} && mv TRANSFER "$(cd bin && ./osversion).$(cd bin/ && ./machinetype)"
|
||||
# Some niceties
|
||||
USER root
|
||||
WORKDIR /root
|
||||
ENTRYPOINT /bin/bash
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
os=${LDEARCH:-`./config.guess`}
|
||||
# o/s switch block
|
||||
case "$os" in
|
||||
m68k-*) echo m68k ;;
|
||||
sparc-*) echo sparc ;;
|
||||
alpha-*) echo alpha ;;
|
||||
i*86-*-*) echo 386 ;;
|
||||
|
||||
@@ -160,9 +160,6 @@ $(OSARCHDIR)$(LDENAME): $(LIBFILES) $(EXTFILES) $(OBJECTDIR)vdate.o
|
||||
$(OSARCHDIR)ldeether: $(OBJECTDIR)ldeether.o $(DLPIFILES)
|
||||
$(CC) $(OBJECTDIR)ldeether.o $(DLPIFILES) $(LDEETHERLDFLAGS) -o $(OSARCHDIR)ldeether
|
||||
|
||||
$(OSARCHDIR)mkvdate: $(OBJECTDIR)mkvdate.o $(REQUIRED-INCS)
|
||||
$(CC) $(OBJECTDIR)mkvdate.o $(LDFLAGS) -o $(OSARCHDIR)mkvdate
|
||||
|
||||
$(OSARCHDIR)tstsout: $(OBJECTDIR)tstsout.o $(BYTESWAPFILES) $(REQUIRED-INCS)
|
||||
$(CC) $(OBJECTDIR)tstsout.o $(BYTESWAPFILES) $(LDFLAGS) -lc -lm -o $(OSARCHDIR)tstsout
|
||||
|
||||
@@ -171,9 +168,9 @@ $(OSARCHDIR)setsout: $(OBJECTDIR)setsout.o $(REQUIRED-INCS)
|
||||
|
||||
#### Component files ######################################################
|
||||
|
||||
$(OBJECTDIR)vdate.o: $(LIBFILES) $(EXTFILES) $(OSARCHDIR)mkvdate
|
||||
$(OBJECTDIR)vdate.o: $(LIBFILES) $(EXTFILES) mkvdate
|
||||
$(RM) $(OBJECTDIR)vdate.c
|
||||
$(OSARCHDIR)mkvdate > $(OBJECTDIR)vdate.c
|
||||
$(BINDIR)mkvdate > $(OBJECTDIR)vdate.c
|
||||
$(CC) $(RFLAGS) $(OBJECTDIR)vdate.c -o $(OBJECTDIR)vdate.o
|
||||
|
||||
$(OBJECTDIR)tstsout.o: $(SRCDIR)tstsout.c $(REQUIRED-INCS) \
|
||||
@@ -197,9 +194,6 @@ $(OBJECTDIR)ldeboot.o: $(SRCDIR)ldeboot.c $(REQUIRED-INCS) \
|
||||
$(OBJECTDIR)ldeether.o: $(SRCDIR)ldeether.c $(REQUIRED-INCS)
|
||||
$(CC) $(RFLAGS) $(SRCDIR)ldeether.c -o $(OBJECTDIR)ldeether.o
|
||||
|
||||
$(OBJECTDIR)mkvdate.o: $(SRCDIR)mkvdate.c $(REQUIRED-INCS)
|
||||
$(CC) $(RFLAGS) $(SRCDIR)mkvdate.c -o $(OBJECTDIR)mkvdate.o
|
||||
|
||||
$(OBJECTDIR)main.o: $(SRCDIR)main.c $(REQUIRED-INCS) \
|
||||
$(INCDIR)lispemul.h $(INCDIR)dbprint.h \
|
||||
$(INCDIR)emlglob.h $(INCDIR)address.h $(INCDIR)adr68k.h $(INCDIR)stack.h \
|
||||
|
||||
5
bin/mkvdate
Executable file
5
bin/mkvdate
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
cat <<EOF
|
||||
#include <time.h>
|
||||
time_t MDate = $(date +%s);
|
||||
EOF
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/bin/sh
|
||||
os=`./config.guess`
|
||||
os=${LDEARCH:-`./config.guess`}
|
||||
case "$os" in
|
||||
m68k-*-amigaos) echo amigaos ;;
|
||||
sparc-sun-sunos*) echo sunos4 ;;
|
||||
sparc-sun-solaris1*) echo sunos4 ;;
|
||||
*-*-solaris2*) echo sunos5 ;;
|
||||
|
||||
@@ -3,6 +3,4 @@
|
||||
void stab(void);
|
||||
void warn(const char *s);
|
||||
int error(const char *s);
|
||||
int stackcheck(void);
|
||||
void stackoverflow(void);
|
||||
#endif
|
||||
|
||||
@@ -59,6 +59,13 @@
|
||||
# define MAIKO_OS_DETECTED 1
|
||||
#endif
|
||||
|
||||
#ifdef amigaos3
|
||||
# define MAIKO_OS_AMIGAOS3 1
|
||||
# define MAIKO_OS_NAME "AmigaOS 3"
|
||||
# define MAIKO_OS_UNIX_LIKE 1
|
||||
# define MAIKO_OS_DETECTED 1
|
||||
#endif
|
||||
|
||||
/* __SVR4: Defined by clang, gcc, and Sun Studio.
|
||||
* __SVR4__ was only defined by Sun Studio. */
|
||||
#if defined(__sun) && defined(__SVR4)
|
||||
@@ -137,6 +144,13 @@
|
||||
# define MAIKO_ARCH_DETECTED 1
|
||||
#endif
|
||||
|
||||
#ifdef __mc68000
|
||||
# define MAIKO_ARCH_M68000 1
|
||||
# define MAIKO_ARCH_NAME "Motorola68K"
|
||||
# define MAIKO_ARCH_WORD_BITS 32
|
||||
# define MAIKO_ARCH_DETECTED 1
|
||||
#endif
|
||||
|
||||
/* Modern GNU C, Clang, Sun Studio provide __BYTE_ORDER__
|
||||
* Older GNU C (ca. 4.0.1) provides __BIG_ENDIAN__/__LITTLE_ENDIAN__
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
/* */
|
||||
/************************************************************************/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "maiko/platform.h"
|
||||
|
||||
/************************************************************************/
|
||||
@@ -187,8 +188,8 @@ error Must specify RELEASE to build Medley.
|
||||
|
||||
/* Set up defaults */
|
||||
#define UNALIGNED_FETCH_OK
|
||||
#define UNSIGNED unsigned long
|
||||
#define INT long
|
||||
typedef uintptr_t UNSIGNED;
|
||||
typedef intptr_t INT;
|
||||
|
||||
|
||||
|
||||
@@ -237,9 +238,9 @@ typedef unsigned char u_char;
|
||||
typedef unsigned long u_int;
|
||||
typedef unsigned short u_short;
|
||||
#undef UNALIGNED_FETCH_OK
|
||||
#define USHORT unsigned
|
||||
typedef unsigned USHORT;
|
||||
#else
|
||||
#define USHORT unsigned short
|
||||
typedef unsigned short USHORT;
|
||||
#endif /* DOS */
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
36
src/common.c
36
src/common.c
@@ -141,39 +141,3 @@ uraidloop:
|
||||
|
||||
void warn(const char *s)
|
||||
{ printf("\nWARN: %s \n", s); }
|
||||
|
||||
/*****************************************************************
|
||||
stackcheck
|
||||
|
||||
common sub-routine.
|
||||
|
||||
Not Implemented.
|
||||
|
||||
1.check Stack overflow.
|
||||
(check CurrentStackPTR)
|
||||
2.if overflow, return T (not 0).
|
||||
Otherwise, return F (0).
|
||||
******************************************************************/
|
||||
int stackcheck() {
|
||||
#ifdef TRACE2
|
||||
printf("TRACE:stackcheck()\n");
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
stackoverflow
|
||||
|
||||
common sub-routine.
|
||||
|
||||
Not Implemented.
|
||||
|
||||
1.error handling of stack overflow.
|
||||
******************************************************************/
|
||||
|
||||
void stackoverflow() {
|
||||
#ifdef TRACE2
|
||||
printf("TRACE:stackoverflow()\n");
|
||||
#endif
|
||||
printf("stackoverflow \n");
|
||||
}
|
||||
|
||||
16
src/dir.c
16
src/dir.c
@@ -522,7 +522,7 @@ static int enum_dsk_prop(char *dir, char *name, char *ver, FINFO **finfo_buf)
|
||||
}
|
||||
|
||||
strcpy(namebuf, dirp.name);
|
||||
if (sbuf.st_mode & S_IFDIR) {
|
||||
if (S_ISDIR(sbuf.st_mode)) {
|
||||
nextp->dirp = 1;
|
||||
quote_dname(namebuf);
|
||||
strcpy(nextp->lname, namebuf);
|
||||
@@ -659,7 +659,7 @@ static int enum_dsk_prop(char *dir, char *name, char *ver, FINFO **finfo_buf)
|
||||
}
|
||||
|
||||
strcpy(namebuf, dp->d_name);
|
||||
if (sbuf.st_mode & S_IFDIR) {
|
||||
if (S_ISDIR(sbuf.st_mode)) {
|
||||
nextp->dirp = 1;
|
||||
quote_dname(namebuf);
|
||||
strcpy(nextp->lname, namebuf);
|
||||
@@ -800,7 +800,7 @@ static int enum_dsk(char *dir, char *name, char *ver, FINFO **finfo_buf)
|
||||
}
|
||||
|
||||
strcpy(namebuf, dirp.name); /* moved from below 2/26/93 */
|
||||
if (sbuf.st_mode & S_IFDIR) {
|
||||
if (S_ISDIR(sbuf.st_mode)) {
|
||||
nextp->dirp = 1;
|
||||
quote_dname(namebuf);
|
||||
strcpy(nextp->lname, namebuf);
|
||||
@@ -922,7 +922,7 @@ static int enum_dsk(char *dir, char *name, char *ver, FINFO **finfo_buf)
|
||||
}
|
||||
|
||||
strcpy(namebuf, dp->d_name);
|
||||
if (sbuf.st_mode & S_IFDIR) {
|
||||
if (S_ISDIR(sbuf.st_mode)) {
|
||||
nextp->dirp = 1;
|
||||
quote_dname(namebuf);
|
||||
strcpy(nextp->lname, namebuf);
|
||||
@@ -1025,7 +1025,7 @@ static int enum_ufs_prop(char *dir, char *name, char *ver, FINFO **finfo_buf)
|
||||
}
|
||||
|
||||
strcpy(namebuf, dirp.name);
|
||||
if (sbuf.st_mode & S_IFDIR) {
|
||||
if (S_ISDIR(sbuf.st_mode)) {
|
||||
nextp->dirp = 1;
|
||||
quote_dname(namebuf);
|
||||
strcpy(nextp->lname, namebuf);
|
||||
@@ -1117,7 +1117,7 @@ static int enum_ufs_prop(char *dir, char *name, char *ver, FINFO **finfo_buf)
|
||||
}
|
||||
|
||||
strcpy(namebuf, dp->d_name);
|
||||
if (sbuf.st_mode & S_IFDIR) {
|
||||
if (S_ISDIR(sbuf.st_mode)) {
|
||||
nextp->dirp = 1;
|
||||
quote_dname(namebuf);
|
||||
strcpy(nextp->lname, namebuf);
|
||||
@@ -1224,7 +1224,7 @@ static int enum_ufs(char *dir, char *name, char *ver, FINFO **finfo_buf)
|
||||
}
|
||||
|
||||
strcpy(namebuf, dirp.name);
|
||||
if (sbuf.st_mode & S_IFDIR) {
|
||||
if (S_ISDIR(sbuf.st_mode)) {
|
||||
nextp->dirp = 1;
|
||||
quote_dname(namebuf);
|
||||
strcpy(nextp->lname, namebuf);
|
||||
@@ -1300,7 +1300,7 @@ static int enum_ufs(char *dir, char *name, char *ver, FINFO **finfo_buf)
|
||||
}
|
||||
|
||||
strcpy(namebuf, dp->d_name);
|
||||
if (sbuf.st_mode & S_IFDIR) {
|
||||
if (S_ISDIR(sbuf.st_mode)) {
|
||||
nextp->dirp = 1;
|
||||
quote_dname(namebuf);
|
||||
strcpy(nextp->lname, namebuf);
|
||||
|
||||
36
src/dsk.c
36
src/dsk.c
@@ -327,29 +327,23 @@ LispPTR COM_openfile(register LispPTR *args)
|
||||
|
||||
case ACCESS_OUTPUT:
|
||||
flags = O_RDWR | O_TRUNC | O_CREAT;
|
||||
if (dskp) {
|
||||
unpack_filename(file, dir, name, ver, 1);
|
||||
if (make_directory(dir) == 0) return (NIL);
|
||||
link_check_flg = 1;
|
||||
}
|
||||
unpack_filename(file, dir, name, ver, 1);
|
||||
if (make_directory(dir) == 0) return (NIL);
|
||||
if (dskp) link_check_flg = 1;
|
||||
break;
|
||||
|
||||
case ACCESS_BOTH:
|
||||
flags = O_RDWR | O_CREAT;
|
||||
if (dskp) {
|
||||
unpack_filename(file, dir, name, ver, 1);
|
||||
if (make_directory(dir) == 0) return (NIL);
|
||||
link_check_flg = 1;
|
||||
}
|
||||
unpack_filename(file, dir, name, ver, 1);
|
||||
if (make_directory(dir) == 0) return (NIL);
|
||||
if (dskp) link_check_flg = 1;
|
||||
break;
|
||||
|
||||
case ACCESS_APPEND:
|
||||
flags = O_RDWR | O_CREAT;
|
||||
if (dskp) {
|
||||
unpack_filename(file, dir, name, ver, 1);
|
||||
if (make_directory(dir) == 0) return (NIL);
|
||||
link_check_flg = 1;
|
||||
}
|
||||
unpack_filename(file, dir, name, ver, 1);
|
||||
if (make_directory(dir) == 0) return (NIL);
|
||||
if (dskp) link_check_flg = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -407,7 +401,7 @@ LispPTR COM_openfile(register LispPTR *args)
|
||||
if (dskp) {
|
||||
TIMEOUT(rval = stat(file, &sbuf));
|
||||
if (rval == 0) {
|
||||
if ((sbuf.st_mode & S_IFMT) != S_IFREG) {
|
||||
if (!S_ISREG(sbuf.st_mode)) {
|
||||
/*
|
||||
* The Lisp code handles this case as same as "file table
|
||||
* overflow" error. Final error message is "File won't
|
||||
@@ -513,7 +507,7 @@ LispPTR COM_openfile(register LispPTR *args)
|
||||
*bufp = ToLispTime(sbuf.st_mtime);
|
||||
|
||||
bufp = (int *)(Addr68k_from_LADDR(args[4]));
|
||||
if (!dskp && ((sbuf.st_mode & S_IFMT) != S_IFREG) && ((sbuf.st_mode & S_IFMT) != S_IFDIR)) {
|
||||
if (!dskp && (!S_ISREG(sbuf.st_mode)) && (!S_ISDIR(sbuf.st_mode))) {
|
||||
/*
|
||||
* Not a regular file or directory file. Put on a marker.
|
||||
*/
|
||||
@@ -617,7 +611,7 @@ LispPTR COM_closefile(register LispPTR *args)
|
||||
/* Just close. */
|
||||
TIMEOUT(rval = close(fd));
|
||||
if (rval == -1) {
|
||||
if (!dskp && errno == EPERM && (sbuf.st_mode & S_IFREG) == 0) {
|
||||
if (!dskp && errno == EPERM && !S_ISREG(sbuf.st_mode)) {
|
||||
/*
|
||||
* On {UNIX} device, closing a special file we are not
|
||||
* the owner of it. Although I don't think close fails
|
||||
@@ -745,7 +739,7 @@ LispPTR COM_closefile(register LispPTR *args)
|
||||
/* Just close. */
|
||||
TIMEOUT(rval = close(fd));
|
||||
if (rval == -1) {
|
||||
if (!dskp && errno == EPERM && (sbuf.st_mode & S_IFREG) == 0) {
|
||||
if (!dskp && errno == EPERM && !S_ISREG(sbuf.st_mode)) {
|
||||
/*
|
||||
* On {UNIX} device, closing a special file we are not
|
||||
* the owner of it. Although I don't think close fails
|
||||
@@ -1945,7 +1939,7 @@ LispPTR COM_readpage(register LispPTR *args)
|
||||
return (NIL);
|
||||
}
|
||||
|
||||
if ((sbuf.st_mode & S_IFREG) != 0) {
|
||||
if (S_ISREG(sbuf.st_mode)) {
|
||||
/*
|
||||
* The request file is a regular file. We have to make sure that
|
||||
* next byte read is at the beginning of the requested page of the
|
||||
@@ -2096,7 +2090,7 @@ LispPTR COM_truncatefile(register LispPTR *args)
|
||||
return (NIL);
|
||||
}
|
||||
|
||||
if ((sbuf.st_mode & S_IFREG) == 0) {
|
||||
if (!S_ISREG(sbuf.st_mode)) {
|
||||
/*
|
||||
* The request file is not a regular file. We don't need to
|
||||
* truncate such file.
|
||||
|
||||
@@ -478,7 +478,7 @@ int *ether_debug() {
|
||||
#ifdef MAIKO_ENABLE_ETHERNET
|
||||
estat[0] = 0;
|
||||
if (ether_fd < 0) return (NIL);
|
||||
printf("fd %d bsize %d buf %X icb %X in %d out %d\n ", ether_fd, ether_bsize, (int)ether_buf,
|
||||
printf("fd %d bsize %d buf %p icb %X in %d out %d\n ", ether_fd, ether_bsize, ether_buf,
|
||||
IOPage->dlethernet[3], ether_in, ether_out);
|
||||
#endif /* MAIKO_ENABLE_ETHERNET */
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ LispPTR aref1(LispPTR array, int index) {
|
||||
if (index >= actarray->totalsize) {
|
||||
printf("Invalid index in GC's AREF1: 0x%x\n", index);
|
||||
printf(" Array size limit: 0x%x\n", actarray->totalsize);
|
||||
printf(" Array ptr: 0x%lx\n", (UNSIGNED)array);
|
||||
printf(" Array ptr: 0x%x\n", array);
|
||||
printf(" Array 68K ptr: %p\n", actarray);
|
||||
printf("base: 0x%x\n", actarray->base);
|
||||
printf("offset: 0x%x\n", actarray->offset);
|
||||
|
||||
@@ -127,7 +127,7 @@ LispPTR subr_TCP_ops(int op, LispPTR nameConn, LispPTR proto, LispPTR length, Li
|
||||
sock = LispNumToCInt(proto);
|
||||
result = socket(AF_INET, SOCK_STREAM, 0);
|
||||
farend.sin_family = AF_INET;
|
||||
farend.sin_port = sock;
|
||||
farend.sin_port = htons(sock);
|
||||
if (connect(result, (struct sockaddr *)&farend, sizeof farend) < 0) {
|
||||
perror("TCP connect");
|
||||
return (NIL);
|
||||
|
||||
11
src/subr.c
11
src/subr.c
@@ -485,18 +485,27 @@ void OP_subrcall(int subr_no, int argnum) {
|
||||
case sb_GET_NATIVE_ADDR_FROM_LISP_PTR:
|
||||
POP_SUBR_ARGS;
|
||||
/* XXX: this WILL NOT WORK if Lisp memory is allocated outside the low 4GB */
|
||||
/* not supported since native addresses can't be represented as
|
||||
a Lisp FIXP
|
||||
ARITH_SWITCH(Addr68k_from_LADDR(args[0]), TopOfStack);
|
||||
*/
|
||||
TopOfStack = NIL_PTR;
|
||||
break;
|
||||
|
||||
case sb_GET_LISP_PTR_FROM_NATIVE_ADDR:
|
||||
POP_SUBR_ARGS;
|
||||
/* not supported since native addresses can't be represented as
|
||||
a Lisp FIXP
|
||||
|
||||
{
|
||||
register UNSIGNED iarg;
|
||||
N_GETNUMBER(args[0], iarg, ret_nil);
|
||||
ARITH_SWITCH(LADDR_from_68k(iarg), TopOfStack);
|
||||
break;
|
||||
};
|
||||
|
||||
*/
|
||||
TopOfStack = NIL_PTR;
|
||||
break;
|
||||
case sb_DSK_GETFILENAME:
|
||||
POP_SUBR_ARGS;
|
||||
TopOfStack = DSK_getfilename(args);
|
||||
|
||||
19
src/ufs.c
19
src/ufs.c
@@ -244,6 +244,7 @@ LispPTR UFS_getfilename(LispPTR *args)
|
||||
LispPTR UFS_deletefile(LispPTR *args)
|
||||
{
|
||||
char file[MAXPATHLEN], fbuf[MAXPATHLEN];
|
||||
struct stat sbuf;
|
||||
register int len, rval;
|
||||
|
||||
ERRSETJMP(NIL);
|
||||
@@ -260,11 +261,21 @@ LispPTR UFS_deletefile(LispPTR *args)
|
||||
#else
|
||||
if (unixpathname(fbuf, file, 0, 0) == 0) return (NIL);
|
||||
#endif /* DOS */
|
||||
|
||||
/* check if we're operating on directory or file */
|
||||
TIMEOUT(rval = stat(file, &sbuf));
|
||||
if (rval == -1) {
|
||||
*Lisp_errno = errno;
|
||||
return (NIL);
|
||||
}
|
||||
/*
|
||||
* On UNIX device, all we have to do is just to unlink the file.
|
||||
* On UNIX device, all we have to do is just to unlink the file
|
||||
* or directory
|
||||
*/
|
||||
TIMEOUT(rval = unlink(file));
|
||||
if (S_ISDIR(sbuf.st_mode)) {
|
||||
TIMEOUT(rval = rmdir(file));
|
||||
} else {
|
||||
TIMEOUT(rval = unlink(file));
|
||||
}
|
||||
if (rval == -1) {
|
||||
*Lisp_errno = errno;
|
||||
return (NIL);
|
||||
@@ -398,7 +409,7 @@ LispPTR UFS_directorynamep(LispPTR *args)
|
||||
return (NIL);
|
||||
}
|
||||
|
||||
if ((sbuf.st_mode & S_IFMT) != S_IFDIR) return (NIL);
|
||||
if (!S_ISDIR(sbuf.st_mode)) return (NIL);
|
||||
|
||||
/* Convert Unix file naming convention to Xerox Lisp one. */
|
||||
if (lisppathname(fullname, dirname, 1, 0) == 0) return (NIL);
|
||||
|
||||
117
src/unixcomm.c
117
src/unixcomm.c
@@ -89,7 +89,6 @@ enum UJTYPE {
|
||||
/* These are indexed by WRITE socket# */
|
||||
struct unixjob {
|
||||
char *pathname; /* used by Lisp direct socket access subr */
|
||||
int readsock; /* Socket to READ from for this job. */
|
||||
int PID; /* process ID associated with this slot */
|
||||
int status; /* status returned by subprocess (not shell) */
|
||||
enum UJTYPE type;
|
||||
@@ -284,7 +283,6 @@ int FindUnixPipes(void) {
|
||||
cleareduj.status = -1;
|
||||
cleareduj.pathname = NULL;
|
||||
cleareduj.PID = 0;
|
||||
cleareduj.readsock = 0;
|
||||
cleareduj.type = UJUNUSED;
|
||||
for (int i = 0; i < NPROCS; i++) UJ[i] = cleareduj;
|
||||
|
||||
@@ -374,7 +372,7 @@ LispPTR Unix_handlecomm(LispPTR *args) {
|
||||
|
||||
/* Get command */
|
||||
N_GETNUMBER(args[0], command, bad);
|
||||
DBPRINT(("\nUnix_handlecomm: trying %d\n", command));
|
||||
DBPRINT(("\nUnix_handlecomm: command %d\n", command));
|
||||
|
||||
switch (command) {
|
||||
case 0: /* Fork pipe process */
|
||||
@@ -435,9 +433,9 @@ LispPTR Unix_handlecomm(LispPTR *args) {
|
||||
UJ[PipeFD].type = UJPROCESS;
|
||||
UJ[PipeFD].status = -1;
|
||||
UJ[PipeFD].PID = (d[1] << 8) | d[2] | (d[4] << 16) | (d[5] << 24);
|
||||
UJ[PipeFD].readsock = 0;
|
||||
close(sockFD);
|
||||
unlink(PipeName);
|
||||
DBPRINT(("New process: slot/PipeFD %d PID %d\n", PipeFD, UJ[PipeFD].PID));
|
||||
return (GetSmallp(PipeFD));
|
||||
} else {
|
||||
DBPRINT(("Fork request failed."));
|
||||
@@ -482,17 +480,11 @@ LispPTR Unix_handlecomm(LispPTR *args) {
|
||||
N_GETNUMBER(args[1], slot, bad); /* Get job # */
|
||||
|
||||
if (!valid_slot(slot)) return (NIL); /* No fd open; punt the read */
|
||||
|
||||
if (UJ[slot].readsock)
|
||||
sock = UJ[slot].readsock;
|
||||
else
|
||||
sock = slot;
|
||||
|
||||
switch (UJ[slot].type) {
|
||||
case UJPROCESS:
|
||||
case UJSHELL:
|
||||
case UJSOSTREAM:
|
||||
TIMEOUT(dest = read(sock, buf, 1));
|
||||
TIMEOUT(dest = read(slot, buf, 1));
|
||||
if (dest > 0) return (GetSmallp(buf[0]));
|
||||
/* Something's amiss; check our process status */
|
||||
wait_for_comm_processes();
|
||||
@@ -523,66 +515,46 @@ LispPTR Unix_handlecomm(LispPTR *args) {
|
||||
|
||||
N_GETNUMBER(args[1], slot, bad);
|
||||
|
||||
DBPRINT(("Killing process in slot %d.\n", slot));
|
||||
|
||||
if (valid_slot(slot)) switch (UJ[slot].type) {
|
||||
case UJSHELL:
|
||||
case UJPROCESS:
|
||||
/* First check to see it hasn't already died */
|
||||
if (UJ[slot].status == -1) {
|
||||
/* Kill the job */
|
||||
kill(UJ[slot].PID, SIGKILL);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
/* Waiting for the process to exit is possibly risky.
|
||||
Sending SIGKILL is always supposed to kill
|
||||
a process, but on very rare occurrences this doesn't
|
||||
happen because of a Unix kernel bug, usually a user-
|
||||
written device driver which hasn't been fully
|
||||
debugged. So we time it out just be safe. */
|
||||
if (UJ[slot].status != -1) break;
|
||||
wait_for_comm_processes();
|
||||
usleep(10);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
else
|
||||
return (ATOM_T);
|
||||
|
||||
DBPRINT(("Terminating process in slot %d.\n", slot));
|
||||
if (!valid_slot(slot)) return (ATOM_T);
|
||||
/* in all cases we need to close() the file descriptor */
|
||||
close(slot);
|
||||
switch (UJ[slot].type) {
|
||||
case UJUNUSED:
|
||||
break;
|
||||
|
||||
case UJSHELL:
|
||||
DBPRINT(("Kill 3 closing shell desc %d.\n", slot));
|
||||
close(slot);
|
||||
break;
|
||||
|
||||
case UJPROCESS:
|
||||
DBPRINT(("Kill 3 closing process desc %d.\n", slot));
|
||||
close(slot);
|
||||
if (UJ[slot].readsock) close(UJ[slot].readsock);
|
||||
break;
|
||||
|
||||
case UJSOSTREAM:
|
||||
DBPRINT(("Kill 3 closing stream socket desc %d.\n", slot));
|
||||
close(slot);
|
||||
break;
|
||||
|
||||
case UJSOCKET:
|
||||
DBPRINT(("Kill 3 closing raw socket desc %d.\n", slot));
|
||||
close(slot);
|
||||
case UJSHELL:
|
||||
case UJPROCESS:
|
||||
/* wait for up to 0.1s for it to exit on its own after the close() */
|
||||
for (int i = 0; i < 10; i++) {
|
||||
wait_for_comm_processes();
|
||||
if (UJ[slot].status != -1) break;
|
||||
usleep(10000);
|
||||
}
|
||||
/* check again before we terminate it */
|
||||
if (UJ[slot].status != -1) break;
|
||||
kill(UJ[slot].PID, SIGKILL);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
/* Waiting for the process to exit is possibly risky.
|
||||
Sending SIGKILL is always supposed to kill
|
||||
a process, but on very rare occurrences this doesn't
|
||||
happen because of a Unix kernel bug, usually a user-
|
||||
written device driver which hasn't been fully
|
||||
debugged. So we time it out just be safe. */
|
||||
wait_for_comm_processes();
|
||||
usleep(10000);
|
||||
if (UJ[slot].status != -1) break;
|
||||
}
|
||||
break;
|
||||
case UJSOCKET:
|
||||
if (UJ[slot].pathname) {
|
||||
DBPRINT(("Unlinking %s\n", UJ[slot].pathname));
|
||||
if (UJ[slot].pathname) {
|
||||
if (unlink(UJ[slot].pathname) < 0) perror("Kill 3 unlink");
|
||||
free(UJ[slot].pathname);
|
||||
UJ[slot].pathname = NULL;
|
||||
}
|
||||
break;
|
||||
if (unlink(UJ[slot].pathname) < 0) perror("Kill 3 unlink");
|
||||
free(UJ[slot].pathname);
|
||||
UJ[slot].pathname = NULL;
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
UJ[slot].type = UJUNUSED;
|
||||
UJ[slot].readsock = UJ[slot].PID = 0;
|
||||
UJ[slot].PID = 0;
|
||||
UJ[slot].pathname = NULL;
|
||||
|
||||
/* If status available, return it, otherwise T */
|
||||
@@ -674,8 +646,6 @@ LispPTR Unix_handlecomm(LispPTR *args) {
|
||||
case UJPROCESS:
|
||||
DBPRINT(("Kill 5 closing process desc %d.\n", dest));
|
||||
close(dest);
|
||||
if (UJ[dest].readsock) close(UJ[dest].readsock);
|
||||
UJ[dest].readsock = 0;
|
||||
break;
|
||||
|
||||
case UJSOCKET:
|
||||
@@ -696,7 +666,7 @@ LispPTR Unix_handlecomm(LispPTR *args) {
|
||||
}
|
||||
|
||||
UJ[dest].type = UJUNUSED;
|
||||
UJ[dest].readsock = UJ[dest].PID = 0;
|
||||
UJ[dest].PID = 0;
|
||||
return (ATOM_T);
|
||||
/* break; */
|
||||
|
||||
@@ -729,18 +699,13 @@ LispPTR Unix_handlecomm(LispPTR *args) {
|
||||
N_GETNUMBER(args[1], slot, bad); /* Get job # */
|
||||
if (!valid_slot(slot)) return (NIL); /* No fd open; punt the read */
|
||||
|
||||
if (UJ[slot].readsock)
|
||||
sock = UJ[slot].readsock;
|
||||
else
|
||||
sock = slot;
|
||||
|
||||
bufp = (Addr68k_from_LADDR(args[2])); /* User buffer */
|
||||
DBPRINT(("Read buffer slot %d, type is %d\n", slot, UJ[slot].type));
|
||||
|
||||
switch (UJ[slot].type) {
|
||||
case UJSHELL:
|
||||
case UJPROCESS:
|
||||
case UJSOSTREAM: dest = read(sock, bufp, 512);
|
||||
case UJSOSTREAM: dest = read(slot, bufp, 512);
|
||||
#ifdef BYTESWAP
|
||||
word_swap_page(bufp, 128);
|
||||
#endif /* BYTESWAP */
|
||||
|
||||
@@ -129,6 +129,8 @@ static int ForkUnixShell(int slot, char *PtySlave, char *termtype, char *shellar
|
||||
}
|
||||
/* Start up shell -- use SHELL environment variable as long as it's in /etc/shells */
|
||||
shell = getenv("SHELL");
|
||||
if (shell == NULL) /* shell of last resort */
|
||||
shell = "/bin/sh";
|
||||
for (userShell = getusershell(); userShell != NULL && strcmp(shell, userShell) != 0; userShell = getusershell());
|
||||
if (userShell == NULL) {
|
||||
perror("$(SHELL) not found in /etc/shells");
|
||||
|
||||
Reference in New Issue
Block a user