Skip to content

Commit 80108fc

Browse files
authored
build(source-os): add writer-first sourceos-office new workflow (#157)
* build(source-os): add writer-first office new helper * build(source-os): add writer-first sourceos-office new command * build(source-os): stage office_new helper in shell installer * build(source-os): exercise installed sourceos-office new path in shell smoke
1 parent 1cd08ff commit 80108fc

4 files changed

Lines changed: 61 additions & 2 deletions

File tree

build/office-suite/scripts/install_sourceos_office_shell.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ mkdir -p "$BIN_DIR"
1111
cp "$ROOT/build/office-suite/scripts/sourceos-office" "$BIN_DIR/sourceos-office"
1212
cp "$ROOT/build/office-suite/scripts/install_sourceos_office_shell.sh" "$BIN_DIR/install_sourceos_office_shell.sh"
1313
cp "$ROOT/build/office-suite/scripts/office_shell_verify.sh" "$BIN_DIR/office_shell_verify.sh"
14-
chmod +x "$BIN_DIR/sourceos-office" "$BIN_DIR/install_sourceos_office_shell.sh" "$BIN_DIR/office_shell_verify.sh"
14+
cp "$ROOT/build/office-suite/scripts/office_new.sh" "$BIN_DIR/office_new.sh"
15+
cp "$ROOT/build/office-suite/templates/sovereign/sourceos-default-writer.fodt" "$BIN_DIR/sourceos-default-writer.fodt"
16+
chmod +x "$BIN_DIR/sourceos-office" "$BIN_DIR/install_sourceos_office_shell.sh" "$BIN_DIR/office_shell_verify.sh" "$BIN_DIR/office_new.sh"
1517

1618
if [[ -x "$ROOT/build/office-suite/scripts/verify_office_suite_profile.sh" ]]; then
1719
"$ROOT/build/office-suite/scripts/verify_office_suite_profile.sh"
@@ -20,4 +22,6 @@ fi
2022
echo "installed sourceos-office to $BIN_DIR/sourceos-office"
2123
echo "installed install_sourceos_office_shell.sh to $BIN_DIR/install_sourceos_office_shell.sh"
2224
echo "installed office_shell_verify.sh to $BIN_DIR/office_shell_verify.sh"
25+
echo "installed office_new.sh to $BIN_DIR/office_new.sh"
26+
echo "installed sourceos-default-writer.fodt to $BIN_DIR/sourceos-default-writer.fodt"
2327
echo "SourceOS office shell install completed"

build/office-suite/scripts/install_sourceos_office_shell_smoke.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ OPEN_BIN="$HOME/.local/bin/sourceos-office-open"
1717
SOURCEOS_OFFICE_BIN="$HOME/.local/bin/sourceos-office"
1818
INSTALL_BIN="$HOME/.local/bin/install_sourceos_office_shell.sh"
1919
VERIFY_BIN="$HOME/.local/bin/office_shell_verify.sh"
20+
NEW_BIN="$HOME/.local/bin/office_new.sh"
2021
CLOUD_BIN="$HOME/.local/bin/office_cloud_handoff.sh"
2122
MIME_FILE="$XDG_CONFIG_HOME/mimeapps.list"
2223
TEST_DOC="$TMPDIR/demo.txt"
24+
NEW_DOC="$TMPDIR/new-writer.fodt"
2325
echo "SourceOS office shell smoke" > "$TEST_DOC"
2426

2527
[[ -f "$DESKTOP_FILE" ]] || {
@@ -47,6 +49,11 @@ echo "SourceOS office shell smoke" > "$TEST_DOC"
4749
exit 1
4850
}
4951

52+
[[ -x "$NEW_BIN" ]] || {
53+
echo "office shell installer smoke failed: missing office_new helper" >&2
54+
exit 1
55+
}
56+
5057
[[ -x "$CLOUD_BIN" ]] || {
5158
echo "office shell installer smoke failed: missing cloud handoff helper" >&2
5259
exit 1
@@ -90,6 +97,21 @@ case "$SEARCH_OUT" in
9097
;;
9198
esac
9299

100+
NEW_OUT="$($SOURCEOS_OFFICE_BIN new writer "$NEW_DOC")"
101+
[[ "$NEW_OUT" == "$NEW_DOC" ]] || {
102+
echo "office shell installer smoke failed: installed sourceos-office new path did not return created file" >&2
103+
exit 1
104+
}
105+
[[ -f "$NEW_DOC" ]] || {
106+
echo "office shell installer smoke failed: installed sourceos-office new path did not create file" >&2
107+
exit 1
108+
}
109+
110+
grep -q "SourceOS sovereign writer template placeholder" "$NEW_DOC" || {
111+
echo "office shell installer smoke failed: created writer file does not contain template payload" >&2
112+
exit 1
113+
}
114+
93115
"$SOURCEOS_OFFICE_BIN" install >/dev/null
94116

95117
echo "office shell installer smoke passed"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [[ $# -lt 2 ]]; then
5+
echo "usage: $0 <writer> <output-file>" >&2
6+
exit 1
7+
fi
8+
9+
KIND="$1"
10+
OUTPUT="$2"
11+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12+
ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
13+
14+
case "$KIND" in
15+
writer)
16+
if [[ -f "$SCRIPT_DIR/sourceos-default-writer.fodt" ]]; then
17+
TEMPLATE="$SCRIPT_DIR/sourceos-default-writer.fodt"
18+
else
19+
TEMPLATE="$ROOT/build/office-suite/templates/sovereign/sourceos-default-writer.fodt"
20+
fi
21+
;;
22+
*)
23+
echo "unsupported office kind: $KIND" >&2
24+
exit 2
25+
;;
26+
esac
27+
28+
mkdir -p "$(dirname "$OUTPUT")"
29+
cp "$TEMPLATE" "$OUTPUT"
30+
echo "$OUTPUT"

build/office-suite/scripts/sourceos-office

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ case "$CMD" in
3333
search)
3434
"$(resolve_helper office_search_open.sh build/office-suite/scripts/office_search_open.sh)" "$@"
3535
;;
36+
new)
37+
"$(resolve_helper office_new.sh build/office-suite/scripts/office_new.sh)" "$@"
38+
;;
3639
help|*)
3740
cat <<'EOF'
38-
usage: sourceos-office <install|verify|open|search> [args]
41+
usage: sourceos-office <install|verify|open|search|new> [args]
3942
EOF
4043
;;
4144
esac

0 commit comments

Comments
 (0)