Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use original Cygwin setup preferences and repo folder #24

Open
starise opened this issue Sep 3, 2017 · 8 comments
Open

Use original Cygwin setup preferences and repo folder #24

starise opened this issue Sep 3, 2017 · 8 comments

Comments

@starise
Copy link

starise commented Sep 3, 2017

I started using this fork of apt-cyg that gives me everything I needed and more. However, I noticed that it downloads a new installer and uses a different hardcoded /setup folder instead of the one followed by the cygwin original installer. Is there a specific reason why it was decided to "hardcode" the setup directory instead of following the cygwin convention? If not, take it as a suggestion for a future improvement.

Thanks for your work on this tool. :)

@kou1okada
Copy link
Owner

There are no reasons, except the original apt-cyg was doing so.
In currently, if you want to use the cache folder which is used by the cygwin original installer (setup-x86_64.exe or setup-x86.exe), please try --use-setuprc option as below:

apt-cyg --use-setuprc update

This option overwrite /etc/setup/last-mirror and /etc/setup/last-cache by the setting of /etc/setup/setup.rc.
Thereafter, apt-cyg will use these settings permanently.

Hmm, this solution is not smart :-(
Maybe, I should consider removing the original hard coded routine for a future improvement.

By the way, my pretty script cygwin_autoinstall.bat uses --use-setuprc option.
Maybe this script makes newcomers happy by a following command line for cmd.exe:

MKDIR %USERPROFILE%\Downloads\cygwin && CD %USERPROFILE%\Downloads\cygwin && powershell -Command "Import-Module BitsTransfer; Start-BitsTransfer https://gist.github.com/kou1okada/7802343/raw/cygwin_autoinstall.bat" && cygwin_autoinstall.bat

Perhaps, it's a part of my future plans.

Thanks.

@DRSDavidSoft
Copy link

DRSDavidSoft commented Jun 1, 2018

Hey @kou1okada, I was about to open the same issue until I noticed this one exists.
I also came from the original implementation, because @kenijo's shark also uses it.

Yes, the original apt-cyg did this with the same manner, but please consider the following:

  • Cygwin is installed by the setup.exe, and thus the directories are made with there, which means creating duplicated cache directories is inefficient on both harddisk and bandwidth.
  • Why the ftp.jaist.ac.jp mirror should be hardcoded? It makes much more sense to use whatever setup.rc is using.

The original implementation did this by default, because it was supposed to be a command-line alternative to setup.exe. I think this fork should also use a shared directory, instead of creating its own. Of course, that's just my opinion.

Is there any way to run apt-cyg with --use-setuprc by default? Kind of like aliasing it?
Also, does @transcode-open's fork use the same behavior, or is it specific to your fork?

@E3V3A
Copy link

E3V3A commented Nov 17, 2018

Aah, this explain some mysterious behavior of setup not noticing when I have removed or added packages using this apt-cyg, unlike using or the "original" apt-cyg! Because I have relocated the package directory for the original setup. I wish I had seen this issue before!

@kou1okada
Can you please look into this again?

@E3V3A
Copy link

E3V3A commented Dec 9, 2018

Hi @kou1okada

The more I use apt-cyg, the more this is becoming as issue.
The way it is currently implemented, by using /etc/setup/last-cache and /etc/setup/last-mirror, does not work and is outdated. (Those files have not been used for years!)

function findworkspace()
{
  # default working directory, mirror and architecture
  
  mirror=http://ftp.jaist.ac.jp/pub/cygwin
  arch="$(current_cygarch)"
  cache=/setup
  
  # work wherever setup worked last, if possible
  
  if [ -e /etc/setup/last-cache ]; then
    cache="$(cygpath -au "$(head -1 /etc/setup/last-cache)")"
  fi
  cache="${cache%/}"
  
  if [ -e /etc/setup/last-mirror ]; then
    mirror="$(head -1 /etc/setup/last-mirror)"
  fi
  mirror="${mirror%/}"
  mirrordir="$(mirror_to_mirrordir "$mirror/")"
  
  verbose 1 "Cache directory is $cache"
  verbose 1 "Mirror is $mirror"
  mkdir -p "$cache/$mirrordir/$arch"
  cd "$cache/$mirrordir/$arch"
  
  init_gnupg
  fetch_trustedkeys
}

Instead, it should read something like this:

function find-workspace {
  # default working directory and mirror
  
  # work wherever setup worked last, if possible
  cache=$(awk '
  BEGIN {
    RS = "\n\\<"
    FS = "\n\t"
  }
  $1 == "last-cache" {
    print $2
  }
  ' /etc/setup/setup.rc)

  mirror=$(awk '
  /last-mirror/ {
    getline
    print $1
  }
  ' /etc/setup/setup.rc)
  mirrordir=$(sed '
  s / %2f g
  s : %3a g
  ' <<< "$mirror")

  mkdir -p "$cache/$mirrordir/$arch"
  cd "$cache/$mirrordir/$arch"
  if [ -e setup.ini ]
  then
    return 0
  else
    get-setup
    return 1
  fi
}

Anything else doesn't make sense, and is incompatible with native setup, causing package incongruities.
I.e. setup doesn't see what was installed by apt-cyg and vice versa. (I use both methods.)

@E3V3A
Copy link

E3V3A commented Feb 4, 2019

@kou1okada
Any updates?

kou1okada added a commit that referenced this issue Feb 18, 2019
* remove `--use-setuprc` and `--use-own-conf` options.
* TODO: update `--mirror` and `--cache` options.
kou1okada added a commit that referenced this issue Mar 8, 2019
@hashimaziz1
Copy link

Has this been fixed?

@kou1okada
Copy link
Owner

Yes, this has been fixed.
But currently, if you set multiple-mirrors, apt-cyg uses the first one only.
And if you run setup-x86{_64,}.exe, the order of multiple-mirrors will be changed by setup-x86{_64,}.exe.

@hashimaziz1
Copy link

Yes, this has been fixed.
But currently, if you set multiple-mirrors, apt-cyg uses the first one only.
And if you run setup-x86{_64,}.exe, the order of multiple-mirrors will be changed by setup-x86{_64,}.exe.

Brilliant, thanks for your great work on this fork, I've been using the original transcode version for years without realising there was a more fully-featured and up-to-date version out there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants