Pkg Devs: Complex Shell Commands from Makefile?

I'm needing to issue some "complex" shell commands in order to get a package to work properly. I'm putting these in Host/InstallDev for the time being.

	cd $(HOST_BUILD_DIR)/build/dist && \
       for file in *.xz; do tar -xvJf "${file}"; done
	cd $(HOST_BUILD_DIR)/build/dist && \
       find ./* -type f -name install.sh -execdir sh {} --prefix=$(CARGO_HOME) --disable-ldconfig \;
tar (child): : Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
tar (child): : Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

I have attempted to throw those into a $(shell xxxxxxxx) but it didn't seem to do anything different.

Anyone have suggestions on what I'm doing wrong, and if you have a better way to do what I need to do, rather than how I'm doing it now.

I know it's complaining about not finding the files, and I'm working on that (though it should be correct), but I'm looking for the best way to do it overall :slight_smile:

find -type f -iname "*.xz" -exec tar -x -J -f {} ";"
1 Like

I will give that a try :slight_smile: Thanks!

1 Like

First Important thing to share with the group:

InstallDev is called before everything else. I believe it maybe the first directive called in the build chain. So.. putting my stuff there makes no sense, since I'm trying to do it after everything is done. Hense, the error.. I was asking it to work on a directory and files that didn't exist yet :confused: :smiley:

So.. Lesson 1: InstallDev processes first.. At guess, and I'll confirm next build I run, that it'll go
InstallDev, Download, Prepare, Configure, Compile, and Install (although Install may have been moved into Compile?

I'm putting this here because the https://openwrt.org/docs/guide-developer/packages page gives a lot of great info, but some of it just isn't there (like.. InstallDev goes first ;p) Yes, if I had read the descriptions carefully, but, let's be honest.. We both know I probably didn't :slight_smile:

So, for all I know the code I put was viable (if inelegant) but was failing because I'm an ijit :slight_smile: I do like your solution better @vgaetera if it I can get it work as needed in the Makefile.

1 Like

Is there a reason why you can't do that in the "normal" source manipulation stage, "prepare" ???

Example search of what I mean
https://github.com/openwrt/packages/search?l=Makefile&q=prepare

2 Likes

As I stated, I needed it to come at the end of the Host/ build tree.. Which, I suppose, is going to be Host/Install (especially since the package also doesn't use make install).

I already use Host/Prepare to setup the symlinks and other directories, in addition to calling Host/Prepare/Default so it'll extract and patch. I was misunderstanding when Host/InstallDev was being called.

define Host/Prepare
	$(call Host/Prepare/Default)
	# Allows outside packages to call $$(BUILD_DIR_HOST)/rust as the dir
	# rather than needing the version number.
	[ -L $(BUILD_DIR_HOST)/rust ] || (cd $(BUILD_DIR_HOST); ln -s "$(PKG_NAME)-$(PKG_VERSION)" rust)

	# This is our CARGO_HOME, so make sure it's there to receive files
	[ -d $(CARGO_HOME) ] || (mkdir -p $(CARGO_HOME))
	[ -d $(RUSTUP_HOME) ] || (mkdir -p $(RUSTUP_HOME))

endef

I'm getting into the next phase of getting this package finished, I'm going to need help with the best ways to do things. :slight_smile:

Build completed successfully in 1:49:02

@vgaetera - This is what I ended up with and seems to work as intended.. Thank you so much, once again!

define Host/Install
	cd $(HOST_BUILD_DIR)/build/dist/ && \
	   find -iname "*.xz" -exec tar -x -J -f {} ";" && \
	   find ./* -type f -name install.sh -execdir sh {} --prefix=$(CARGO_HOME) --disable-ldconfig \;
endef

It might be better to add -type f to the first find and remove ./* from the second find.

The first line extracts these, which each drop into their own subdir..

build-manifest-nightly-x86_64-unknown-linux-gnu.tar.xz  rustc-nightly-src.tar.xz
cargo-nightly-x86_64-unknown-linux-gnu.tar.xz           rustc-nightly-x86_64-unknown-linux-gnu.tar.xz
clippy-nightly-x86_64-unknown-linux-gnu.tar.xz          rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
llvm-tools-nightly-x86_64-unknown-linux-gnu.tar.xz      rust-nightly-x86_64-unknown-linux-gnu.tar.xz
miri-nightly-x86_64-unknown-linux-gnu.tar.xz            rust-src-nightly.tar.xz
rust-analysis-nightly-x86_64-unknown-linux-gnu.tar.xz   rust-std-nightly-mips64-unknown-linux-muslabi64.tar.xz
rust-analyzer-nightly-x86_64-unknown-linux-gnu.tar.xz   rust-std-nightly-x86_64-unknown-linux-gnu.tar.xz
rustc-dev-nightly-x86_64-unknown-linux-gnu.tar.xz

and then each sub-dir has an install.sh that needs to be run.

It's a complete hacky work around to a known bug rust has, but it does allow to save the compiled binaries and libs once they are created, so next will be a way to determine if they've already been created or not, and use them if so.

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.