Skip to content

Commit

Permalink
new package: ffplayout
Browse files Browse the repository at this point in the history
  • Loading branch information
licy183 committed Nov 6, 2023
1 parent 196dff2 commit f052e6d
Show file tree
Hide file tree
Showing 2 changed files with 191 additions and 0 deletions.
111 changes: 111 additions & 0 deletions tur/ffplayout/0001-fix-hardcoded-paths.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
--- a/ffplayout-api/src/main.rs
+++ b/ffplayout-api/src/main.rs
@@ -41,8 +41,8 @@
}

fn public_path() -> &'static str {
- if Path::new("/usr/share/ffplayout/public/").is_dir() {
- return "/usr/share/ffplayout/public/";
+ if Path::new("@TERMUX_PREFIX@/share/ffplayout/public/").is_dir() {
+ return "@TERMUX_PREFIX@/share/ffplayout/public/";
}

if Path::new("./public/").is_dir() {
--- a/ffplayout-api/src/utils/channels.rs
+++ b/ffplayout-api/src/utils/channels.rs
@@ -21,7 +21,7 @@
return Err(ServiceError::BadRequest("Bad service name!".to_string()));
}

- if !target_channel.config_path.starts_with("/etc/ffplayout") {
+ if !target_channel.config_path.starts_with("@TERMUX_PREFIX@/etc/ffplayout") {
return Err(ServiceError::BadRequest("Bad config path!".to_string()));
}

@@ -32,7 +32,7 @@
};

let mut config =
- PlayoutConfig::new(Some("/usr/share/ffplayout/ffplayout.yml.orig".to_string()));
+ PlayoutConfig::new(Some("@TERMUX_PREFIX@/share/ffplayout/ffplayout.yml.orig".to_string()));

config.general.stat_file = format!(".ffp_{channel_name}",);

--- a/ffplayout-api/src/utils/control.rs
+++ b/ffplayout-api/src/utils/control.rs
@@ -183,7 +183,7 @@

Ok(Self {
service: channel.service,
- cmd: vec_strings!["/usr/bin/systemctl"],
+ cmd: vec_strings!["@TERMUX_PREFIX@//bin/systemctl"],
})
}

--- a/ffplayout-api/src/utils/mod.rs
+++ b/ffplayout-api/src/utils/mod.rs
@@ -75,7 +75,7 @@
}

pub fn db_path() -> Result<String, Box<dyn std::error::Error>> {
- let sys_path = Path::new("/usr/share/ffplayout/db");
+ let sys_path = Path::new("@TERMUX_PREFIX@/share/ffplayout/db");
let mut db_path = "./ffplayout.db".to_string();

if sys_path.is_dir() && !sys_path.writable() {
@@ -83,7 +83,7 @@
}

if sys_path.is_dir() && sys_path.writable() {
- db_path = "/usr/share/ffplayout/db/ffplayout.db".to_string();
+ db_path = "@TERMUX_PREFIX@/share/ffplayout/db/ffplayout.db".to_string();
} else if Path::new("./assets").is_dir() {
db_path = "./assets/ffplayout.db".to_string();
}
--- a/ffplayout-api/src/db/handles.rs
+++ b/ffplayout-api/src/db/handles.rs
@@ -104,7 +104,7 @@
};

