-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-sync with internal repository (#58)
The internal and external repositories are out of sync. This Pull Request attempts to brings them back in sync by patching the GitHub repository. Please carefully review this patch. You must disable ShipIt for your project in order to merge this pull request. DO NOT IMPORT this pull request. Instead, merge it directly on GitHub using the MERGE BUTTON. Re-enable ShipIt after merging.
- Loading branch information
1 parent
77b3860
commit 65937a6
Showing
6 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Easy buck2 builds for Facebook projects | ||
|
||
This directory contains buck2 targets designed to simplify buck2 builds of | ||
Meta open source projects. | ||
|
||
The most notable target is `//build/buck2/install_deps`, which will attempt to | ||
discover and install necessary third party packages from apt / dnf / etc. | ||
See the "repos" directory for the currently supported platforms. | ||
|
||
## Deployment | ||
|
||
This directory is copied literally into a number of different Facebook open | ||
source repositories. Any change made to code in this directory will be | ||
automatically be replicated by our open source tooling into all GitHub hosted | ||
repositories that use `buck2`. Typically this directory is copied | ||
into the open source repositories as `build/buck2/`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under both the MIT license found in the | ||
# LICENSE-MIT file in the root directory of this source tree and the Apache | ||
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory | ||
# of this source tree. | ||
load("@fbcode_macros//build_defs:native_rules.bzl", "buck_sh_binary") | ||
|
||
oncall("open_source") | ||
|
||
buck_sh_binary( | ||
name = "install_deps", | ||
main = "install_deps.sh", | ||
resources = glob(["repos/*"]), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/sh | ||
# (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. | ||
|
||
if [ -z "$INSTALL_COMMAND" ]; then | ||
if [ -f /etc/os-release ]; then | ||
. /etc/os-release; | ||
fi | ||
|
||
if command -v brew >/dev/null; then | ||
ID="homebrew"; | ||
fi | ||
|
||
if [ -f "$BUCK_DEFAULT_RUNTIME_RESOURCES/repos/$ID" ]; then | ||
# shellcheck disable=SC1090 | ||
. "$BUCK_DEFAULT_RUNTIME_RESOURCES/repos/$ID"; | ||
else | ||
echo "Unable to determine platform id / install commands"; | ||
return 1; | ||
fi | ||
fi | ||
|
||
if [ -z "${BUCK2_COMMAND}" ]; then | ||
if command -v buck2 >/dev/null; then | ||
BUCK2_COMMAND="buck2" | ||
elif command -v dotslash >/dev/null && [ -f ./buck2 ]; then | ||
BUCK2_COMMAND="dotslash ./buck2" | ||
else | ||
echo "Unable to determine buck2 command"; | ||
return 1; | ||
fi | ||
fi | ||
|
||
PKG_FILE=$(mktemp /tmp/buck2-install-pkgs.XXXXXX) | ||
|
||
eval "$BUCK2_COMMAND \\ | ||
cquery \"attrregexfilter(labels, 'third-party:$ID:', deps(//...))\" \\ | ||
--json --output-attribute=labels 2>/dev/null \\ | ||
| grep -o \"third-party:$ID:[^\\\"]*\" \\ | ||
| sort \\ | ||
| uniq \\ | ||
| sed \"s/third-party:$ID://\" \\ | ||
> $PKG_FILE" | ||
|
||
echo "About to install the project dependencies with the following command:" | ||
echo | ||
eval "cat $PKG_FILE | xargs echo $INSTALL_COMMAND" | ||
echo | ||
echo "Press \"y\" to continue" | ||
read -r REPLY | ||
echo | ||
|
||
if expr "X$REPLY" : '^X[Yy]$' >/dev/null; then | ||
eval "cat $PKG_FILE | xargs -r $INSTALL_COMMAND" | ||
else | ||
echo "Not installing dependencies" | ||
fi | ||
|
||
rm "$PKG_FILE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
INSTALL_COMMAND="sudo -E dnf install -y" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
INSTALL_COMMAND="brew install" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
INSTALL_COMMAND="sudo -E apt-get install -y" |