sezanzeb / input-remapper

🎮 ⌨ An easy to use tool to change the behaviour of your input devices.
GNU General Public License v3.0
3.75k stars 155 forks source link

Build script is not working on Linux MX #479

Open sergiymaksymenko opened 2 years ago

sergiymaksymenko commented 2 years ago

Build script scripts/buiild.sh is not working on my Linux MX 21 (Debian GNU/Linux 11, bullseye). The reason is that it does not finds correct paths. If we change it as follows:

build_deb() {
  # https://www.devdungeon.com/content/debian-package-tutorial-dpkgdeb
  # that was really easy actually
  rm build -r
  mkdir build/deb -p
  cd ..
  python3 ./setup.py install --root=scripts/build/deb
  mv scripts/build/deb/usr/local/lib/python3.*/ scripts/build/deb/usr/lib/python3/
  cp ./DEBIAN scripts/build/deb/ -r
  mkdir dist -p
  rm dist/input-remapper-1.5.0.deb || true
  dpkg -b scripts/build/deb dist/input-remapper-1.5.0.deb
}

then creating deb-package can be run by the command:

cd input-remapper/scripts/ && ./build.sh

sezanzeb commented 2 years ago

The script was made to be run like ./scripts/build.sh (as seen in the readme)

would it be possible to change the build script so that both cd scripts && ./build.sh and ./scripts/build.sh work?

sergiymaksymenko commented 2 years ago

Hi, thank you for the message, yes, it is better to change script than the README. We can change the function as follows:

build_deb() {
  # https://www.devdungeon.com/content/debian-package-tutorial-dpkgdeb
  # that was really easy actually
  cd ..
  baseDir=$(pwd)
  scriptsDir=${baseDir}/scripts     # scripts/
  buildDir=${scriptsDir}/build      # scripts/build/
  debDir=${buildDir}/deb            # scripts/build/deb
  distDir=${baseDir}/dist           # dist/

  rm ${buildDir} -r
  mkdir ${debDir} -p
  python3 ${baseDir}/setup.py install --root=${debDir}
  mv ${debDir}/usr/local/lib/python3.*/ ${debDir}/usr/lib/python3/
  cp ${baseDir}/DEBIAN ${debDir}/ -r
  mkdir ${distDir} -p
  rm ${distDir}/input-remapper-1.5.0.deb || true
  dpkg -b ${debDir} ${distDir}/input-remapper-1.5.0.deb
}

Now it works as required by cd scripts && ./build.sh. It explicitly substitutes all full paths, and therefore it should work on all distributions. Also the command mv ${debDir}/usr/local/lib/python3.*/ ${debDir}/usr/lib/python3/ assumes that python3 installs everything into usr/local/lib/ and the program require for python3 to be installed into usr/lib/.

sezanzeb commented 2 years ago

I think something like a check

# ensure we are in the root directory of the project
if [ ! -f "./setup.py" ]; then
    cd ..
fi

would make it flexible and avoid problems.

Could you please test it and make a PR for this? And please add "_all" to the two occurrences of the output filename, like input-remapper-1.5.0_all.deb, to address https://github.com/sezanzeb/input-remapper/issues/480