refactor filebrowser build script
This commit is contained in:
parent
076810cfb8
commit
c6715eca10
|
@ -2,17 +2,18 @@
|
||||||
|
|
||||||
version="${1:?You need to specific a version, eg: v1.22.2}"
|
version="${1:?You need to specific a version, eg: v1.22.2}"
|
||||||
version_num="${version##v}"
|
version_num="${version##v}"
|
||||||
|
package_name=filebrowser-${version_num}.tar.gz
|
||||||
|
|
||||||
|
|
||||||
# must occur dirs
|
# must occur dirs
|
||||||
material_dir="./materials"
|
material_dir="./materials"
|
||||||
|
|
||||||
# optional dirs (created during build)
|
# optional dirs (created during build)
|
||||||
download_dir="./downloads"
|
download_dir="./var/downloads"
|
||||||
package_dir="./packages"
|
extract_dir="./var/extracted"
|
||||||
extract_dir="./extracted"
|
rootfs="./var/rootfs"
|
||||||
rootfs="./rootfs"
|
|
||||||
|
|
||||||
package_name=filebrowser-${version_num}.tar.gz
|
package_dir="./packages"
|
||||||
|
|
||||||
|
|
||||||
function copy_file {
|
function copy_file {
|
||||||
|
@ -29,35 +30,42 @@ function copy_file {
|
||||||
mkdir -p $dst_dir
|
mkdir -p $dst_dir
|
||||||
cp --no-target-directory $src $dst
|
cp --no-target-directory $src $dst
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# don't re-download if already downloaded
|
function download {
|
||||||
if [ ! -f "${download_dir}/${package_name}" ] ; then
|
# don't re-download if already downloaded
|
||||||
mkdir -p ${download_dir}
|
if [ ! -f "${download_dir}/${package_name}" ] ; then
|
||||||
wget --output-document ${download_dir}/${package_name} https://github.com/filebrowser/filebrowser/releases/download/${version}/linux-amd64-filebrowser.tar.gz
|
mkdir -p ${download_dir}
|
||||||
fi
|
wget --output-document ${download_dir}/${package_name} https://github.com/filebrowser/filebrowser/releases/download/${version}/linux-amd64-filebrowser.tar.gz
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
rm -rf ${extract_dir}
|
|
||||||
mkdir -p ${extract_dir}
|
|
||||||
tar -xf ${download_dir}/${package_name} -C ${extract_dir}
|
|
||||||
|
|
||||||
# clean rootfs
|
function extract {
|
||||||
rm -rf ${rootfs}
|
rm -rf ${extract_dir}
|
||||||
|
mkdir -p ${extract_dir}
|
||||||
|
tar -xf ${download_dir}/${package_name} -C ${extract_dir}
|
||||||
|
}
|
||||||
|
|
||||||
# move files
|
|
||||||
copy_file ${extract_dir}/filebrowser ${rootfs}/usr/bin/filebrowser
|
|
||||||
|
|
||||||
copy_file ${extract_dir}/CHANGELOG.md ${rootfs}/usr/share/filebrowser/
|
function build_rootfs {
|
||||||
copy_file ${extract_dir}/LICENSE ${rootfs}/usr/share/filebrowser/
|
rm -rf ${rootfs}
|
||||||
copy_file ${extract_dir}/README.md ${rootfs}/usr/share/filebrowser/
|
|
||||||
|
|
||||||
copy_file ${material_dir}/filebrowser.service ${rootfs}/usr/lib/systemd/system/filebrowser.service
|
copy_file ${extract_dir}/filebrowser ${rootfs}/usr/bin/filebrowser
|
||||||
|
|
||||||
# debian packages meta file
|
copy_file ${extract_dir}/CHANGELOG.md ${rootfs}/usr/share/filebrowser/
|
||||||
mkdir -p $rootfs/DEBIAN
|
copy_file ${extract_dir}/LICENSE ${rootfs}/usr/share/filebrowser/
|
||||||
sed "s/+++VERSION+++/${version_num}/" > $rootfs/DEBIAN/control << EOF
|
copy_file ${extract_dir}/README.md ${rootfs}/usr/share/filebrowser/
|
||||||
|
|
||||||
|
copy_file ${material_dir}/filebrowser.service ${rootfs}/usr/lib/systemd/system/filebrowser.service
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function package_meta {
|
||||||
|
# debian packages meta file
|
||||||
|
mkdir -p $rootfs/DEBIAN
|
||||||
|
sed "s/+++VERSION+++/${version_num}/" > $rootfs/DEBIAN/control << EOF
|
||||||
Package: filebrowser
|
Package: filebrowser
|
||||||
Version: +++VERSION+++
|
Version: +++VERSION+++
|
||||||
Priority: optional
|
Priority: optional
|
||||||
|
@ -66,5 +74,17 @@ Maintainer: leafee98 <me@leafee98.com>
|
||||||
Description: Web File Browser
|
Description: Web File Browser
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
mkdir -p $package_dir
|
}
|
||||||
dpkg-deb --build --root-owner-group $rootfs $package_dir/filebrowser-${version}.deb
|
|
||||||
|
|
||||||
|
function main {
|
||||||
|
download
|
||||||
|
extract
|
||||||
|
build_rootfs
|
||||||
|
package_meta
|
||||||
|
|
||||||
|
mkdir -p $package_dir
|
||||||
|
dpkg-deb --build --root-owner-group $rootfs $package_dir/filebrowser-${version}.deb
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
|
Loading…
Reference in a new issue