let config_path = if env::consts::OS == "linux" {
- "/etc/ffplayout/ffplayout.yml"
+ "@TERMUX_PREFIX@/etc/ffplayout/ffplayout.yml"
} else {
"./assets/ffplayout.yml"
};
--- a/lib/src/utils/config.rs
+++ b/lib/src/utils/config.rs
@@ -318,7 +318,7 @@
impl PlayoutConfig {
/// Read config from YAML file, and set some extra config values.
pub fn new(cfg_path: Option<String>) -> Self {
- let mut config_path = PathBuf::from("/etc/ffplayout/ffplayout.yml");
+ let mut config_path = PathBuf::from("@TERMUX_PREFIX@/etc/ffplayout/ffplayout.yml");

if let Some(cfg) = cfg_path {
config_path = PathBuf::from(cfg);
@@ -336,7 +336,7 @@
Ok(file) => file,
Err(_) => {
println!(
- "{config_path:?} doesn't exists!\nPut \"ffplayout.yml\" in \"/etc/playout/\" or beside the executable!"
+ "{config_path:?} doesn't exists!\nPut \"ffplayout.yml\" in \"@TERMUX_PREFIX@/etc/playout/\" or beside the executable!"
);
process::exit(1);
}
--- a/ffplayout-engine/src/utils/mod.rs
+++ b/ffplayout-engine/src/utils/mod.rs
@@ -19,11 +19,11 @@
pub fn get_config(args: Args) -> PlayoutConfig {
let cfg_path = match args.channel {
Some(c) => {
- let path = PathBuf::from(format!("/etc/ffplayout/{c}.yml"));
+ let path = PathBuf::from(format!("@TERMUX_PREFIX@/etc/ffplayout/{c}.yml"));

if !path.is_file() {
println!(
- "Config file \"{c}\" under \"/etc/ffplayout/\" not found.\n\nCheck arguments!"
+ "Config file \"{c}\" under \"@TERMUX_PREFIX@/etc/ffplayout/\" not found.\n\nCheck arguments!"
);
exit(1)
}
80 changes: 80 additions & 0 deletions tur/ffplayout/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
TERMUX_PKG_HOMEPAGE=https://ffplayout.github.io
TERMUX_PKG_DESCRIPTION="Rust and ffmpeg based playout"
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_MAINTAINER="@termux-user-repository"
TERMUX_PKG_VERSION=0.19.1
TERMUX_PKG_SRCURL=git+https://github.com/ffplayout/ffplayout
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_HOSTBUILD=true

termux_step_get_source() {
local TMP_CHECKOUT=$TERMUX_PKG_CACHEDIR/tmp-checkout
local TMP_CHECKOUT_VERSION=$TERMUX_PKG_CACHEDIR/tmp-checkout-version

if [ ! -f $TMP_CHECKOUT_VERSION ] || [ "$(cat $TMP_CHECKOUT_VERSION)" != "$TERMUX_PKG_VERSION" ]; then
if [ "$TERMUX_PKG_GIT_BRANCH" == "" ]; then
TERMUX_PKG_GIT_BRANCH=v$TERMUX_PKG_VERSION
fi

rm -rf $TMP_CHECKOUT
git clone --depth 1 \
--branch $TERMUX_PKG_GIT_BRANCH \
${TERMUX_PKG_SRCURL:4} \
$TMP_CHECKOUT

# Set git submoudle url to https rather than ssh
sed -i 's|git@github.com:|https://github.com/|g' $TMP_CHECKOUT/.gitmodules

pushd $TMP_CHECKOUT
git submodule update --init --recursive --depth=1
popd

echo "$TERMUX_PKG_VERSION" > $TMP_CHECKOUT_VERSION
fi

rm -rf $TERMUX_PKG_SRCDIR
cp -Rf $TMP_CHECKOUT $TERMUX_PKG_SRCDIR
}

termux_step_host_build() {
termux_setup_nodejs
pushd $TERMUX_PKG_SRCDIR
bash ./scripts/man_create.sh
rm -rf public
cd ffplayout-frontend
npm install
npm run generate
cp -r .output/public ../public
popd
}

termux_step_configure() {
# Remove this marker all the time
rm -rf $TERMUX_HOSTBUILD_MARKER
}

termux_step_make() {
termux_setup_rust

if [ "$TERMUX_ARCH" == "x86_64" ]; then
local libdir=target/x86_64-linux-android/release/deps
mkdir -p $libdir
pushd $libdir
RUSTFLAGS+=" -C link-arg=$($CC -print-libgcc-file-name)"
echo "INPUT(-l:libunwind.a)" > libgcc.so
popd
fi

cargo build --jobs $TERMUX_MAKE_PROCESSES --release --target $CARGO_TARGET_NAME
}

termux_step_make_install() {
cp ./target/$CARGO_TARGET_NAME/release/ffpapi .
cp ./target/$CARGO_TARGET_NAME/release/ffplayout .
tar -cvf "ffplayout-v${TERMUX_PKG_VERSION}_${CARGO_TARGET_NAME}.tar" --exclude='*.db' --exclude='*.db-shm' --exclude='*.db-wal' assets docker docs public LICENSE README.md CHANGELOG.md ffplayout ffpapi
mkdir -p $TERMUX_PREFIX/opt/ffplayout
tar -C $TERMUX_PREFIX/opt/ffplayout -xvf "ffplayout-v${TERMUX_PKG_VERSION}_${CARGO_TARGET_NAME}.tar"
ln -sfr $TERMUX_PREFIX/opt/ffplayout/ffpapi $TERMUX_PREFIX/bin
ln -sfr $TERMUX_PREFIX/opt/ffplayout/ffplayout $TERMUX_PREFIX/bin
}

0 comments on commit f052e6d

Please sign in to comment.