Skip to content
This repository was archived by the owner on Nov 21, 2018. It is now read-only.

Installer next #11

Merged
merged 4 commits into from
Feb 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion msi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ all: $(MSI).msi

$(MSI).msi: $(OBJS)
$(LIGHT) $(LIGHT_FLAGS) -out $@ $(OBJS) -sice:ICE57
# ICE57 wrongly complains about the shortcuts
# ICE57 wrongly complains about the shortcuts

.wxs.wixobj:
$(CANDLE) $(CANDLE_FLAGS) -out $@ $^
Expand Down
70 changes: 50 additions & 20 deletions package-rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ def move_file(source, target):
package_name=COMBINED_PACKAGE_NAME + "-" + package_version + "-" + target
run(["sh", "./rust-installer/combine-installers.sh",
"--product-name=Rust",
"--verify-bin=rustc",
"--rel-manifest-dir=rustlib",
"--success-message=Rust-is-ready-to-roll",
"--success-message=Rust-is-ready-to-roll.",
"--work-dir=" + TEMP_DIR + "/work",
"--output-dir=" + OUTPUT_DIR,
"--package-name=" + package_name,
Expand Down Expand Up @@ -229,26 +228,58 @@ def move_file(source, target):

if make_pkg:
print "creating .pkg"

assert docs_installer is not None
assert cargo_installer is not None

rustc_package_name = rustc_installer.replace(".tar.gz", "")
docs_package_name = docs_installer.replace(".tar.gz", "")
cargo_package_name = cargo_installer.replace(".tar.gz", "")

os.mkdir(TEMP_DIR + "/pkg")
shutil.copytree(TEMP_DIR + "/work/" + package_name, TEMP_DIR + "/pkg/root")

shutil.copytree(TEMP_DIR + "/work/" + rustc_package_name, TEMP_DIR + "/pkg/rustc")
shutil.copytree(TEMP_DIR + "/work/" + cargo_package_name, TEMP_DIR + "/pkg/cargo")
shutil.copytree(TEMP_DIR + "/work/" + docs_package_name, TEMP_DIR + "/pkg/rust-docs")

# The package root, extracted from a tarball has entirely wrong permissions.
# This goes over everything and fixes them.
run(["chmod", "-R", "u+rwX,go+rX,go-w", TEMP_DIR + "/pkg/root"])
for filename in os.listdir(TEMP_DIR + "/pkg/root/bin"):
run(["chmod", "0755", TEMP_DIR + "/pkg/root/bin/" + filename])
run(["chmod", "-R", "u+rwX,go+rX,go-w", TEMP_DIR + "/pkg"])
for filename in os.listdir(TEMP_DIR + "/pkg/rustc/rustc/bin"):
run(["chmod", "0755", TEMP_DIR + "/pkg/rustc/rustc/bin/" + filename])
for filename in os.listdir(TEMP_DIR + "/pkg/cargo/cargo/bin"):
run(["chmod", "0755", TEMP_DIR + "/pkg/cargo/cargo/bin/" + filename])

# Copy the postinstall script that will execute install.sh
shutil.copyfile("./pkg/postinstall", TEMP_DIR + "/pkg/rustc/postinstall")
run(["chmod", "a+x", TEMP_DIR + "/pkg/rustc/postinstall"])
shutil.copyfile("./pkg/postinstall", TEMP_DIR + "/pkg/cargo/postinstall")
run(["chmod", "a+x", TEMP_DIR + "/pkg/cargo/postinstall"])
shutil.copyfile("./pkg/postinstall", TEMP_DIR + "/pkg/rust-docs/postinstall")
run(["chmod", "a+x", TEMP_DIR + "/pkg/rust-docs/postinstall"])

pkgbuild_cmd = "pkgbuild --identifier org.rust-lang.rustc " + \
"--scripts " + TEMP_DIR + "/pkg/rustc --nopayload " + TEMP_DIR + "/pkg/rustc.pkg"
run(["sh", "-c", pkgbuild_cmd])
pkgbuild_cmd = "pkgbuild --identifier org.rust-lang.cargo " + \
"--scripts " + TEMP_DIR + "/pkg/cargo --nopayload " + TEMP_DIR + "/pkg/cargo.pkg"
run(["sh", "-c", pkgbuild_cmd])
pkgbuild_cmd = "pkgbuild --identifier org.rust-lang.rust-docs " + \
"--scripts " + TEMP_DIR + "/pkg/rust-docs --nopayload " + TEMP_DIR + "/pkg/rust-docs.pkg"
run(["sh", "-c", pkgbuild_cmd])

# Remove everything under the root. These all shouldn't be installed.
for filename in os.listdir(TEMP_DIR + "/pkg/root"):
if os.path.isfile(TEMP_DIR + "/pkg/root/" + filename):
run(["rm", TEMP_DIR + "/pkg/root/" + filename])
# Also create an 'uninstall' package
os.mkdir(TEMP_DIR + "/pkg/uninstall")
shutil.copyfile("./pkg/postinstall", TEMP_DIR + "/pkg/uninstall/postinstall")
run(["chmod", "a+x", TEMP_DIR + "/pkg/uninstall/postinstall"])
pkgbuild_cmd = "pkgbuild --identifier org.rust-lang.uninstall " + \
"--scripts " + TEMP_DIR + "/pkg/uninstall --nopayload " + TEMP_DIR + "/pkg/uninstall.pkg"
run(["sh", "-c", pkgbuild_cmd])

os.mkdir(TEMP_DIR + "/pkg/res")
shutil.copyfile(TEMP_DIR + "/LICENSE.txt", TEMP_DIR + "/pkg/res/LICENSE.txt")
shutil.copyfile("./pkg/welcome.rtf", TEMP_DIR + "/pkg/res/welcome.rtf")
shutil.copyfile("./gfx/rust-logo.png", TEMP_DIR + "/pkg/res/rust-logo.png")
pkgbuild_cmd = "pkgbuild --identifier org.rust-lang.rust " + \
"--root " + TEMP_DIR + "/pkg/root " + TEMP_DIR + "/pkg/rust.pkg"
run(["sh", "-c", pkgbuild_cmd])
productbuild_cmd = "productbuild --distribution ./pkg/Distribution.xml " + \
"--resources " + TEMP_DIR + "/pkg/res " + OUTPUT_DIR + "/" + package_name + ".pkg " + \
"--package-path " + TEMP_DIR + "/pkg"
Expand All @@ -263,16 +294,17 @@ def move_file(source, target):
assert docs_installer is not None
assert mingw_installer is not None
assert cargo_installer is not None

exe_temp_dir = TEMP_DIR + "/exe"
os.mkdir(exe_temp_dir)
run(["tar", "xzf", INPUT_DIR + "/" + rustc_installer, "-C", exe_temp_dir])
run(["tar", "xzf", INPUT_DIR + "/" + docs_installer, "-C", exe_temp_dir])
run(["tar", "xzf", INPUT_DIR + "/" + mingw_installer, "-C", exe_temp_dir])
run(["tar", "xzf", INPUT_DIR + "/" + cargo_installer, "-C", exe_temp_dir])
orig_rustc_dir = exe_temp_dir + "/" + rustc_installer.replace(".tar.gz", "")
orig_docs_dir = exe_temp_dir + "/" + docs_installer.replace(".tar.gz", "")
orig_mingw_dir = exe_temp_dir + "/" + mingw_installer.replace(".tar.gz", "")
orig_cargo_dir = exe_temp_dir + "/" + cargo_installer.replace(".tar.gz", "")
orig_rustc_dir = exe_temp_dir + "/" + rustc_installer.replace(".tar.gz", "") + "/rustc"
orig_docs_dir = exe_temp_dir + "/" + docs_installer.replace(".tar.gz", "") + "/rust-docs"
orig_mingw_dir = exe_temp_dir + "/" + mingw_installer.replace(".tar.gz", "") + "/rust-mingw"
orig_cargo_dir = exe_temp_dir + "/" + cargo_installer.replace(".tar.gz", "") + "/cargo"

# Move these to locations needed by the iscc script and wix sources
rustc_dir = exe_temp_dir + "/rustc"
Expand All @@ -290,9 +322,7 @@ def move_file(source, target):
for dir_and_component in dir_comp_pairs:
dir_ = dir_and_component[0]
component = dir_and_component[1]
for file_ in ["components", "install.sh", "rust-installer-version"]:
os.remove(dir_ + "/" + file_)
os.remove(dir_ + "/manifest-" + component + ".in")
os.remove(dir_ + "/manifest.in")

if make_exe:
# Copy installer files, etc.
Expand Down
59 changes: 48 additions & 11 deletions pkg/Distribution.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,63 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-gui-script minSpecVersion="2">
<title>Rust</title>
<title>The Rust Compiler</title>
<license file="LICENSE.txt" mime-type="text/plain"/>
<pkg-ref id="org.rust-lang.rust"/>
<options customize="never" require-scripts="false" hostArchitectures="i386,x86_64"/>
<options customize="always" require-scripts="false" hostArchitectures="i386,x86_64"/>
<domains enable_anywhere="false" enable_currentUserHome="false" enable_localSystem="true" />
<volume-check>
<allowed-os-versions>
<os-version min="10.7"/>
</allowed-os-versions>
</volume-check>
<choices-outline>
<line choice="default">
<line choice="org.rust-lang.rust"/>
</line>
<line choice="install">
<line choice="rustc"/>
<line choice="cargo"/>
<line choice="rust-docs"/>
</line>
<line choice="uninstall" />
</choices-outline>
<choice id="default"
customLocation="usr/local"/>
<choice id="org.rust-lang.rust" visible="false">
<pkg-ref id="org.rust-lang.rust"/>
<!--
These 'selected' scripts ensure that install and uninstall can never be selected at
the same time. Exectly how they work is pretty mysterious, tied to the unspecified algorithm
the installer uses to traverse the options after one is toggled.
-->
<choice id="install" visible="true"
title="Install Rust" description="Install the Rust compiler, package manager and documentation."
customLocation="/usr/local"
selected="!choices.uninstall.selected"
/>
<choice id="uninstall" visible="true"
title="Uninstall Rust" description="Select this option to uninstall an existing Rust installation."
customLocation="/usr/local"
selected="!(choices.install.selected || choices.rustc.selected || choices.cargo.selected || choices['rust-docs'].selected)"
start_selected="false"
>
<pkg-ref id="org.rust-lang.uninstall" />
</choice>
<pkg-ref id="org.rust-lang.rust" version="0" onConclusion="none">rust.pkg</pkg-ref>
<welcome file="welcome.rtf" mime-type="text/enriched"/>
<choice id="rustc" visible="true"
title="Compiler" description="rustc, the Rust compiler, and rustdoc, the API documentation tool."
selected="(!choices.uninstall.selected &amp;&amp; choices.rustc.selected) || (choices.uninstall.selected &amp;&amp; choices.install.selected)"
>
<pkg-ref id="org.rust-lang.rustc"/>
</choice>
<choice id="cargo" visible="true"
title="Cargo" description="cargo, the Rust package manager."
selected="(!choices.uninstall.selected &amp;&amp; choices.cargo.selected) || (choices.uninstall.selected &amp;&amp; choices.install.selected)"
>
<pkg-ref id="org.rust-lang.cargo"/>
</choice>
<choice id="rust-docs" visible="true"
title="Documentation" description="HTML documentation."
selected="(!choices.uninstall.selected &amp;&amp; choices['rust-docs'].selected) || (choices.uninstall.selected &amp;&amp; choices.install.selected)"
>
<pkg-ref id="org.rust-lang.rust-docs"/>
</choice>
<pkg-ref id="org.rust-lang.rustc" version="0" onConclusion="none">rustc.pkg</pkg-ref>
<pkg-ref id="org.rust-lang.cargo" version="0" onConclusion="none">cargo.pkg</pkg-ref>
<pkg-ref id="org.rust-lang.rust-docs" version="0" onConclusion="none">rust-docs.pkg</pkg-ref>
<pkg-ref id="org.rust-lang.uninstall" version="0" onConclusion="none">uninstall.pkg</pkg-ref>
<background file="rust-logo.png" mime-type="image/png"
alignment="bottomleft"/>
</installer-gui-script>
26 changes: 26 additions & 0 deletions pkg/postinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

source_dir="$(dirname "$0")"
dest_dir="$2"
package_id="$INSTALL_PKG_SESSION_ID"

if [ -z "$source_dir" ]; then
exit 1
fi
if [ -z "$dest_dir" ]; then
exit 1
fi
if [ -z "$package_id" ]; then
exit 1
fi

if [ "$package_id" = "org.rust-lang.uninstall" ]; then
if [ ! -e "$dest_dir/lib/rustlib/uninstall.sh" ]; then
exit 1
fi
sh "$dest_dir/lib/rustlib/uninstall.sh"
else
sh "$source_dir/install.sh" --prefix="$dest_dir"
fi

exit 0
12 changes: 0 additions & 12 deletions pkg/welcome.rtf

This file was deleted.

2 changes: 1 addition & 1 deletion rust-installer