Skip to content

Instantly share code, notes, and snippets.

@spvkgn
Last active July 23, 2023 04:39
Show Gist options
  • Save spvkgn/6fbfe7a68dbfec0feade847729117751 to your computer and use it in GitHub Desktop.
Save spvkgn/6fbfe7a68dbfec0feade847729117751 to your computer and use it in GitHub Desktop.
Build far2l for OpenWrt

Build Far2L using OpenWrt SDK toolchain

  • wget https://downloads.openwrt.org/releases/21.02.3/targets/ramips/mt7621/openwrt-sdk-21.02.3-ramips-mt7621_gcc-8.4.0_musl.Linux-x86_64.tar.xz

  • tar xvf $(ls openwrt-sdk-*.tar.xz) && cd $(ls -d openwrt-sdk-*/) && mkdir -p package/far2l && nano package/far2l/Makefile

include $(TOPDIR)/rules.mk

GIT_HASH:=$(shell wget -qO- https://api.github.com/repos/elfmz/far2l/commits/master | grep -Po -m1 '"sha": "\K.{7}')

PKG_NAME:=far2l
PKG_VERSION:=$(shell wget -qO- https://raw.githubusercontent.com/elfmz/far2l/master/packaging/version)-$(GIT_HASH)
PKG_RELEASE:=1

PKG_LICENSE:=GPL-2
PKG_LICENSE_FILES:=LICENSE.txt

PKG_REV:=master
PKG_SOURCE:=$(PKG_REV).tar.gz
PKG_SOURCE_URL:=https://github.com/elfmz/far2l/archive/
PKG_HASH:=skip
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_REV)
PKG_BUILD_PARALLEL:=1

CMAKE_INSTALL:=1

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk

define Package/far2l/Default
	SECTION:=utils
	CATEGORY:=Utilities
	TITLE:=Far2L File Manager
	URL:=https://github.com/elfmz/far2l
endef

define Package/far2l
	$(call Package/far2l/Default)
	DEPENDS:=+libstdcpp
	VARIANT:=default
endef

define Package/far2l-tiny
	$(call Package/far2l/Default)
	TITLE+= (compact version)
	DEFAULT:=n
	VARIANT:=tiny
endef

define Package/far2l/install
	$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/far2l $(1)/usr/share/far2l
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/far2l $(1)/usr/bin
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/far2l/* $(1)/usr/lib/far2l/
	$(CP) $(PKG_INSTALL_DIR)/usr/share/far2l/* $(1)/usr/share/far2l/
endef

define Package/far2l-tiny/install
	$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/share/far2l
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/far2l $(1)/usr/bin
	$(CP) $(PKG_INSTALL_DIR)/usr/share/far2l/FarEng.* $(1)/usr/share/far2l/
	$(CP) $(PKG_INSTALL_DIR)/usr/share/far2l/*.sh $(1)/usr/share/far2l/
	$(CP) $(PKG_INSTALL_DIR)/usr/share/far2l/*.ini $(1)/usr/share/far2l/
endef

CMAKE_OPTIONS += \
	-DUSEUCD=no -DUSEWX=no -DCOLORER=no -DNETROCKS=no \
	-DGIT_HASH=$(GIT_HASH) -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON

ifeq ($(BUILD_VARIANT),tiny)
	TARGET_LDFLAGS += -static-libstdc++
	CMAKE_OPTIONS += \
		-DALIGN=no -DAUTOWRAP=no -DCALC=no -DCOMPARE=no -DDRAWLINE=no \
		-DEDITCASE=no -DEDITORCOMP=no -DFILECASE=no -DINCSRCH=no \
		-DINSIDE=no -DMULTIARC=no -DSIMPLEINDENT=no -DTMPPANEL=no
endif

ifdef CONFIG_USE_MUSL
	CMAKE_OPTIONS += -DMUSL=ON
endif

ifdef CONFIG_PACKAGE_busybox
	CMAKE_OPTIONS += -DTAR_LIMITED_ARGS=ON
endif

$(eval $(call BuildPackage,far2l))
$(eval $(call BuildPackage,far2l-tiny))
  • mkdir -p package/far2l/patches && wget https://github.com/unxed/far2l-deb/raw/master/portable/tty_tweaks.patch -qP package/far2l/patches
cat << "EOF" > package/far2l/patches/series
tty_tweaks.patch
EOF
  • make defconfig ; make package/far2l/compile V=s -j `nproc` BUILD_LOG=1

    • < Exit >< Yes >
  • for i in ./bin/packages/*/base/far2l*.ipk ; do cp $i .. && fakeroot tar czvf ../$(basename $i .ipk).tar.gz -C build_dir/target-*/far2l-*/.pkgdir/$(basename $i | cut -d_ -f1) ./usr ; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment